step copy.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. <template>
  2. <view class="page">
  3. <view class="list_info">
  4. <block v-if="step == 1">
  5. <view class="name">请问你的性别是:</view>
  6. <view class="itemSex">
  7. <view class="sex2" :class="sex == 1 ? 'active' : ''" style="margin-right: 10rpx;" @click="chkSex(1)">
  8. <image class="photo" src="../../static/me/sex_1.png" mode="widthFix" />
  9. <text>男性</text>
  10. </view>
  11. <view class="sex2" :class="sex == 2 ? 'active' : ''" style="margin-left: 10rpx;" @click="chkSex(2)">
  12. <image class="photo" src="../../static/me/sex_2.png" mode="widthFix" />
  13. <text>女性</text>
  14. </view>
  15. </view>
  16. <view class="name">给自己取个名字吧:</view>
  17. <view class="item">
  18. <input type="text" class="input" placeholder="请输入昵称" v-model="nickname" maxlength="10" />
  19. </view>
  20. <view class="name">你的微信号是:</view>
  21. <view class="item">
  22. <input type="text" class="input" placeholder="请输入微信号" v-model="wechat" maxlength="32" />
  23. </view>
  24. <view class="name">选一张你的真实照片作为封面:</view>
  25. <view class="bcenter">
  26. <view class="avator" @click="upload">
  27. <image :src="avator" mode="aspectFill" class="img" />
  28. <image class="photo" src="../../static/me/photo.png" mode="widthFix" />
  29. </view>
  30. </view>
  31. </block>
  32. <block v-if="step == 2">
  33. <view class="name">给自己写一个个性签名:</view>
  34. <view class="item">
  35. <input type="text" class="input" placeholder="请输入个性签名" v-model="qianmin" maxlength="64" />
  36. </view>
  37. <view class="name">职业:</view>
  38. <view class="item">
  39. <input type="text" class="input" placeholder="请输入职业" v-model="ziye" maxlength="50" />
  40. </view>
  41. <view class="name">年龄:</view>
  42. <view class="itemSingle">
  43. <slider class="slider" :value="age" @change="sliderChange1" activeColor="#FF2A95"
  44. background-color="#282828" block-color="#FF2A95" block-size="12" min="10" max="100"
  45. show-value />
  46. </view>
  47. <view class="name">身高(CM):</view>
  48. <view class="itemSingle">
  49. <slider class="slider" :value="height" @change="sliderChange2" activeColor="#FF2A95"
  50. background-color="#282828" block-color="#FF2A95" block-size="12" min="150" max="220"
  51. show-value />
  52. </view>
  53. <view class="name">体重(KG):</view>
  54. <view class="itemSingle">
  55. <slider class="slider" :value="weight" @change="sliderChange3" activeColor="#FF2A95"
  56. background-color="#282828" block-color="#FF2A95" block-size="12" min="30" max="100"
  57. show-value />
  58. </view>
  59. </block>
  60. <block v-if="step == 3">
  61. <view class="name">学历:</view>
  62. <view class="item" @click="SetXueli">
  63. <input type="text" class="input" placeholder="请选择" v-model="xueli_sel" disabled="true" />
  64. <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" />
  65. </view>
  66. <view class="name">您的星座是:</view>
  67. <view class="item" @click="SetXinzuo">
  68. <input type="text" class="input" placeholder="请选择" v-model="xinzuo_sel" disabled="true" />
  69. <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" />
  70. </view>
  71. </block>
  72. <block v-if="step == 4">
  73. <view class="name">兴趣爱好:
  74. <view class="right" @click="showPop = true;">添加+</view>
  75. </view>
  76. <view class="item_tag">
  77. <view class="tag" v-for="(item, index) in sel_tags" :key="index">
  78. {{ item }}
  79. <image class="close" src="../../static/me/close.png" mode="widthFix" @click="delTag(item)" />
  80. </view>
  81. </view>
  82. </block>
  83. <view class="blankHeight"></view>
  84. </view>
  85. <view class="btn_submit" v-if="step == 1" @click="step++;">下一步</view>
  86. <view class="btn_list" v-if="step == 2 || step == 3">
  87. <view class="btn_submit1" @click="step--;">上一步</view>
  88. <view class="btn_submit2" @click="step++;">下一步</view>
  89. </view>
  90. <view class="btn_list" v-if="step == 4">
  91. <view class="btn_submit1" @click="step--;">上一步</view>
  92. <view class="btn_submit2" @click="submitData()">完成</view>
  93. </view>
  94. <view class="popSel" v-if="showPop" @tap.stop="onPreview">
  95. <view class="list_info">
  96. <view class="name">你的兴趣爱好是?</view>
  97. <view class="desc">提示:最多选择10个兴趣爱好标签</view>
  98. <view class="item_tag">
  99. <view @tap.stop="chkTag(item)" class="tag" :class="selTags(item) ? 'active' : ''"
  100. v-for="(item, index) in list_tag" :key="index">
  101. {{ item }}
  102. </view>
  103. </view>
  104. </view>
  105. <view class="btn_submit" @click="showPop = false;">提交选择</view>
  106. </view>
  107. <view class="tag_all_select">
  108. <view class="tag_items">
  109. <view v-for="(item, index) in tagList" :key="index" class="tag_item"
  110. :class="[item.size, { 'active': selectedTags.includes(index) }]" @click="selectTag(index)">
  111. {{ item.name }}
  112. </view>
  113. </view>
  114. </view>
  115. <view class="blankHeight"></view>
  116. <view class="blankHeight"></view>
  117. <view class="blankHeight"></view>
  118. <ToastW3 ref="ToastW3"></ToastW3>
  119. <DialogBox ref="DialogBox"></DialogBox>
  120. <view v-if="showRights"
  121. 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;">
  122. <text
  123. style="width:90%;color:#000000;font-size:38rpx;text-align: left;padding:10rpx 20rpx;padding-top:10rpx;">正在获取相机、存储权限</text>
  124. <text
  125. style="width:90%;color:#666666;font-size:28rpx;text-align: left;padding:10rpx 20rpx;">该权限用于获取设备拍摄或获取本地应用相册,进行头像或图片上传。</text>
  126. </view>
  127. </view>
  128. </template>
  129. <script>
  130. import {
  131. requestAndroidPermission,
  132. gotoAppPermissionSetting
  133. } from '../index/permission.js'
  134. export default {
  135. components: {},
  136. data() {
  137. return {
  138. showRights: false,
  139. title: '',
  140. step: 1,
  141. sel: 1,
  142. info: {},
  143. showPop: false,
  144. nickname: '',
  145. wechat: '',
  146. sex: 1,
  147. age: 18,
  148. height: 160,
  149. weight: 50,
  150. avator: '../../static/me/avator.png',
  151. ziye: '',
  152. qianmin: '',
  153. xueli_sel: '',
  154. xueli: ['初中', '初中', '中专', '高中', '专科', '本科', '研究生', '硕士', '博士'],
  155. xinzuo_sel: '',
  156. xinzuo: ['水瓶座', '双鱼座', '白羊座', '金牛座', '双子座', '巨蟹座', '狮子座', '处女座', '天秤座', '天蝎座', '射手座', '摩羯座'],
  157. list_tag: [
  158. '篮球', '排球', '足球', '羽毛球', '健身达人', '美食达人'
  159. ],
  160. sel_tags: [],
  161. selectedTags: [],
  162. tagList: [
  163. { name: '游戏', size: 'large' },
  164. { name: '音乐', size: 'medium' },
  165. { name: '盲盒', size: 'large' },
  166. { name: '小可爱', size: 'small' },
  167. { name: '娃娃人', size: 'medium' },
  168. { name: '纹身', size: 'large' },
  169. { name: '洛丽塔', size: 'small' },
  170. { name: '女装', size: 'medium' },
  171. { name: '萌球', size: 'small' }
  172. ]
  173. }
  174. },
  175. onLoad() {
  176. this.step = 1;
  177. let tagStr =
  178. "篮球、羽毛球、兵乓球、足球、滑板、滑旱冰、跑步、跳绳、举重、听音乐、看电影、绘画、写小说、看书、做弹弓玩、做木剑玩、做橡皮枪玩、积木、用麻将搭金字塔、拼图、拆装、扑克牌、小汽车、手表、鞋之类的、弹吉他、钢琴、萨克斯、葫芦丝、大号、小号、折纸、剪纸、品茶、涂鸦、英雄联盟、qq堂、cs、cf、地下城勇士、桌面游戏";
  179. this.list_tag = tagStr.split("、");
  180. this.getInfoData();
  181. },
  182. onShow() { },
  183. methods: {
  184. onBack() { },
  185. chkSel() {
  186. if (this.sel == 1) {
  187. this.sel = 0;
  188. } else {
  189. this.sel = 1;
  190. }
  191. },
  192. chkSex(sex) {
  193. this.sex = sex;
  194. },
  195. delTag(tg) {
  196. let list_tag2 = [];
  197. for (let i = 0; i < this.sel_tags.length; i++) {
  198. if (this.sel_tags[i] != tg && this.sel_tags[i] != '') {
  199. list_tag2.push(this.sel_tags[i]);
  200. }
  201. }
  202. this.sel_tags = list_tag2;
  203. },
  204. selTags(itm) {
  205. let that = this;
  206. let isIn = false;
  207. for (let entry of this.sel_tags) {
  208. // console.log(entry); // 1, "string", false
  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. // console.log(entry); // 1, "string", false
  221. if (entry != itm && entry != '') {
  222. tmpTags.push(entry);
  223. }
  224. }
  225. this.sel_tags = tmpTags;
  226. } else {
  227. if (this.sel_tags.length >= 10) {
  228. this.$refs['ToastW3'].showToast({
  229. title: "最多选择10个标签",
  230. animation: 0
  231. });
  232. return;
  233. }
  234. this.sel_tags.push(itm);
  235. }
  236. },
  237. sliderChange1(e) {
  238. this.age = e.detail.value;
  239. },
  240. sliderChange2(e) {
  241. this.height = e.detail.value;
  242. },
  243. sliderChange3(e) {
  244. this.weight = e.detail.value;
  245. },
  246. SetXueli() {
  247. let that = this;
  248. uni.showActionSheet({
  249. itemColor: '#000000',
  250. itemList: this.xueli,
  251. success: function (res) {
  252. that.xueli_sel = that.xueli[res.tapIndex];
  253. // console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
  254. },
  255. fail: function (res) {
  256. console.log(res.errMsg);
  257. }
  258. });
  259. },
  260. SetXinzuo() {
  261. let that = this;
  262. uni.showActionSheet({
  263. itemColor: '#000000',
  264. itemList: this.xinzuo,
  265. success: function (res) {
  266. that.xinzuo_sel = that.xinzuo[res.tapIndex];
  267. // console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
  268. },
  269. fail: function (res) {
  270. console.log(res.errMsg);
  271. }
  272. });
  273. },
  274. getInfoData() {
  275. console.log(this.$apiHost + '/Member/getinfoData');
  276. uni.request({
  277. url: this.$apiHost + '/Member/getinfoData', //仅为示例,并非真实接口地址。
  278. data: {
  279. uuid: getApp().globalData.uuid
  280. },
  281. header: {
  282. 'content-type': 'application/json' //自定义请求头信息
  283. },
  284. success: (res) => {
  285. console.log("res", res.data)
  286. this.nickname = res.data.nickname;
  287. this.wechat = res.data.wechat;
  288. this.sex = res.data.sex || 2;
  289. this.age = res.data.age || 18;
  290. this.height = res.data.height || 160;
  291. this.weight = res.data.weight || 50;
  292. this.xueli_sel = res.data.xueli;
  293. this.xinzuo_sel = res.data.xinzuo;
  294. this.ziye = res.data.ziye;
  295. this.qianmin = res.data.qianmin;
  296. if (res.data.avator != "") {
  297. this.avator = res.data.avator;
  298. }
  299. if (res.data.aihao != null && res.data.aihao != undefined) {
  300. if (res.data.aihao.length > 0) {
  301. this.sel_tags = res.data.aihao.split(",");
  302. }
  303. }
  304. }
  305. });
  306. },
  307. submitData() {
  308. let aihao = this.sel_tags.join(',')
  309. let obj2 = {
  310. uuid: getApp().globalData.uuid,
  311. avator: this.avator,
  312. nickname: this.nickname,
  313. wechat: this.wechat,
  314. sex: this.sex,
  315. age: this.age,
  316. height: this.height,
  317. weight: this.weight,
  318. xueli: this.xueli_sel,
  319. xinzuo: this.xinzuo_sel,
  320. ziye: this.ziye,
  321. qianmin: this.qianmin,
  322. aihao: aihao
  323. }
  324. // console.log("obj2", obj2);
  325. uni.request({
  326. url: this.$apiHost + '/Member/setinfoData', //仅为示例,并非真实接口地址。
  327. data: obj2,
  328. method: 'POST',
  329. header: {
  330. 'Content-Type': 'application/x-www-form-urlencoded',
  331. 'sign': getApp().globalData.headerSign
  332. },
  333. dataType: 'json',
  334. // header: {
  335. // 'content-type': 'application/json', //自定义请求头信息
  336. // 'Access-Control-Allow-Origin': '*'
  337. // },
  338. success: (res) => {
  339. console.log("res", res.data)
  340. this.$refs['ToastW3'].showToast({
  341. title: res.data.str,
  342. animation: 0
  343. });
  344. if (res.data.success == "yes") {
  345. uni.switchTab({
  346. url: "/pages/index/index",
  347. });
  348. }
  349. }
  350. });
  351. },
  352. // upload() {
  353. // let that = this;
  354. // this.$refs['DialogBox'].confirm({
  355. // title: '提示',
  356. // content: '该权限用于获取设备拍摄或获取本地应用相册,进行头像的图片上传。',
  357. // DialogType: 'inquiry',
  358. // btn1: '拒绝',
  359. // btn2: '同意',
  360. // animation: 0
  361. // }).then((res) => {
  362. // that.upload2();
  363. // })
  364. // },
  365. upload() {
  366. this.checkRights();
  367. console.log("----upload");
  368. var _self = this;
  369. uni.chooseImage({
  370. count: 1,
  371. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  372. sourceType: ['album', 'camera'], //从相册、相机选择
  373. extension: ['.png', '.jpeg', '.jpg'],
  374. success: function (res) {
  375. console.log('res:', res)
  376. _self.imglocal = res.tempFilePaths[0]
  377. const tempFilePaths = res.tempFilePaths[0];
  378. console.log('tempFilePaths:', tempFilePaths);
  379. // 图片上传
  380. const uploadTask = uni.uploadFile({
  381. url: _self.$apiHost + '/Xweb/upload_img?skey=' + _self.skey, // post请求地址
  382. filePath: res.tempFilePaths[0],
  383. name: 'file', // 待确认
  384. success: function (uploadFileRes) {
  385. let resdata = JSON.parse(uploadFileRes.data)
  386. console.log('Success11:', uploadFileRes);
  387. console.log('Success21:', resdata);
  388. if (resdata.success == 'yes') {
  389. _self.avator = resdata.url;
  390. }
  391. },
  392. fail: function (uploadFileFail) {
  393. console.log('Error:', uploadFileFail.data);
  394. },
  395. complete: () => {
  396. console.log('Complete:');
  397. }
  398. });
  399. },
  400. error: function (e) {
  401. console.log(e);
  402. }
  403. });
  404. },
  405. checkRights() {
  406. let that = this;
  407. that.showRights = true;
  408. requestAndroidPermission('android.permission.CAMERA')
  409. .then(result => {
  410. that.showRights = false;
  411. // 根据返回的结果进行处理
  412. if (result === 1) { } else if (result === 0) {
  413. console.log('权限被拒绝');
  414. } else if (result === -1) {
  415. console.log('权限被永久拒绝');
  416. }
  417. })
  418. .catch(error => {
  419. that.showRights = true;
  420. console.log('权限申请失败:', error);
  421. });
  422. },
  423. selectTag(index) {
  424. const tagIndex = this.selectedTags.indexOf(index);
  425. if (tagIndex === -1) {
  426. // 如果未选中,则添加到选中数组
  427. this.selectedTags.push(index);
  428. } else {
  429. // 如果已选中,则从数组中移除
  430. this.selectedTags.splice(tagIndex, 1);
  431. }
  432. }
  433. }
  434. }
  435. </script>
  436. <style scoped lang="scss">
  437. @import 'normal.scss';
  438. .popSel {
  439. position: fixed;
  440. z-index: 999999;
  441. top: 0;
  442. left: 0;
  443. background-color: #121212;
  444. width: 100vh;
  445. height: 100vh;
  446. }
  447. .tag_all_select {
  448. padding: 20rpx;
  449. .tag_items {
  450. display: flex;
  451. flex-wrap: wrap;
  452. gap: 30rpx;
  453. justify-content: center;
  454. align-items: center;
  455. .tag_item {
  456. display: flex;
  457. align-items: center;
  458. justify-content: center;
  459. border-radius: 50%;
  460. background: rgba(255, 255, 255, 0.1);
  461. color: #fff;
  462. font-size: 26rpx;
  463. transition: all 0.3s ease;
  464. cursor: pointer;
  465. &.small {
  466. width: 120rpx;
  467. height: 120rpx;
  468. }
  469. &.medium {
  470. width: 160rpx;
  471. height: 160rpx;
  472. font-size: 28rpx;
  473. }
  474. &.large {
  475. width: 200rpx;
  476. height: 200rpx;
  477. font-size: 32rpx;
  478. }
  479. &.active {
  480. transform: scale(1.2);
  481. background: rgba(255, 255, 255, 0.2);
  482. box-shadow: 0 0 20rpx rgba(255, 255, 255, 0.3);
  483. z-index: 1;
  484. }
  485. &:not(.active):hover {
  486. transform: scale(1.05);
  487. }
  488. }
  489. }
  490. }
  491. </style>