editInfo.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <template>
  2. <view class="page">
  3. <view class="list_info">
  4. <view class="bcenter">
  5. <view class="avator" @click="upload">
  6. <image class="img" :src="avator" mode="aspectFill" />
  7. <image class="photo" src="../../static/me/photo.png" mode="widthFix" />
  8. </view>
  9. </view>
  10. <view class="section_title">基本信息</view>
  11. <view class="info_card">
  12. <view class="info_item">
  13. <text class="label">昵称</text>
  14. <view class="content">
  15. <input type="text" placeholder="请输入昵称" v-model="nickname" maxlength="30" />
  16. <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" />
  17. </view>
  18. </view>
  19. <view class="info_item">
  20. <text class="label">简介</text>
  21. <view class="content">
  22. <input type="text" placeholder="请输入简介" v-model="wechat" maxlength="32" />
  23. <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" />
  24. </view>
  25. </view>
  26. <view class="info_item" @click="SetSex">
  27. <text class="label">性别</text>
  28. <view class="content">
  29. <input type="text" placeholder="请选择" v-model="sexText" disabled="true" />
  30. <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" />
  31. </view>
  32. </view>
  33. <view class="info_item">
  34. <text class="label">生日</text>
  35. <view class="content">
  36. <input type="text" placeholder="请选择生日" v-model="ziye" maxlength="50" />
  37. <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" />
  38. </view>
  39. </view>
  40. <view class="info_item" @click="SetXinzuo">
  41. <text class="label">星座</text>
  42. <view class="content">
  43. <input type="text" placeholder="请选择" v-model="xinzuo_sel" disabled="true" />
  44. <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" />
  45. </view>
  46. </view>
  47. </view>
  48. <view class="section_title">个性标签</view>
  49. <view class="info_card">
  50. <view class="item_tag">
  51. <view class="tag" v-for="(item,index) in sel_tags">
  52. {{item}}
  53. <image class="close" src="../../static/me/close.png" mode="widthFix" @click="delTag(item)" />
  54. </view>
  55. <view class="addNew" @click="showPop = true;">添加+</view>
  56. </view>
  57. </view>
  58. <view class="blankHeight"></view>
  59. </view>
  60. <view class="btn_submit" @click="submitData">提交保存</view>
  61. <DialogBox ref="DialogBox"></DialogBox>
  62. <view class="popSel" v-if="showPop" @tap.stop="onPreview">
  63. <view class="list_info">
  64. <view class="name">你的兴趣爱好是?</view>
  65. <view class="desc">提示:最多选择10个兴趣爱好标签</view>
  66. <view class="item_tag">
  67. <view @tap.stop="chkTag(item)" class="tag" :class="selTags(item)?'active':''"
  68. v-for="(item,index) in list_tag">
  69. {{item}}
  70. </view>
  71. </view>
  72. </view>
  73. <view class="btn_submit" @click="showPop = false;">提交选择</view>
  74. </view>
  75. <ToastW3 ref="ToastW3"></ToastW3>
  76. <view v-if="showRights"
  77. 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;">
  78. <text
  79. style="width:90%;color:#000000;font-size:38rpx;text-align: left;padding:10rpx 20rpx;padding-top:10rpx;">正在获取相机、存储权限</text>
  80. <text
  81. style="width:90%;color:#666666;font-size:28rpx;text-align: left;padding:10rpx 20rpx;">该权限用于获取设备拍摄或获取本地应用相册,进行头像或图片上传。</text>
  82. </view>
  83. </view>
  84. </template>
  85. <script>
  86. import {
  87. requestAndroidPermission,
  88. gotoAppPermissionSetting
  89. } from '../index/permission.js'
  90. export default {
  91. components: {},
  92. data() {
  93. return {
  94. showRights: false,
  95. title: '',
  96. sel: 1,
  97. info: {},
  98. showPop: false,
  99. nickname: '',
  100. wechat: '',
  101. sex: 1,
  102. age: 18,
  103. height: 160,
  104. weight: 50,
  105. avator: '../../static/me/avator.png',
  106. ziye: '',
  107. qianmin: '',
  108. xueli_sel: '',
  109. xueli: ['初中', '初中', '中专', '高中', '专科', '本科', '研究生', '硕士', '博士'],
  110. xinzuo_sel: '',
  111. xinzuo: ['水瓶座', '双鱼座', '白羊座', '金牛座', '双子座', '巨蟹座', '狮子座', '处女座', '天秤座', '天蝎座', '射手座', '摩羯座'],
  112. list_tag: [
  113. '篮球', '排球', '足球', '羽毛球', '健身达人', '美食达人'
  114. ],
  115. sel_tags: [],
  116. sexText: '',
  117. sexOptions: ['男', '女', '其他']
  118. }
  119. },
  120. onLoad() {
  121. let tagStr =
  122. "篮球、羽毛球、兵乓球、足球、滑板、滑旱冰、跑步、跳绳、举重、听音乐、看电影、绘画、写小说、看书、做弹弓玩、做木剑玩、做橡皮枪玩、积木、用麻将搭金字塔、拼图、拆装、扑克牌、小汽车、手表、鞋之类的、弹吉他、钢琴、萨克斯、葫芦丝、大号、小号、折纸、剪纸、品茶、涂鸦、英雄联盟、qq堂、cs、cf、地下城勇士、桌面游戏";
  123. this.list_tag = tagStr.split("、");
  124. this.getInfoData();
  125. },
  126. onShow() {},
  127. methods: {
  128. onBack() {},
  129. onPreview() {},
  130. chkSel() {
  131. if (this.sel == 1) {
  132. this.sel = 0;
  133. } else {
  134. this.sel = 1;
  135. }
  136. },
  137. chkSex(sex) {
  138. this.sex = sex;
  139. },
  140. delTag(tg) {
  141. let list_tag2 = [];
  142. for (let i = 0; i < this.sel_tags.length; i++) {
  143. if (this.sel_tags[i] != tg) {
  144. list_tag2.push(this.sel_tags[i]);
  145. }
  146. }
  147. this.sel_tags = list_tag2;
  148. },
  149. selTags(itm) {
  150. let that = this;
  151. let isIn = false;
  152. for (let entry of this.sel_tags) {
  153. if (entry == itm) {
  154. isIn = true;
  155. break;
  156. }
  157. }
  158. return isIn;
  159. },
  160. chkTag(itm) {
  161. if (this.selTags(itm)) {
  162. let tmpTags = [];
  163. for (let entry of this.sel_tags) {
  164. if (entry != itm) {
  165. tmpTags.push(entry);
  166. }
  167. }
  168. this.sel_tags = tmpTags;
  169. } else {
  170. if (this.sel_tags.length <= 9) {
  171. this.sel_tags.push(itm);
  172. } else {
  173. this.$refs['ToastW3'].showToast({
  174. title: "最多选择10个标签",
  175. animation: 0
  176. });
  177. }
  178. }
  179. },
  180. sliderChange1(e) {
  181. this.age = e.detail.value;
  182. },
  183. sliderChange2(e) {
  184. this.height = e.detail.value;
  185. },
  186. sliderChange3(e) {
  187. this.weight = e.detail.value;
  188. },
  189. SetXueli() {
  190. let that = this;
  191. uni.showActionSheet({
  192. itemColor: '#000000',
  193. itemList: this.xueli,
  194. success: function(res) {
  195. that.xueli_sel = that.xueli[res.tapIndex];
  196. },
  197. fail: function(res) {
  198. console.log(res.errMsg);
  199. }
  200. });
  201. },
  202. SetXinzuo() {
  203. let that = this;
  204. uni.showActionSheet({
  205. itemColor: '#000000',
  206. itemList: this.xinzuo,
  207. success: function(res) {
  208. that.xinzuo_sel = that.xinzuo[res.tapIndex];
  209. },
  210. fail: function(res) {
  211. console.log(res.errMsg);
  212. }
  213. });
  214. },
  215. SetSex() {
  216. let that = this;
  217. uni.showActionSheet({
  218. itemColor: '#000000',
  219. itemList: this.sexOptions,
  220. success: function(res) {
  221. that.sexText = that.sexOptions[res.tapIndex];
  222. that.sex = res.tapIndex + 1;
  223. },
  224. fail: function(res) {
  225. console.log(res.errMsg);
  226. }
  227. });
  228. },
  229. getInfoData() {
  230. uni.request({
  231. url: this.$apiHost + '/Member/getinfoData',
  232. data: {
  233. uuid: getApp().globalData.uuid
  234. },
  235. header: {
  236. 'content-type': 'application/json'
  237. },
  238. success: (res) => {
  239. this.nickname = res.data.nickname;
  240. this.wechat = res.data.wechat;
  241. this.sex = res.data.sex;
  242. this.sexText = this.sexOptions[res.data.sex - 1] || '';
  243. this.age = res.data.age;
  244. this.height = res.data.height;
  245. this.weight = res.data.weight;
  246. this.xueli_sel = res.data.xueli;
  247. this.xinzuo_sel = res.data.xinzuo;
  248. this.ziye = res.data.ziye;
  249. this.qianmin = res.data.qianmin;
  250. if (res.data.avator != "") {
  251. this.avator = res.data.avator;
  252. }
  253. console.log(res.data.aihao);
  254. if (res.data.aihao) {
  255. this.sel_tags = res.data.aihao.split(",");
  256. }
  257. }
  258. });
  259. },
  260. submitData() {
  261. let aihao = this.sel_tags.join(',')
  262. let obj2 = {
  263. uuid: getApp().globalData.uuid,
  264. avator: this.avator,
  265. nickname: this.nickname,
  266. wechat: this.wechat,
  267. sex: this.sex,
  268. age: this.age,
  269. height: this.height,
  270. weight: this.weight,
  271. xueli: this.xueli_sel,
  272. xinzuo: this.xinzuo_sel,
  273. ziye: this.ziye,
  274. qianmin: this.qianmin,
  275. aihao: aihao
  276. }
  277. uni.request({
  278. url: this.$apiHost + '/Member/setinfoData',
  279. data: obj2,
  280. method: 'POST',
  281. header: {
  282. 'Content-Type': 'application/x-www-form-urlencoded',
  283. 'sign': getApp().globalData.headerSign
  284. },
  285. dataType: 'json',
  286. success: (res) => {
  287. console.log("res", res.data)
  288. this.$refs['ToastW3'].showToast({
  289. title: res.data.str,
  290. animation: 0
  291. });
  292. if (res.data.success == 'yes') {
  293. setTimeout(function() {
  294. uni.navigateBack()
  295. }, 800)
  296. }
  297. this.getInfoData()
  298. }
  299. });
  300. },
  301. upload() {
  302. this.checkRights();
  303. console.log("----upload");
  304. var _self = this;
  305. uni.chooseImage({
  306. count: 1,
  307. sizeType: ['compressed'],
  308. sourceType: ['album', 'camera'],
  309. success: function(res) {
  310. console.log('res:', res)
  311. if (res.tempFilePaths.length > 0) {
  312. _self.imglocal = res.tempFilePaths[0]
  313. const tempFilePaths = res.tempFilePaths[0];
  314. console.log('tempFilePaths:', tempFilePaths);
  315. const uploadTask = uni.uploadFile({
  316. url: _self.$apiHost + '/Xweb/upload_img?skey=' + _self.skey,
  317. filePath: res.tempFilePaths[0],
  318. name: 'file',
  319. success: function(uploadFileRes) {
  320. let resdata = JSON.parse(uploadFileRes.data)
  321. console.log('Success11:', uploadFileRes);
  322. console.log('Success21:', resdata);
  323. if (resdata.success == 'yes') {
  324. _self.avator = resdata.url;
  325. }
  326. },
  327. fail: function(uploadFileFail) {
  328. console.log('Error:', uploadFileFail.data);
  329. },
  330. complete: () => {
  331. console.log('Complete:');
  332. }
  333. });
  334. }
  335. },
  336. error: function(e) {
  337. console.log(e);
  338. }
  339. });
  340. },
  341. checkRights() {
  342. let that = this;
  343. that.showRights = true;
  344. requestAndroidPermission('android.permission.CAMERA')
  345. .then(result => {
  346. that.showRights = false;
  347. if (result === 1) {} else if (result === 0) {
  348. console.log('权限被拒绝');
  349. } else if (result === -1) {
  350. console.log('权限被永久拒绝');
  351. }
  352. })
  353. .catch(error => {
  354. that.showRights = true;
  355. console.log('权限申请失败:', error);
  356. });
  357. }
  358. }
  359. }
  360. </script>
  361. <style scoped lang="scss">
  362. @import 'normal.scss';
  363. .popSel {
  364. position: fixed;
  365. z-index: 999999;
  366. top: 0;
  367. left: 0;
  368. background-color: #ffffff;
  369. width: 100vh;
  370. height: 100vh;
  371. }
  372. </style>