step copy.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  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" style="
  121. width: 100%;
  122. height: 300rpx;
  123. background-color: rgba(255, 255, 255, 0.9);
  124. position: fixed;
  125. top: 0;
  126. display: flex;
  127. flex-direction: column;
  128. justify-content: center;
  129. align-items: center;
  130. ">
  131. <text style="
  132. width: 90%;
  133. color: #000000;
  134. font-size: 38rpx;
  135. text-align: left;
  136. padding: 10rpx 20rpx;
  137. padding-top: 10rpx;
  138. ">正在获取相机、存储权限</text>
  139. <text style="
  140. width: 90%;
  141. color: #666666;
  142. font-size: 28rpx;
  143. text-align: left;
  144. padding: 10rpx 20rpx;
  145. ">该权限用于获取设备拍摄或获取本地应用相册,进行头像或图片上传。</text>
  146. </view>
  147. </view>
  148. </template>
  149. <script>
  150. import {
  151. requestAndroidPermission,
  152. gotoAppPermissionSetting,
  153. } from "../index/permission.js";
  154. export default {
  155. components: {},
  156. data() {
  157. return {
  158. showRights: false,
  159. title: "",
  160. step: 1,
  161. sel: 1,
  162. info: {},
  163. showPop: false,
  164. nickname: "",
  165. wechat: "",
  166. sex: 1,
  167. age: 18,
  168. height: 160,
  169. weight: 50,
  170. avator: "../../static/me/avator.png",
  171. ziye: "",
  172. qianmin: "",
  173. xueli_sel: "",
  174. xueli: [
  175. "初中",
  176. "初中",
  177. "中专",
  178. "高中",
  179. "专科",
  180. "本科",
  181. "研究生",
  182. "硕士",
  183. "博士",
  184. ],
  185. xinzuo_sel: "",
  186. xinzuo: [
  187. "水瓶座",
  188. "双鱼座",
  189. "白羊座",
  190. "金牛座",
  191. "双子座",
  192. "巨蟹座",
  193. "狮子座",
  194. "处女座",
  195. "天秤座",
  196. "天蝎座",
  197. "射手座",
  198. "摩羯座",
  199. ],
  200. list_tag: ["篮球", "排球", "足球", "羽毛球", "健身达人", "美食达人"],
  201. sel_tags: [],
  202. selectedTags: [],
  203. tagList: [
  204. { name: "游戏", size: "large" },
  205. { name: "音乐", size: "medium" },
  206. { name: "盲盒", size: "large" },
  207. { name: "小可爱", size: "small" },
  208. { name: "娃娃人", size: "medium" },
  209. { name: "纹身", size: "large" },
  210. { name: "洛丽塔", size: "small" },
  211. { name: "女装", size: "medium" },
  212. { name: "萌球", size: "small" },
  213. ],
  214. };
  215. },
  216. onLoad() {
  217. this.step = 1;
  218. let tagStr =
  219. "篮球、羽毛球、兵乓球、足球、滑板、滑旱冰、跑步、跳绳、举重、听音乐、看电影、绘画、写小说、看书、做弹弓玩、做木剑玩、做橡皮枪玩、积木、用麻将搭金字塔、拼图、拆装、扑克牌、小汽车、手表、鞋之类的、弹吉他、钢琴、萨克斯、葫芦丝、大号、小号、折纸、剪纸、品茶、涂鸦、英雄联盟、qq堂、cs、cf、地下城勇士、桌面游戏";
  220. this.list_tag = tagStr.split("、");
  221. this.getInfoData();
  222. },
  223. onShow() { },
  224. methods: {
  225. onBack() { },
  226. chkSel() {
  227. if (this.sel == 1) {
  228. this.sel = 0;
  229. } else {
  230. this.sel = 1;
  231. }
  232. },
  233. chkSex(sex) {
  234. this.sex = sex;
  235. },
  236. delTag(tg) {
  237. let list_tag2 = [];
  238. for (let i = 0; i < this.sel_tags.length; i++) {
  239. if (this.sel_tags[i] != tg && this.sel_tags[i] != "") {
  240. list_tag2.push(this.sel_tags[i]);
  241. }
  242. }
  243. this.sel_tags = list_tag2;
  244. },
  245. selTags(itm) {
  246. let that = this;
  247. let isIn = false;
  248. for (let entry of this.sel_tags) {
  249. // console.log(entry); // 1, "string", false
  250. if (entry == itm) {
  251. isIn = true;
  252. break;
  253. }
  254. }
  255. return isIn;
  256. },
  257. chkTag(itm) {
  258. if (this.selTags(itm)) {
  259. let tmpTags = [];
  260. for (let entry of this.sel_tags) {
  261. // console.log(entry); // 1, "string", false
  262. if (entry != itm && entry != "") {
  263. tmpTags.push(entry);
  264. }
  265. }
  266. this.sel_tags = tmpTags;
  267. } else {
  268. if (this.sel_tags.length >= 10) {
  269. this.$refs["ToastW3"].showToast({
  270. title: "最多选择10个标签",
  271. animation: 0,
  272. });
  273. return;
  274. }
  275. this.sel_tags.push(itm);
  276. }
  277. },
  278. sliderChange1(e) {
  279. this.age = e.detail.value;
  280. },
  281. sliderChange2(e) {
  282. this.height = e.detail.value;
  283. },
  284. sliderChange3(e) {
  285. this.weight = e.detail.value;
  286. },
  287. SetXueli() {
  288. let that = this;
  289. uni.showActionSheet({
  290. itemColor: "#000000",
  291. itemList: this.xueli,
  292. success: function (res) {
  293. that.xueli_sel = that.xueli[res.tapIndex];
  294. // console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
  295. },
  296. fail: function (res) {
  297. console.log(res.errMsg);
  298. },
  299. });
  300. },
  301. SetXinzuo() {
  302. let that = this;
  303. uni.showActionSheet({
  304. itemColor: "#000000",
  305. itemList: this.xinzuo,
  306. success: function (res) {
  307. that.xinzuo_sel = that.xinzuo[res.tapIndex];
  308. // console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
  309. },
  310. fail: function (res) {
  311. console.log(res.errMsg);
  312. },
  313. });
  314. },
  315. getInfoData() {
  316. console.log(this.$apiHost + "/Member/getinfoData");
  317. uni.request({
  318. url: this.$apiHost + "/Member/getinfoData", //仅为示例,并非真实接口地址。
  319. data: {
  320. uuid: getApp().globalData.uuid,
  321. },
  322. header: {
  323. "content-type": "application/json", //自定义请求头信息
  324. },
  325. success: (res) => {
  326. console.log("res", res.data);
  327. this.nickname = res.data.nickname;
  328. this.wechat = res.data.wechat;
  329. this.sex = res.data.sex || 2;
  330. this.age = res.data.age || 18;
  331. this.height = res.data.height || 160;
  332. this.weight = res.data.weight || 50;
  333. this.xueli_sel = res.data.xueli;
  334. this.xinzuo_sel = res.data.xinzuo;
  335. this.ziye = res.data.ziye;
  336. this.qianmin = res.data.qianmin;
  337. if (res.data.avator != "") {
  338. this.avator = res.data.avator;
  339. }
  340. if (res.data.aihao != null && res.data.aihao != undefined) {
  341. if (res.data.aihao.length > 0) {
  342. this.sel_tags = res.data.aihao.split(",");
  343. }
  344. }
  345. },
  346. });
  347. },
  348. submitData() {
  349. let aihao = this.sel_tags.join(",");
  350. let obj2 = {
  351. uuid: getApp().globalData.uuid,
  352. avator: this.avator,
  353. nickname: this.nickname,
  354. wechat: this.wechat,
  355. sex: this.sex,
  356. age: this.age,
  357. height: this.height,
  358. weight: this.weight,
  359. xueli: this.xueli_sel,
  360. xinzuo: this.xinzuo_sel,
  361. ziye: this.ziye,
  362. qianmin: this.qianmin,
  363. aihao: aihao,
  364. };
  365. // console.log("obj2", obj2);
  366. uni.request({
  367. url: this.$apiHost + "/Member/setinfoData", //仅为示例,并非真实接口地址。
  368. data: obj2,
  369. method: "POST",
  370. header: {
  371. "Content-Type": "application/x-www-form-urlencoded",
  372. sign: getApp().globalData.headerSign,
  373. },
  374. dataType: "json",
  375. // header: {
  376. // 'content-type': 'application/json', //自定义请求头信息
  377. // 'Access-Control-Allow-Origin': '*'
  378. // },
  379. success: (res) => {
  380. console.log("res", res.data);
  381. this.$refs["ToastW3"].showToast({
  382. title: res.data.str,
  383. animation: 0,
  384. });
  385. if (res.data.success == "yes") {
  386. uni.switchTab({
  387. url: "/pages/index/index",
  388. });
  389. }
  390. },
  391. });
  392. },
  393. // upload() {
  394. // let that = this;
  395. // this.$refs['DialogBox'].confirm({
  396. // title: '提示',
  397. // content: '该权限用于获取设备拍摄或获取本地应用相册,进行头像的图片上传。',
  398. // DialogType: 'inquiry',
  399. // btn1: '拒绝',
  400. // btn2: '同意',
  401. // animation: 0
  402. // }).then((res) => {
  403. // that.upload2();
  404. // })
  405. // },
  406. upload() {
  407. this.checkRights();
  408. console.log("----upload");
  409. var _self = this;
  410. uni.chooseImage({
  411. count: 1,
  412. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  413. sourceType: ["album", "camera"], //从相册、相机选择
  414. extension: [".png", ".jpeg", ".jpg"],
  415. success: function (res) {
  416. console.log("res:", res);
  417. _self.imglocal = res.tempFilePaths[0];
  418. const tempFilePaths = res.tempFilePaths[0];
  419. console.log("tempFilePaths:", tempFilePaths);
  420. // 图片上传
  421. const uploadTask = uni.uploadFile({
  422. url: _self.$apiHost + "/Xweb/upload_img?skey=" + _self.skey, // post请求地址
  423. filePath: res.tempFilePaths[0],
  424. name: "file", // 待确认
  425. success: function (uploadFileRes) {
  426. let resdata = JSON.parse(uploadFileRes.data);
  427. console.log("Success11:", uploadFileRes);
  428. console.log("Success21:", resdata);
  429. if (resdata.success == "yes") {
  430. _self.avator = resdata.url;
  431. }
  432. },
  433. fail: function (uploadFileFail) {
  434. console.log("Error:", uploadFileFail.data);
  435. },
  436. complete: () => {
  437. console.log("Complete:");
  438. },
  439. });
  440. },
  441. error: function (e) {
  442. console.log(e);
  443. },
  444. });
  445. },
  446. checkRights() {
  447. let that = this;
  448. that.showRights = true;
  449. requestAndroidPermission("android.permission.CAMERA")
  450. .then((result) => {
  451. that.showRights = false;
  452. // 根据返回的结果进行处理
  453. if (result === 1) {
  454. } else if (result === 0) {
  455. console.log("权限被拒绝");
  456. } else if (result === -1) {
  457. console.log("权限被永久拒绝");
  458. }
  459. })
  460. .catch((error) => {
  461. that.showRights = true;
  462. console.log("权限申请失败:", error);
  463. });
  464. },
  465. selectTag(index) {
  466. const tagIndex = this.selectedTags.indexOf(index);
  467. if (tagIndex === -1) {
  468. // 如果未选中,则添加到选中数组
  469. this.selectedTags.push(index);
  470. } else {
  471. // 如果已选中,则从数组中移除
  472. this.selectedTags.splice(tagIndex, 1);
  473. }
  474. },
  475. },
  476. };
  477. </script>
  478. <style scoped lang="scss">
  479. @import "normal.scss";
  480. .popSel {
  481. position: fixed;
  482. z-index: 999999;
  483. top: 0;
  484. left: 0;
  485. background-color: #121212;
  486. width: 100vh;
  487. height: 100vh;
  488. }
  489. .tag_all_select {
  490. padding: 20rpx;
  491. .tag_items {
  492. display: flex;
  493. flex-wrap: wrap;
  494. gap: 30rpx;
  495. justify-content: center;
  496. align-items: center;
  497. .tag_item {
  498. display: flex;
  499. align-items: center;
  500. justify-content: center;
  501. border-radius: 50%;
  502. background: rgba(255, 255, 255, 0.1);
  503. color: #fff;
  504. font-size: 26rpx;
  505. transition: all 0.3s ease;
  506. cursor: pointer;
  507. &.small {
  508. width: 120rpx;
  509. height: 120rpx;
  510. }
  511. &.medium {
  512. width: 160rpx;
  513. height: 160rpx;
  514. font-size: 28rpx;
  515. }
  516. &.large {
  517. width: 200rpx;
  518. height: 200rpx;
  519. font-size: 32rpx;
  520. }
  521. &.active {
  522. transform: scale(1.2);
  523. background: rgba(255, 255, 255, 0.2);
  524. box-shadow: 0 0 20rpx rgba(255, 255, 255, 0.3);
  525. z-index: 1;
  526. }
  527. &:not(.active):hover {
  528. transform: scale(1.05);
  529. }
  530. }
  531. }
  532. }
  533. </style>