editInfo.vue 10 KB

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