editInfo.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  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">提示:最多选择10个兴趣爱好标签</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. "看书、做弹弓玩、做木剑玩、做橡皮枪玩、积木、用麻将搭金字塔、拼图、拆装、扑克牌、小汽车、手表、鞋之类的、弹吉他、钢琴、萨克斯、葫芦丝、大号、小号、折纸、剪纸、品茶、涂鸦、英雄联盟、qq堂、cs、cf、地下城勇士、桌面游戏";
  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 <= 9) {
  227. this.sel_tags.push(itm);
  228. } else {
  229. this.$refs['ToastW3'].showToast({
  230. title: "最多选择10个标签",
  231. animation: 0
  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 (res.data.success == 'yes' && isBack == true) {
  315. setTimeout(function () {
  316. console.log('返回');
  317. uni.navigateBack()
  318. }, 800)
  319. } else {
  320. this.closePropUp()
  321. }
  322. this.getInfoData()
  323. }
  324. });
  325. },
  326. upload() {
  327. this.checkRights();
  328. console.log("----upload");
  329. var _self = this;
  330. uni.chooseImage({
  331. count: 1,
  332. sizeType: ['compressed'],
  333. sourceType: ['album', 'camera'],
  334. success: function (res) {
  335. console.log('res:', res)
  336. if (res.tempFilePaths.length > 0) {
  337. _self.imglocal = res.tempFilePaths[0]
  338. const tempFilePaths = res.tempFilePaths[0];
  339. console.log('tempFilePaths:', tempFilePaths);
  340. const uploadTask = uni.uploadFile({
  341. url: _self.$apiHost + '/Xweb/upload_img?skey=' + _self.skey,
  342. filePath: res.tempFilePaths[0],
  343. name: 'file',
  344. success: function (uploadFileRes) {
  345. let resdata = JSON.parse(uploadFileRes.data)
  346. console.log('Success11:', uploadFileRes);
  347. console.log('Success21:', resdata);
  348. if (resdata.success == 'yes') {
  349. _self.showRights = false;
  350. _self.avator = resdata.url;
  351. }
  352. },
  353. fail: function (uploadFileFail) {
  354. console.log('Error:', uploadFileFail.data);
  355. },
  356. complete: () => {
  357. console.log('Complete:');
  358. }
  359. });
  360. }
  361. },
  362. error: function (e) {
  363. console.log(e);
  364. }
  365. });
  366. },
  367. checkRights() {
  368. let that = this;
  369. that.showRights = true;
  370. requestAndroidPermission('android.permission.CAMERA')
  371. .then(result => {
  372. that.showRights = false;
  373. if (result === 1) { } else if (result === 0) {
  374. console.log('权限被拒绝');
  375. } else if (result === -1) {
  376. console.log('权限被永久拒绝');
  377. }
  378. })
  379. .catch(error => {
  380. that.showRights = true;
  381. console.log('权限申请失败:', error);
  382. });
  383. },
  384. onBirthdayChange(e) {
  385. this.birthday = e.detail.value;
  386. this.xinzuo_sel = this.getConstellation(this.birthday);
  387. },
  388. getConstellation(birthday) {
  389. if (!birthday) return '';
  390. const month = parseInt(birthday.split('-')[1]);
  391. const day = parseInt(birthday.split('-')[2]);
  392. // 星座日期数组
  393. const constellationDates = [
  394. [1, 20, "水瓶座"],
  395. [2, 19, "双鱼座"],
  396. [3, 21, "白羊座"],
  397. [4, 20, "金牛座"],
  398. [5, 21, "双子座"],
  399. [6, 22, "巨蟹座"],
  400. [7, 23, "狮子座"],
  401. [8, 23, "处女座"],
  402. [9, 23, "天秤座"],
  403. [10, 24, "天蝎座"],
  404. [11, 23, "射手座"],
  405. [12, 22, "摩羯座"]
  406. ];
  407. let constellation = "";
  408. if (day < constellationDates[month - 1][1]) {
  409. constellation = constellationDates[month - 1][2];
  410. } else {
  411. constellation = constellationDates[month % 12][2];
  412. }
  413. return constellation;
  414. }
  415. }
  416. }
  417. </script>
  418. <style scoped lang="scss">
  419. @import 'normal.scss';
  420. page {
  421. font-family: PingFang SC-Medium;
  422. }
  423. .popSel {
  424. position: fixed;
  425. z-index: 999999;
  426. top: 0;
  427. left: 0;
  428. background-color: #f2f6f2;
  429. width: 100vh;
  430. height: 100vh;
  431. .headLabel {
  432. width: 686rpx;
  433. margin: 28rpx 32rpx;
  434. min-height: 222rpx;
  435. background: #fff;
  436. box-sizing: border-box;
  437. padding: 30rpx 40rpx 46rpx 20rpx;
  438. border-radius: 20rpx;
  439. .avator-box {
  440. display: flex;
  441. align-items: center;
  442. .avator {
  443. width: 80rpx;
  444. height: 80rpx;
  445. margin-right: 20rpx;
  446. }
  447. }
  448. .tag-box {
  449. display: flex;
  450. flex-direction: row;
  451. justify-content: flex-start;
  452. align-items: center;
  453. flex-wrap: wrap;
  454. font-size: 24rpx;
  455. .tag {
  456. margin-right: 16rpx;
  457. margin-top: 20rpx;
  458. padding: 6rpx 10rpx;
  459. border: 2rpx solid #DCE1DC;
  460. color: #9E9E9E;
  461. display: flex;
  462. justify-content: center;
  463. align-items: center;
  464. border-radius: 42rpx;
  465. line-height: 1;
  466. .close {
  467. width: 20rpx;
  468. margin-left: 12rpx;
  469. position: relative;
  470. }
  471. }
  472. }
  473. }
  474. }
  475. .openNicknamePopUpWindow {
  476. .length-indicator {
  477. font-size: 24rpx;
  478. color: #999;
  479. text-align: right;
  480. margin-top: 10rpx;
  481. margin-right: 20rpx;
  482. position: absolute;
  483. right: 24rpx;
  484. top: 24rpx;
  485. }
  486. }
  487. .popSel {
  488. .item_tag {
  489. display: flex;
  490. flex-direction: row;
  491. justify-content: flex-start;
  492. align-items: center;
  493. flex-wrap: wrap;
  494. width: 690rpx;
  495. padding: 20rpx;
  496. .tag {
  497. border-radius: 94rpx;
  498. margin-right: 10rpx;
  499. margin-top: 10rpx;
  500. padding: 8rpx 16rpx;
  501. font-size: 28rpx;
  502. color: #333;
  503. display: flex;
  504. flex-direction: row;
  505. justify-content: center;
  506. align-items: center;
  507. background: #fff;
  508. border-width: 0;
  509. .close {
  510. width: 28rpx;
  511. margin-left: 2rpx;
  512. position: relative;
  513. }
  514. }
  515. .active {
  516. border-width: 0;
  517. background: #ACF934;
  518. }
  519. .addNew {
  520. margin-right: 10rpx;
  521. margin-top: 10rpx;
  522. padding: 0rpx 20rpx;
  523. height: 60rpx;
  524. border-radius: 12rpx;
  525. background: #1f1f1f;
  526. color: #fff;
  527. display: flex;
  528. flex-direction: row;
  529. justify-content: center;
  530. align-items: center;
  531. }
  532. }
  533. }
  534. </style>