editInfo.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. <template>
  2. <view class="page">
  3. <PageHeader title="" class="PageHeader">
  4. <template slot="center">
  5. 基本资料
  6. </template>
  7. </PageHeader>
  8. <view class="reserveASeat"></view>
  9. <!-- <view style="height: 90rpx;"></view> -->
  10. <view class="list_info">
  11. <view class="bcenter">
  12. <view class="avator" @click="upload">
  13. <!-- <image class="img" :src="avator" mode="aspectFill" /> -->
  14. <CircleAvatar class="avator" :src="avator" style="width: 200rpx; height: 200rpx;"></CircleAvatar>
  15. <image class="photo" src="../../static/me/photo.png" mode="widthFix" />
  16. </view>
  17. </view>
  18. <view class="section_title">基本信息</view>
  19. <view class="info_card">
  20. <view class="info_item" @click="openNicknamePopUpWindow">
  21. <text class="label">昵称</text>
  22. <view class="content">
  23. <text v-if="nickname" class="textContent">{{ nickname }}</text>
  24. <text v-else class="textPrompt">请输入昵称</text>
  25. <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" />
  26. </view>
  27. </view>
  28. <view class="info_item" @click="SetSex">
  29. <text class="label">性别</text>
  30. <view class="content">
  31. <input type="text" placeholder="选择你的性别" v-model="sexText" disabled="true" />
  32. <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" />
  33. </view>
  34. </view>
  35. <view class="info_item">
  36. <text class="label">生日</text>
  37. <view class="content">
  38. <picker mode="date" :value="birthday" :end="endDate" @change="onBirthdayChange">
  39. <input type="text" placeholder="选择你的生日" v-model="birthday" disabled="true" />
  40. </picker>
  41. <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" />
  42. </view>
  43. </view>
  44. <view class="info_item">
  45. <text class="label">星座</text>
  46. <view class="content">
  47. <input type="text" placeholder="根据你的生日自动匹配" :value="xinzuo_sel" disabled="true"
  48. style="padding-right: 43rpx;" />
  49. <!-- <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" /> -->
  50. </view>
  51. </view>
  52. <view class="info_item" @click="openContentPopUpWindow">
  53. <text class="label">简介</text>
  54. <view class="content">
  55. <!-- <input type="text" placeholder="做个自我介绍吧~" v-model="content" maxlength="32" /> -->
  56. <text v-if="content" class="textContent one-omit">{{ content }}</text>
  57. <text v-else class="textPrompt">做个自我介绍吧</text>
  58. <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" />
  59. </view>
  60. </view>
  61. </view>
  62. <view class="section_title">个性标签</view>
  63. <view class="info_card">
  64. <view class="item_tag">
  65. <view class="tag" v-for="(item, index) in sel_tags" :key="index">
  66. {{ item }}
  67. <image class="close" src="../../static/me/close.png" mode="widthFix" @click="delTag(item)" />
  68. </view>
  69. <view class="addNew" @click="showPop = true;">+ 添加</view>
  70. </view>
  71. </view>
  72. <view class="blankHeight"></view>
  73. </view>
  74. <view class="btn_submit" @click="submitData(true)">保存</view>
  75. <DialogBox ref="DialogBox"></DialogBox>
  76. <view class="popSel" v-if="showPop" @tap.stop="onPreview">
  77. <PageHeader title="添加标签" @back="showPop = false" :isBack="false" style="background: #f2f6f2;" />
  78. <view class="reserveASeat"></view>
  79. <view class="headLabel">
  80. <view class="avator-box">
  81. <CircleAvatar class="avator" :src="avator"></CircleAvatar>
  82. <view class="one-omit">{{ nickname }}</view>
  83. </view>
  84. <view class="tag-box">
  85. <view class="tag" v-for="(item, index) in sel_tags" :key="index">
  86. {{ item }}
  87. <image class="close" src="../../static/me/close.png" mode="widthFix" @click="delTag(item)" />
  88. </view>
  89. </view>
  90. </view>
  91. <view class="list_info">
  92. <view class="name">你的兴趣爱好是?</view>
  93. <view class="desc">提示:最多选择5个兴趣爱好标签</view>
  94. <view style="height: 700rpx; overflow-y: scroll; margin-top: 20rpx; padding-bottom: 100rpx;">
  95. <view class="add-tag-box" style="color: #000;" v-if="showAddTag">
  96. <input
  97. class="add-tag-input"
  98. v-model="newTag"
  99. placeholder="请输入标签名称"
  100. maxlength="10"
  101. @confirm="addCustomTag"
  102. />
  103. <view class="add-tag-btns">
  104. <text class="cancel-btn" @tap="cancelAddTag">取消</text>
  105. <text class="confirm-btn" @tap="addCustomTag">确定</text>
  106. </view>
  107. </view>
  108. <view class="item_tag">
  109. <view class="tag add-tag" @tap="showAddTagInput">
  110. <text>+ 自定义</text>
  111. </view>
  112. <view @tap.stop="chkTag(item)" class="tag" :class="selTags(item) ? 'active' : ''"
  113. v-for="(item, index) in list_tag" :key="index">
  114. {{ item }}
  115. </view>
  116. </view>
  117. </view>
  118. </view>
  119. <view class="btn_submit" @click="showPop = false;">提交选择</view>
  120. </view>
  121. <ToastW3 ref="ToastW3"></ToastW3>
  122. <view v-if="showRights"
  123. style="width:100%;height:300rpx;background-color: rgba(255,255,255,0.9);position: fixed;top:0;display: flex;flex-direction: column;justify-content: center;align-items: center;">
  124. <text
  125. style="width:90%;color:#000000;font-size:38rpx;text-align: left;padding:10rpx 20rpx;padding-top:10rpx;">正在获取相机、存储权限</text>
  126. <text
  127. style="width:90%;color:#666666;font-size:28rpx;text-align: left;padding:10rpx 20rpx;">该权限用于获取设备拍摄或获取本地应用相册,进行头像或图片上传。</text>
  128. </view>
  129. <view>
  130. <NicknamePopup title="编辑昵称" subtitle="" class="openNicknamePopUpWindow" ref="openNicknamePopUpWindow">
  131. <template slot="content">
  132. <view class="input-box">
  133. <uv-input placeholder="请输入昵称" border="surround" v-model="nickname" maxlength="20"></uv-input>
  134. <view class="length-indicator">{{ nickname.length }}/20</view>
  135. </view>
  136. <view class="btn-box" @click="submitData">保存</view>
  137. </template>
  138. </NicknamePopup>
  139. <NicknamePopup title="专属于你的简介" subtitle="好的简介让你在社区更受关注" class="openContentPopUpWindow"
  140. ref="openContentPopUpWindow">
  141. <template slot="content">
  142. <uv-textarea v-model="content" maxlength="50" count placeholder="请输入内容"></uv-textarea>
  143. <view class="btn-box" @click="submitData">保存</view>
  144. </template>
  145. </NicknamePopup>
  146. </view>
  147. </view>
  148. </template>
  149. <script>
  150. import {
  151. requestAndroidPermission,
  152. gotoAppPermissionSetting
  153. } from '../index/permission.js'
  154. import PageHeader from '@/components/PageHeader/PageHeader.vue';
  155. import CircleAvatar from '@/components/CircleAvatar/CircleAvatar.vue';
  156. import NicknamePopup from '@/components/NicknamePopup/NicknamePopup.vue';
  157. export default {
  158. components: {
  159. PageHeader,
  160. CircleAvatar,
  161. NicknamePopup
  162. },
  163. data() {
  164. return {
  165. showRights: false,
  166. title: '',
  167. sel: 1,
  168. info: {},
  169. showPop: false,
  170. nickname: '',
  171. content: '',
  172. sex: 1,
  173. age: 18,
  174. height: 160,
  175. weight: 50,
  176. avator: '../../static/me/avator.png',
  177. ziye: '',
  178. qianmin: '',
  179. xinzuo_sel: '',
  180. xinzuo: ['水瓶座', '双鱼座', '白羊座', '金牛座', '双子座', '巨蟹座', '狮子座', '处女座', '天秤座', '天蝎座', '射手座', '摩羯座'],
  181. list_tag: [],
  182. sel_tags: [],
  183. sexText: '',
  184. birthday: '',
  185. sexOptions: ['男', '女', '其他'],
  186. endDate: new Date().toISOString().split('T')[0],
  187. showAddTag: false,
  188. newTag: '',
  189. }
  190. },
  191. onLoad() {
  192. let tagStr =
  193. "老二次元了、coser、沉迷音乐、网游小达人、AJ控、白日梦想家、撸铁狂魔、古风汉服、爱画画、数码极客、盲盒玩家、三坑玩家、动漫达人、独立设计师、爱卡通、兜风去、爱夜跑、街头滑板、球类运动、lo娘、rapper、时尚达人、机甲狂潮、养宠物、风轻云淡、养多肉、热爱自然、赛博朋克、骨子里高冷、爱唠嗑、资深中二、天然呆、思想家、极度抽象、学院派、平平无奇、热情奔放、博古通今、labubu粉、玛特收藏家";
  194. this.list_tag = tagStr.split("、");
  195. this.getInfoData();
  196. },
  197. onShow() {},
  198. methods: {
  199. openNicknamePopUpWindow() {
  200. this.$refs.openNicknamePopUpWindow.open();
  201. },
  202. openContentPopUpWindow() {
  203. this.$refs.openContentPopUpWindow.open();
  204. },
  205. closePropUp() {
  206. this.$refs.openNicknamePopUpWindow.close();
  207. this.$refs.openContentPopUpWindow.close();
  208. },
  209. onBack() {},
  210. onPreview() {},
  211. chkSel() {
  212. if (this.sel == 1) {
  213. this.sel = 0;
  214. } else {
  215. this.sel = 1;
  216. }
  217. },
  218. chkSex(sex) {
  219. this.sex = sex;
  220. },
  221. delTag(tg) {
  222. let list_tag2 = [];
  223. for (let i = 0; i < this.sel_tags.length; i++) {
  224. if (this.sel_tags[i] != tg) {
  225. list_tag2.push(this.sel_tags[i]);
  226. }
  227. }
  228. this.sel_tags = list_tag2;
  229. },
  230. selTags(itm) {
  231. let isIn = false;
  232. for (let entry of this.sel_tags) {
  233. if (entry == itm) {
  234. isIn = true;
  235. break;
  236. }
  237. }
  238. return isIn;
  239. },
  240. chkTag(itm) {
  241. if (this.selTags(itm)) {
  242. let tmpTags = [];
  243. for (let entry of this.sel_tags) {
  244. if (entry != itm) {
  245. tmpTags.push(entry);
  246. }
  247. }
  248. this.sel_tags = tmpTags;
  249. } else {
  250. if (this.sel_tags.length <= 4) {
  251. this.sel_tags.push(itm);
  252. } else {
  253. uni.showToast({
  254. title: "最多选择5个标签",
  255. icon: "none"
  256. });
  257. }
  258. }
  259. },
  260. sliderChange1(e) {
  261. this.age = e.detail.value;
  262. },
  263. sliderChange2(e) {
  264. this.height = e.detail.value;
  265. },
  266. sliderChange3(e) {
  267. this.weight = e.detail.value;
  268. },
  269. SetSex() {
  270. let that = this;
  271. uni.showActionSheet({
  272. itemColor: '#000000',
  273. itemList: this.sexOptions,
  274. success: function(res) {
  275. that.sexText = that.sexOptions[res.tapIndex];
  276. that.sex = res.tapIndex + 1;
  277. },
  278. fail: function(res) {
  279. console.log(res.errMsg);
  280. }
  281. });
  282. },
  283. getInfoData() {
  284. uni.request({
  285. url: this.$apiHost + '/Member/getinfoData',
  286. data: {
  287. uuid: getApp().globalData.uuid
  288. },
  289. header: {
  290. 'content-type': 'application/json'
  291. },
  292. success: (res) => {
  293. console.log(res.data);
  294. this.nickname = res.data.nickname;
  295. this.wechat = res.data.wechat;
  296. this.sex = res.data.sex;
  297. this.sexText = this.sexOptions[res.data.sex - 1] || '';
  298. this.birthday = res.data.birthday;
  299. this.xinzuo_sel = this.getConstellation(this.birthday);
  300. if (res.data.avator != "") {
  301. this.avator = res.data.avator;
  302. }
  303. if (res.data.aihao) {
  304. this.sel_tags = res.data.aihao.split(",");
  305. }
  306. }
  307. });
  308. },
  309. submitData(isBack) {
  310. let aihao = this.sel_tags.join(',')
  311. let obj2 = {
  312. uuid: getApp().globalData.uuid,
  313. avator: this.avator,
  314. nickname: this.nickname,
  315. content: this.content,
  316. sex: this.sex,
  317. birthday: this.birthday,
  318. xinzuo: this.xinzuo_sel,
  319. ziye: this.ziye,
  320. qianmin: this.qianmin,
  321. aihao: aihao
  322. }
  323. uni.request({
  324. url: this.$apiHost + '/Member/setinfoData',
  325. data: obj2,
  326. method: 'POST',
  327. header: {
  328. 'Content-Type': 'application/x-www-form-urlencoded',
  329. 'sign': getApp().globalData.headerSign
  330. },
  331. dataType: 'json',
  332. success: (res) => {
  333. console.log("res", res.data)
  334. this.$refs['ToastW3'].showToast({
  335. title: res.data.str,
  336. animation: 0
  337. });
  338. if (this.success == 'yes' && isBack == true) {
  339. if (this.nickname) {
  340. getApp().globalData.nickname = this.nickname
  341. uni.removeStorageSync("nickname");
  342. uni.setStorageSync("nickname", this.nickname);
  343. }
  344. if (this.avator) {
  345. getApp().globalData.avator = this.avator
  346. uni.removeStorageSync("avator");
  347. uni.setStorageSync("avator", this.avator);
  348. }
  349. setTimeout(function() {
  350. console.log('返回');
  351. uni.navigateBack()
  352. }, 800)
  353. } else {
  354. this.closePropUp()
  355. }
  356. this.getInfoData()
  357. }
  358. });
  359. },
  360. upload() {
  361. this.checkRights();
  362. console.log("----upload");
  363. var _self = this;
  364. uni.chooseImage({
  365. count: 1,
  366. sizeType: ['compressed'],
  367. sourceType: ['album', 'camera'],
  368. success: function(res) {
  369. console.log('res:', res)
  370. if (res.tempFilePaths.length > 0) {
  371. _self.imglocal = res.tempFilePaths[0]
  372. const tempFilePaths = res.tempFilePaths[0];
  373. console.log('tempFilePaths:', tempFilePaths);
  374. const uploadTask = uni.uploadFile({
  375. url: _self.$apiHost + '/Xweb/upload_img?skey=' + _self.skey,
  376. filePath: res.tempFilePaths[0],
  377. name: 'file',
  378. success: function(uploadFileRes) {
  379. let resdata = JSON.parse(uploadFileRes.data)
  380. console.log('Success11:', uploadFileRes);
  381. console.log('Success21:', resdata);
  382. if (resdata.success == 'yes') {
  383. _self.showRights = false;
  384. _self.avator = resdata.url;
  385. }
  386. },
  387. fail: function(uploadFileFail) {
  388. console.log('Error:', uploadFileFail.data);
  389. },
  390. complete: () => {
  391. console.log('Complete:');
  392. }
  393. });
  394. }
  395. },
  396. error: function(e) {
  397. console.log(e);
  398. }
  399. });
  400. },
  401. checkRights() {
  402. let that = this;
  403. that.showRights = true;
  404. requestAndroidPermission('android.permission.CAMERA')
  405. .then(result => {
  406. that.showRights = false;
  407. if (result === 1) {} else if (result === 0) {
  408. console.log('权限被拒绝');
  409. } else if (result === -1) {
  410. console.log('权限被永久拒绝');
  411. }
  412. })
  413. .catch(error => {
  414. that.showRights = true;
  415. console.log('权限申请失败:', error);
  416. });
  417. },
  418. onBirthdayChange(e) {
  419. this.birthday = e.detail.value;
  420. this.xinzuo_sel = this.getConstellation(this.birthday);
  421. },
  422. getConstellation(birthday) {
  423. if (!birthday) return '';
  424. const month = parseInt(birthday.split('-')[1]);
  425. const day = parseInt(birthday.split('-')[2]);
  426. // 星座日期数组
  427. const constellationDates = [
  428. [1, 20, "水瓶座"],
  429. [2, 19, "双鱼座"],
  430. [3, 21, "白羊座"],
  431. [4, 20, "金牛座"],
  432. [5, 21, "双子座"],
  433. [6, 22, "巨蟹座"],
  434. [7, 23, "狮子座"],
  435. [8, 23, "处女座"],
  436. [9, 23, "天秤座"],
  437. [10, 24, "天蝎座"],
  438. [11, 23, "射手座"],
  439. [12, 22, "摩羯座"]
  440. ];
  441. let constellation = "";
  442. if (day < constellationDates[month - 1][1]) {
  443. constellation = constellationDates[month - 1][2];
  444. } else {
  445. constellation = constellationDates[month % 12][2];
  446. }
  447. return constellation;
  448. },
  449. showAddTagInput() {
  450. this.showAddTag = true;
  451. this.newTag = '';
  452. },
  453. cancelAddTag() {
  454. this.showAddTag = false;
  455. this.newTag = '';
  456. },
  457. addCustomTag() {
  458. if (!this.newTag.trim()) {
  459. uni.showToast({
  460. title: '请输入标签名称',
  461. icon: 'none'
  462. });
  463. return;
  464. }
  465. if (this.list_tag.includes(this.newTag)) {
  466. uni.showToast({
  467. title: '该标签已存在',
  468. icon: 'none'
  469. });
  470. return;
  471. }
  472. this.list_tag.unshift(this.newTag);
  473. this.showAddTag = false;
  474. this.newTag = '';
  475. },
  476. }
  477. }
  478. </script>
  479. <style scoped lang="scss">
  480. @import 'normal.scss';
  481. page {
  482. font-family: PingFang SC-Medium;
  483. }
  484. .popSel {
  485. position: fixed;
  486. z-index: 101;
  487. top: 0;
  488. left: 0;
  489. background-color: #f2f6f2;
  490. width: 100vh;
  491. min-height: 100vh;
  492. .headLabel {
  493. width: 686rpx;
  494. margin: 28rpx 32rpx;
  495. min-height: 222rpx;
  496. background: #fff;
  497. box-sizing: border-box;
  498. padding: 30rpx 40rpx 46rpx 20rpx;
  499. border-radius: 20rpx;
  500. .avator-box {
  501. display: flex;
  502. align-items: center;
  503. .avator {
  504. width: 80rpx;
  505. height: 80rpx;
  506. margin-right: 20rpx;
  507. }
  508. }
  509. .tag-box {
  510. display: flex;
  511. flex-direction: row;
  512. justify-content: flex-start;
  513. align-items: center;
  514. flex-wrap: wrap;
  515. font-size: 24rpx;
  516. .tag {
  517. margin-right: 16rpx;
  518. margin-top: 20rpx;
  519. padding: 6rpx 10rpx;
  520. border: 2rpx solid #DCE1DC;
  521. color: #9E9E9E;
  522. display: flex;
  523. justify-content: center;
  524. align-items: center;
  525. border-radius: 42rpx;
  526. line-height: 1;
  527. .close {
  528. width: 20rpx;
  529. margin-left: 12rpx;
  530. position: relative;
  531. }
  532. }
  533. }
  534. }
  535. }
  536. .openNicknamePopUpWindow {
  537. .length-indicator {
  538. font-size: 24rpx;
  539. color: #999;
  540. text-align: right;
  541. margin-top: 10rpx;
  542. margin-right: 20rpx;
  543. position: absolute;
  544. right: 24rpx;
  545. top: 24rpx;
  546. }
  547. }
  548. .popSel {
  549. .item_tag {
  550. display: flex;
  551. flex-direction: row;
  552. justify-content: flex-start;
  553. align-items: center;
  554. flex-wrap: wrap;
  555. width: 690rpx;
  556. padding: 20rpx;
  557. .tag {
  558. border-radius: 94rpx;
  559. margin-right: 10rpx;
  560. margin-top: 10rpx;
  561. padding: 8rpx 16rpx;
  562. font-size: 28rpx;
  563. color: #333;
  564. display: flex;
  565. flex-direction: row;
  566. justify-content: center;
  567. align-items: center;
  568. background: #fff;
  569. border-width: 0;
  570. .close {
  571. width: 28rpx;
  572. margin-left: 2rpx;
  573. position: relative;
  574. }
  575. }
  576. .active {
  577. border-width: 0;
  578. background: #ACF934;
  579. }
  580. .addNew {
  581. margin-right: 10rpx;
  582. margin-top: 10rpx;
  583. padding: 0rpx 20rpx;
  584. height: 60rpx;
  585. border-radius: 12rpx;
  586. background: #1f1f1f;
  587. color: #fff;
  588. display: flex;
  589. flex-direction: row;
  590. justify-content: center;
  591. align-items: center;
  592. }
  593. }
  594. }
  595. .reserveASeat {
  596. width: 100%;
  597. height: calc(var(--status-bar-height) + 50rpx);
  598. }
  599. .page {
  600. background: url("../../static/me/wd_bg_bianjiziliao.png") top center/ 100% auto no-repeat,
  601. #f2f6f2;
  602. }
  603. .PageHeader {
  604. background: url("../../static/me/wd_bg_bianjiziliao.png") center top / 100% auto no-repeat,
  605. #f2f6f2;
  606. background-position-y: var(--status-bar-height);
  607. }
  608. .add-tag-box {
  609. background: #fff;
  610. padding: 20rpx;
  611. margin: 20rpx;
  612. border-radius: 12rpx;
  613. .add-tag-input {
  614. width: 100%;
  615. height: 80rpx;
  616. background: #f5f5f5;
  617. border-radius: 8rpx;
  618. padding: 0 20rpx;
  619. font-size: 28rpx;
  620. margin-bottom: 20rpx;
  621. }
  622. .add-tag-btns {
  623. display: flex;
  624. justify-content: flex-end;
  625. gap: 20rpx;
  626. .cancel-btn, .confirm-btn {
  627. padding: 10rpx 30rpx;
  628. border-radius: 8rpx;
  629. font-size: 28rpx;
  630. }
  631. .cancel-btn {
  632. background: #f5f5f5;
  633. color: #666;
  634. }
  635. .confirm-btn {
  636. background: #1f1f1f;
  637. color: #fff;
  638. }
  639. }
  640. }
  641. .item_tag {
  642. .add-tag {
  643. background: #f5f5f5;
  644. color: #666;
  645. border: 2rpx dashed #ddd;
  646. &:active {
  647. background: #e5e5e5;
  648. }
  649. }
  650. }
  651. </style>