editInfo.vue 16 KB

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