editInfo.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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. <view class="list_info">
  77. <view class="name">你的兴趣爱好是?</view>
  78. <view class="desc">提示:最多选择10个兴趣爱好标签</view>
  79. <view class="item_tag">
  80. <view @tap.stop="chkTag(item)" class="tag" :class="selTags(item) ? 'active' : ''"
  81. v-for="(item, index) in list_tag" :key="index">
  82. {{ item }}
  83. </view>
  84. </view>
  85. </view>
  86. <view class="btn_submit" @click="showPop = false;">提交选择</view>
  87. </view>
  88. <ToastW3 ref="ToastW3"></ToastW3>
  89. <view v-if="showRights"
  90. 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;">
  91. <text
  92. style="width:90%;color:#000000;font-size:38rpx;text-align: left;padding:10rpx 20rpx;padding-top:10rpx;">正在获取相机、存储权限</text>
  93. <text
  94. style="width:90%;color:#666666;font-size:28rpx;text-align: left;padding:10rpx 20rpx;">该权限用于获取设备拍摄或获取本地应用相册,进行头像或图片上传。</text>
  95. </view>
  96. <view>
  97. <NicknamePopup title="编辑昵称" subtitle="" class="openNicknamePopUpWindow" ref="openNicknamePopUpWindow">
  98. <template slot="content">
  99. <view class="input-box">
  100. <uv-input placeholder="请输入昵称" border="surround" v-model="nickname" maxlength="20"></uv-input>
  101. <view class="length-indicator">{{ nickname.length }}/20</view>
  102. </view>
  103. <view class="btn-box" @click="submitData">保存</view>
  104. </template>
  105. </NicknamePopup>
  106. <NicknamePopup title="专属于你的简介" subtitle="好的简介让你在社区更受关注" class="openContentPopUpWindow"
  107. ref="openContentPopUpWindow">
  108. <template slot="content">
  109. <uv-textarea v-model="content" maxlength="50" count placeholder="请输入内容"></uv-textarea>
  110. <view class="btn-box" @click="submitData">保存</view>
  111. </template>
  112. </NicknamePopup>
  113. </view>
  114. </view>
  115. </template>
  116. <script>
  117. import {
  118. requestAndroidPermission,
  119. gotoAppPermissionSetting
  120. } from '../index/permission.js'
  121. import PageHeader from '@/components/PageHeader/PageHeader.vue';
  122. import CircleAvatar from '@/components/CircleAvatar/CircleAvatar.vue';
  123. import NicknamePopup from '@/components/NicknamePopup/NicknamePopup.vue';
  124. export default {
  125. components: { PageHeader, CircleAvatar, NicknamePopup },
  126. data() {
  127. return {
  128. showRights: false,
  129. title: '',
  130. sel: 1,
  131. info: {},
  132. showPop: false,
  133. nickname: '',
  134. content: '',
  135. sex: 1,
  136. age: 18,
  137. height: 160,
  138. weight: 50,
  139. avator: '../../static/me/avator.png',
  140. ziye: '',
  141. qianmin: '',
  142. xinzuo_sel: '',
  143. xinzuo: ['水瓶座', '双鱼座', '白羊座', '金牛座', '双子座', '巨蟹座', '狮子座', '处女座', '天秤座', '天蝎座', '射手座', '摩羯座'],
  144. list_tag: [],
  145. sel_tags: [],
  146. sexText: '',
  147. birthday: '',
  148. sexOptions: ['男', '女', '其他'],
  149. endDate: new Date().toISOString().split('T')[0]
  150. }
  151. },
  152. onLoad() {
  153. let tagStr =
  154. "🎮 游戏、🎁 盲盒、😊 小可爱、😊 小可爱、🐱 喵星人、💪 纹身、跑步、跳绳、举重、听音乐、看电影、绘画、写小说、看书、做弹弓玩、做木剑玩、做橡皮枪玩、积木、用麻将搭金字塔、拼图、拆装、扑克牌、小汽车、手表、鞋之类的、弹吉他、钢琴、萨克斯、葫芦丝、大号、小号、折纸、剪纸、品茶、涂鸦、英雄联盟、qq堂、cs、cf、地下城勇士、桌面游戏";
  155. this.list_tag = tagStr.split("、");
  156. this.getInfoData();
  157. },
  158. onShow() { },
  159. methods: {
  160. openNicknamePopUpWindow() {
  161. this.$refs.openNicknamePopUpWindow.open();
  162. },
  163. openContentPopUpWindow() {
  164. this.$refs.openContentPopUpWindow.open();
  165. },
  166. closePropUp() {
  167. this.$refs.openNicknamePopUpWindow.close();
  168. this.$refs.openContentPopUpWindow.close();
  169. },
  170. onBack() { },
  171. onPreview() { },
  172. chkSel() {
  173. if (this.sel == 1) {
  174. this.sel = 0;
  175. } else {
  176. this.sel = 1;
  177. }
  178. },
  179. chkSex(sex) {
  180. this.sex = sex;
  181. },
  182. delTag(tg) {
  183. let list_tag2 = [];
  184. for (let i = 0; i < this.sel_tags.length; i++) {
  185. if (this.sel_tags[i] != tg) {
  186. list_tag2.push(this.sel_tags[i]);
  187. }
  188. }
  189. this.sel_tags = list_tag2;
  190. },
  191. selTags(itm) {
  192. let that = this;
  193. let isIn = false;
  194. for (let entry of this.sel_tags) {
  195. if (entry == itm) {
  196. isIn = true;
  197. break;
  198. }
  199. }
  200. return isIn;
  201. },
  202. chkTag(itm) {
  203. if (this.selTags(itm)) {
  204. let tmpTags = [];
  205. for (let entry of this.sel_tags) {
  206. if (entry != itm) {
  207. tmpTags.push(entry);
  208. }
  209. }
  210. this.sel_tags = tmpTags;
  211. } else {
  212. if (this.sel_tags.length <= 9) {
  213. this.sel_tags.push(itm);
  214. } else {
  215. this.$refs['ToastW3'].showToast({
  216. title: "最多选择10个标签",
  217. animation: 0
  218. });
  219. }
  220. }
  221. },
  222. sliderChange1(e) {
  223. this.age = e.detail.value;
  224. },
  225. sliderChange2(e) {
  226. this.height = e.detail.value;
  227. },
  228. sliderChange3(e) {
  229. this.weight = e.detail.value;
  230. },
  231. SetSex() {
  232. let that = this;
  233. uni.showActionSheet({
  234. itemColor: '#000000',
  235. itemList: this.sexOptions,
  236. success: function (res) {
  237. that.sexText = that.sexOptions[res.tapIndex];
  238. that.sex = res.tapIndex + 1;
  239. },
  240. fail: function (res) {
  241. console.log(res.errMsg);
  242. }
  243. });
  244. },
  245. getInfoData() {
  246. uni.request({
  247. url: this.$apiHost + '/Member/getinfoData',
  248. data: {
  249. uuid: getApp().globalData.uuid
  250. },
  251. header: {
  252. 'content-type': 'application/json'
  253. },
  254. success: (res) => {
  255. console.log(res.data);
  256. this.nickname = res.data.nickname;
  257. this.wechat = res.data.wechat;
  258. this.sex = res.data.sex;
  259. this.sexText = this.sexOptions[res.data.sex - 1] || '';
  260. this.birthday = res.data.birthday;
  261. this.xinzuo_sel = this.getConstellation(this.birthday);
  262. if (res.data.avator != "") {
  263. this.avator = res.data.avator;
  264. }
  265. if (res.data.aihao) {
  266. this.sel_tags = res.data.aihao.split(",");
  267. }
  268. }
  269. });
  270. },
  271. submitData(isBack) {
  272. let aihao = this.sel_tags.join(',')
  273. let obj2 = {
  274. uuid: getApp().globalData.uuid,
  275. avator: this.avator,
  276. nickname: this.nickname,
  277. content: this.content,
  278. sex: this.sex,
  279. birthday: this.birthday,
  280. xinzuo: this.xinzuo_sel,
  281. ziye: this.ziye,
  282. qianmin: this.qianmin,
  283. aihao: aihao
  284. }
  285. uni.request({
  286. url: this.$apiHost + '/Member/setinfoData',
  287. data: obj2,
  288. method: 'POST',
  289. header: {
  290. 'Content-Type': 'application/x-www-form-urlencoded',
  291. 'sign': getApp().globalData.headerSign
  292. },
  293. dataType: 'json',
  294. success: (res) => {
  295. console.log("res", res.data)
  296. this.$refs['ToastW3'].showToast({
  297. title: res.data.str,
  298. animation: 0
  299. });
  300. if (res.data.success == 'yes' && isBack == true) {
  301. setTimeout(function () {
  302. console.log('返回');
  303. uni.navigateBack()
  304. }, 800)
  305. } else {
  306. this.closePropUp()
  307. }
  308. this.getInfoData()
  309. }
  310. });
  311. },
  312. upload() {
  313. this.checkRights();
  314. console.log("----upload");
  315. var _self = this;
  316. uni.chooseImage({
  317. count: 1,
  318. sizeType: ['compressed'],
  319. sourceType: ['album', 'camera'],
  320. success: function (res) {
  321. console.log('res:', res)
  322. if (res.tempFilePaths.length > 0) {
  323. _self.imglocal = res.tempFilePaths[0]
  324. const tempFilePaths = res.tempFilePaths[0];
  325. console.log('tempFilePaths:', tempFilePaths);
  326. const uploadTask = uni.uploadFile({
  327. url: _self.$apiHost + '/Xweb/upload_img?skey=' + _self.skey,
  328. filePath: res.tempFilePaths[0],
  329. name: 'file',
  330. success: function (uploadFileRes) {
  331. let resdata = JSON.parse(uploadFileRes.data)
  332. console.log('Success11:', uploadFileRes);
  333. console.log('Success21:', resdata);
  334. if (resdata.success == 'yes') {
  335. _self.showRights = false;
  336. _self.avator = resdata.url;
  337. }
  338. },
  339. fail: function (uploadFileFail) {
  340. console.log('Error:', uploadFileFail.data);
  341. },
  342. complete: () => {
  343. console.log('Complete:');
  344. }
  345. });
  346. }
  347. },
  348. error: function (e) {
  349. console.log(e);
  350. }
  351. });
  352. },
  353. checkRights() {
  354. let that = this;
  355. that.showRights = true;
  356. requestAndroidPermission('android.permission.CAMERA')
  357. .then(result => {
  358. that.showRights = false;
  359. if (result === 1) { } else if (result === 0) {
  360. console.log('权限被拒绝');
  361. } else if (result === -1) {
  362. console.log('权限被永久拒绝');
  363. }
  364. })
  365. .catch(error => {
  366. that.showRights = true;
  367. console.log('权限申请失败:', error);
  368. });
  369. },
  370. onBirthdayChange(e) {
  371. this.birthday = e.detail.value;
  372. this.xinzuo_sel = this.getConstellation(this.birthday);
  373. },
  374. getConstellation(birthday) {
  375. if (!birthday) return '';
  376. const month = parseInt(birthday.split('-')[1]);
  377. const day = parseInt(birthday.split('-')[2]);
  378. // 星座日期数组
  379. const constellationDates = [
  380. [1, 20, "水瓶座"],
  381. [2, 19, "双鱼座"],
  382. [3, 21, "白羊座"],
  383. [4, 20, "金牛座"],
  384. [5, 21, "双子座"],
  385. [6, 22, "巨蟹座"],
  386. [7, 23, "狮子座"],
  387. [8, 23, "处女座"],
  388. [9, 23, "天秤座"],
  389. [10, 24, "天蝎座"],
  390. [11, 23, "射手座"],
  391. [12, 22, "摩羯座"]
  392. ];
  393. let constellation = "";
  394. if (day < constellationDates[month - 1][1]) {
  395. constellation = constellationDates[month - 1][2];
  396. } else {
  397. constellation = constellationDates[month % 12][2];
  398. }
  399. return constellation;
  400. }
  401. }
  402. }
  403. </script>
  404. <style scoped lang="scss">
  405. @import 'normal.scss';
  406. .popSel {
  407. position: fixed;
  408. z-index: 999999;
  409. top: 0;
  410. left: 0;
  411. background-color: #ffffff;
  412. width: 100vh;
  413. height: 100vh;
  414. }
  415. .openNicknamePopUpWindow {
  416. .length-indicator {
  417. font-size: 24rpx;
  418. color: #999;
  419. text-align: right;
  420. margin-top: 10rpx;
  421. margin-right: 20rpx;
  422. position: absolute;
  423. right: 24rpx;
  424. top: 24rpx;
  425. }
  426. }
  427. .item_tag {
  428. display: flex;
  429. flex-direction: row;
  430. justify-content: flex-start;
  431. align-items: center;
  432. flex-wrap: wrap;
  433. width: 690rpx;
  434. padding: 20rpx;
  435. .tag {
  436. border-radius: 12rpx;
  437. margin-right: 10rpx;
  438. margin-top: 10rpx;
  439. padding: 8rpx 16rpx;
  440. height: 60rpx;
  441. border: 2rpx solid #eee;
  442. color: #333;
  443. display: flex;
  444. flex-direction: row;
  445. justify-content: center;
  446. align-items: center;
  447. background: #eeeeee;
  448. .close {
  449. width: 28rpx;
  450. margin-left: 2rpx;
  451. position: relative;
  452. }
  453. }
  454. .active {
  455. border-radius: 20rpx;
  456. border: 2rpx solid #ff5967;
  457. }
  458. .addNew {
  459. margin-right: 10rpx;
  460. margin-top: 10rpx;
  461. padding: 0rpx 20rpx;
  462. height: 60rpx;
  463. border-radius: 12rpx;
  464. background: #1f1f1f;
  465. color: #fff;
  466. display: flex;
  467. flex-direction: row;
  468. justify-content: center;
  469. align-items: center;
  470. }
  471. }
  472. </style>