step.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542
  1. <template>
  2. <view class="step-container">
  3. <view class="reserveASeat"></view>
  4. <!-- 步骤指示器 -->
  5. <view class="step-header">
  6. <text class="step-number">STEP {{ currentStep }}</text>
  7. <view class="progress-container">
  8. <view class="progress-bar">
  9. <view
  10. class="progress-inner"
  11. :style="{ width: currentStep === 1 ? '50%' : '100%' }"
  12. ></view>
  13. </view>
  14. </view>
  15. </view>
  16. <!-- 步骤1:个人信息 -->
  17. <view v-if="currentStep === 1" class="step-content">
  18. <view class="step-title">这里是 <text>·灵魂汇聚·</text> 的起点</view>
  19. <!-- 头像上传 -->
  20. <view class="avatar-section">
  21. <view class="avatar-wrapper" @click="chooseAvatar">
  22. <CircleAvatar
  23. v-if="userInfo.avatar"
  24. class="avator"
  25. :src="userInfo.avatar"
  26. ></CircleAvatar>
  27. <view class="avatar-placeholder">
  28. <image
  29. src="/static/me/photo.png"
  30. mode="aspectFit"
  31. class="camera-icon"
  32. ></image>
  33. </view>
  34. </view>
  35. </view>
  36. <!-- 昵称输入 -->
  37. <view class="input-section">
  38. <view class="input-label">我的名字</view>
  39. <view class="input-wrapper">
  40. <input
  41. type="text"
  42. v-model="userInfo.nickname"
  43. placeholder="取一个独一无二的名字吧~"
  44. placeholder-class="input-placeholder"
  45. maxlength="10"
  46. />
  47. <view class="input-actions">
  48. <image
  49. src="/static/me/step/dlzc_icon_suiji.png"
  50. mode="aspectFit"
  51. class="action-icon random"
  52. @click="generateRandomNickname"
  53. ></image>
  54. </view>
  55. </view>
  56. </view>
  57. <!-- 性别选择 -->
  58. <view class="gender-section">
  59. <view class="input-label">性别</view>
  60. <view class="gender-options">
  61. <view
  62. class="gender-item"
  63. :class="{ active: userInfo.gender === '1' }"
  64. @click="userInfo.gender = '1'"
  65. >
  66. <image
  67. src="/static/me/step/dlzc_icon_nan.png"
  68. mode="aspectFit"
  69. class="gender-icon"
  70. ></image>
  71. <text>男生</text>
  72. </view>
  73. <view
  74. class="gender-item"
  75. :class="{ active: userInfo.gender === '2' }"
  76. @click="userInfo.gender = '2'"
  77. >
  78. <image
  79. src="/static/me/step/dlzc_icon_nv.png"
  80. mode="aspectFit"
  81. class="gender-icon"
  82. ></image>
  83. <text>女生</text>
  84. </view>
  85. <view
  86. class="gender-item"
  87. :class="{ active: userInfo.gender === '3' }"
  88. @click="userInfo.gender = '3'"
  89. >
  90. <image
  91. src="/static/me/step/dlzc_icon_qita.png"
  92. mode="aspectFit"
  93. class="gender-icon"
  94. ></image>
  95. <text>其它</text>
  96. </view>
  97. </view>
  98. </view>
  99. <!-- 生日选择 -->
  100. <view class="birthday-section">
  101. <view class="input-label">我的生日</view>
  102. <view class="birthday-picker">
  103. <picker
  104. style="height: auto"
  105. mode="date"
  106. :value="userInfo.birthday"
  107. :end="endDate"
  108. @change="bindDateChange"
  109. >
  110. <view class="uni-input">
  111. <text :class="{ placeholder: !userInfo.birthday }">{{
  112. userInfo.birthday || "选择生日"
  113. }}</text>
  114. <text v-if="userInfo.birthday" class="constellation">{{
  115. userInfo.xinzuo
  116. }}</text>
  117. </view>
  118. </picker>
  119. <image
  120. src="/static/me/step/dlzc_icon_arrow.png"
  121. mode="aspectFit"
  122. class="arrow-icon"
  123. ></image>
  124. </view>
  125. </view>
  126. </view>
  127. <!-- 步骤2:兴趣选择 -->
  128. <view v-if="currentStep === 2" class="step-content">
  129. <view class="step-title">亦是 <text>·奇思妙想·</text> 的原野</view>
  130. <view class="interest-section">
  131. <text class="interest-tip">请选择</text>
  132. <view
  133. class="interest-circles"
  134. @touchstart="handleTouchStart"
  135. @touchmove="handleTouchMove"
  136. @touchend="handleTouchEnd"
  137. >
  138. <view class="interest-circles-container" :style="getContainerStyle()">
  139. <view
  140. v-for="(interest, index) in interests"
  141. :key="index"
  142. class="interest-circle-box"
  143. :class="{
  144. 'active': selectedInterests.includes(interest.id),
  145. 'disabled': !selectedInterests.includes(interest.id) && isMaxSelected
  146. }"
  147. @click="toggleInterest(interest.id)"
  148. >
  149. <view class="interest-circle">
  150. <view>{{ interest.name }}</view>
  151. </view>
  152. </view>
  153. </view>
  154. </view>
  155. <!-- 添加兴趣爱好 -->
  156. <view class="add-interests">
  157. <view class="add-title">
  158. 添加兴趣爱好
  159. <text class="add-hint">(最多选择5个)</text>
  160. </view>
  161. <view class="interest-tags">
  162. <view
  163. v-for="(tag, index) in selectedTags"
  164. :key="index"
  165. class="interest-tag"
  166. >
  167. {{ tag.name }}
  168. <text class="remove-tag" @click.stop="removeTag(tag)">×</text>
  169. </view>
  170. <view
  171. class="add-tag"
  172. @click="showPopup"
  173. v-if="!isMaxSelected"
  174. >
  175. <image
  176. src="/static/me/step/dlzc_icon_tianjia.png"
  177. mode="aspectFit"
  178. class="add-icon"
  179. ></image>
  180. 创建新偏好
  181. </view>
  182. </view>
  183. </view>
  184. </view>
  185. </view>
  186. <!-- 底部按钮 -->
  187. <view class="bottom-button" @click="handleNext">
  188. {{ currentStep === 1 ? "下一步" : "完成" }}
  189. </view>
  190. <!-- 添加标签弹窗 -->
  191. <uni-popup ref="addTagPopup" type="center" :mask-click="false">
  192. <view class="add-tag-popup">
  193. <view class="popup-title">创建新偏好</view>
  194. <scroll-view
  195. scroll-y
  196. class="popup-content"
  197. :scroll-top="scrollTop"
  198. @scroll="onScroll"
  199. >
  200. <view class="popup-input">
  201. <input
  202. type="text"
  203. v-model="newTag"
  204. :disabled="isMaxSelected"
  205. :placeholder="isMaxSelected ? '已达到标签上限' : '输入您的兴趣爱好'"
  206. placeholder-style="color: #999999;"
  207. maxlength="5"
  208. @confirm="addNewTag"
  209. class="tag-input"
  210. :class="{ 'disabled': isMaxSelected }"
  211. />
  212. </view>
  213. <view class="selected-tags" v-if="selectedTags.length > 0">
  214. <view class="selected-tags-title">
  215. 已选标签 ({{ selectedTags.length }}/{{ maxTags }})
  216. <text v-if="isMaxSelected" class="max-hint">已达到上限</text>
  217. </view>
  218. <view class="selected-tags-list">
  219. <view
  220. v-for="(tag, index) in selectedTags"
  221. :key="index"
  222. class="selected-tag"
  223. >
  224. {{ tag.name }}
  225. <text class="remove-tag" @click.stop="removeTag(tag)">×</text>
  226. </view>
  227. </view>
  228. </view>
  229. </scroll-view>
  230. <view class="popup-buttons">
  231. <button class="btn-cancel" @click="closePopup">再考虑一下</button>
  232. <button
  233. class="btn-confirm"
  234. :class="{ 'disabled': isMaxSelected || !newTag.trim() }"
  235. @click="addNewTag"
  236. >确认添加</button>
  237. </view>
  238. </view>
  239. </uni-popup>
  240. </view>
  241. </template>
  242. <script>
  243. import {
  244. requestAndroidPermission,
  245. gotoAppPermissionSetting,
  246. } from "../index/permission.js";
  247. export default {
  248. components: {},
  249. data() {
  250. return {
  251. currentStep: 1,
  252. userInfo: {
  253. avatar: "",
  254. nickname: "",
  255. gender: "",
  256. birthday: "",
  257. xinzuo: "",
  258. },
  259. interests: [
  260. { id: 1, name: "老二次元了" },
  261. { id: 2, name: "coser" },
  262. { id: 3, name: "沉迷音乐-Hop" },
  263. { id: 4, name: "网游小达人" },
  264. { id: 5, name: "AJ控" },
  265. { id: 6, name: "白日梦想家" },
  266. { id: 7, name: "撸铁狂魔" },
  267. { id: 8, name: "古风汉服" },
  268. { id: 9, name: "爱画画" },
  269. { id: 10, name: "数码极客" },
  270. { id: 11, name: "盲盒玩家" },
  271. { id: 12, name: "三坑玩家" },
  272. { id: 13, name: "动漫达人" },
  273. { id: 14, name: "独立设计师" },
  274. { id: 15, name: "爱卡通" },
  275. { id: 16, name: "兜风去" },
  276. { id: 17, name: "爱夜跑" },
  277. { id: 18, name: "街头滑板" },
  278. { id: 19, name: "球类运动" },
  279. { id: 20, name: "lo娘" },
  280. { id: 21, name: "rapper" },
  281. { id: 22, name: "时尚达人" },
  282. { id: 23, name: "机甲狂潮" },
  283. { id: 24, name: "养宠物" },
  284. { id: 25, name: "风轻云淡" },
  285. { id: 26, name: "养多肉" },
  286. { id: 27, name: "热爱自然" },
  287. { id: 28, name: "赛博朋克" },
  288. { id: 29, name: "骨子里高冷" },
  289. { id: 30, name: "爱唠嗑" },
  290. { id: 31, name: "资深中二" },
  291. { id: 32, name: "天然呆" },
  292. { id: 33, name: "思想家" },
  293. { id: 34, name: "极度抽象" },
  294. { id: 35, name: "学院派" },
  295. { id: 36, name: "平平无奇" },
  296. { id: 37, name: "热情奔放" },
  297. { id: 38, name: "博古通今" },
  298. { id: 39, name: "labubu粉" },
  299. { id: 40, name: "玛特收藏家" },
  300. ],
  301. selectedInterests: [],
  302. showAddTag: false,
  303. newTag: "",
  304. endDate: "",
  305. circleConfig: {
  306. size: 132,
  307. gap: 30,
  308. rowGap: 20,
  309. offsetLefts: 30,
  310. offsetTops: 20,
  311. rows: 4,
  312. baseTop: 30,
  313. baseLeft: 30,
  314. },
  315. containerWidth: 0,
  316. customTags: [],
  317. maxTags: 5,
  318. scrollTop: 0,
  319. };
  320. },
  321. computed: {
  322. totalWidth() {
  323. const { size, gap, rows } = this.circleConfig;
  324. const columns = Math.ceil(this.interests.length / rows);
  325. return columns * (size + gap) + gap + "rpx";
  326. },
  327. selectedTags() {
  328. const selectedPresets = this.interests
  329. .filter((interest) => this.selectedInterests.includes(interest.id))
  330. .map((interest) => ({
  331. id: interest.id,
  332. name: interest.name,
  333. isPreset: true,
  334. }));
  335. return [...selectedPresets, ...this.customTags];
  336. },
  337. isMaxSelected() {
  338. return this.selectedTags.length >= this.maxTags;
  339. },
  340. },
  341. onLoad() {
  342. this.currentStep = 1;
  343. const now = new Date();
  344. const year = now.getFullYear();
  345. const month = String(now.getMonth() + 1).padStart(2, "0");
  346. const day = String(now.getDate()).padStart(2, "0");
  347. this.endDate = `${year}-${month}-${day}`;
  348. },
  349. onShow() {},
  350. methods: {
  351. onBack() {},
  352. chkSel() {
  353. if (this.sel == 1) {
  354. this.sel = 0;
  355. } else {
  356. this.sel = 1;
  357. }
  358. },
  359. chkSex(sex) {
  360. this.sex = sex;
  361. },
  362. delTag(tg) {
  363. let list_tag2 = [];
  364. for (let i = 0; i < this.sel_tags.length; i++) {
  365. if (this.sel_tags[i] != tg && this.sel_tags[i] != "") {
  366. list_tag2.push(this.sel_tags[i]);
  367. }
  368. }
  369. this.sel_tags = list_tag2;
  370. },
  371. selTags(itm) {
  372. let that = this;
  373. let isIn = false;
  374. for (let entry of this.sel_tags) {
  375. // console.log(entry); // 1, "string", false
  376. if (entry == itm) {
  377. isIn = true;
  378. break;
  379. }
  380. }
  381. return isIn;
  382. },
  383. chkTag(itm) {
  384. if (this.selTags(itm)) {
  385. let tmpTags = [];
  386. for (let entry of this.sel_tags) {
  387. // console.log(entry); // 1, "string", false
  388. if (entry != itm && entry != "") {
  389. tmpTags.push(entry);
  390. }
  391. }
  392. this.sel_tags = tmpTags;
  393. } else {
  394. if (this.sel_tags.length >= 5) {
  395. this.$refs["ToastW3"].showToast({
  396. title: "最多选择5个标签",
  397. animation: 0,
  398. });
  399. return;
  400. }
  401. this.sel_tags.push(itm);
  402. }
  403. },
  404. sliderChange1(e) {
  405. this.age = e.detail.value;
  406. },
  407. sliderChange2(e) {
  408. this.height = e.detail.value;
  409. },
  410. sliderChange3(e) {
  411. this.weight = e.detail.value;
  412. },
  413. SetXueli() {
  414. let that = this;
  415. uni.showActionSheet({
  416. itemColor: "#000000",
  417. itemList: this.xueli,
  418. success: function (res) {
  419. that.xueli_sel = that.xueli[res.tapIndex];
  420. // console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
  421. },
  422. fail: function (res) {
  423. console.log(res.errMsg);
  424. },
  425. });
  426. },
  427. SetXinzuo() {
  428. let that = this;
  429. uni.showActionSheet({
  430. itemColor: "#000000",
  431. itemList: this.xinzuo,
  432. success: function (res) {
  433. that.xinzuo_sel = that.xinzuo[res.tapIndex];
  434. // console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
  435. },
  436. fail: function (res) {
  437. console.log(res.errMsg);
  438. },
  439. });
  440. },
  441. getInfoData() {
  442. console.log(this.$apiHost + "/Member/getinfoData");
  443. uni.request({
  444. url: this.$apiHost + "/Member/getinfoData", //仅为示例,并非真实接口地址。
  445. data: {
  446. uuid: getApp().globalData.uuid,
  447. },
  448. header: {
  449. "content-type": "application/json", //自定义请求头信息
  450. },
  451. success: (res) => {
  452. console.log("res", res.data);
  453. this.nickname = res.data.nickname;
  454. this.wechat = res.data.wechat;
  455. this.sex = res.data.sex || 2;
  456. this.age = res.data.age || 18;
  457. this.height = res.data.height || 160;
  458. this.weight = res.data.weight || 50;
  459. this.xueli_sel = res.data.xueli;
  460. this.xinzuo_sel = res.data.xinzuo;
  461. this.ziye = res.data.ziye;
  462. this.qianmin = res.data.qianmin;
  463. if (res.data.avator != "") {
  464. this.avator = res.data.avator;
  465. }
  466. if (res.data.aihao != null && res.data.aihao != undefined) {
  467. if (res.data.aihao.length > 0) {
  468. this.sel_tags = res.data.aihao.split(",");
  469. }
  470. }
  471. },
  472. });
  473. },
  474. submitData() {
  475. let aihao = this.sel_tags.join(",");
  476. let obj2 = {
  477. uuid: getApp().globalData.uuid,
  478. avator: this.avator,
  479. nickname: this.nickname,
  480. wechat: this.wechat,
  481. sex: this.sex,
  482. age: this.age,
  483. height: this.height,
  484. weight: this.weight,
  485. xueli: this.xueli_sel,
  486. xinzuo: this.xinzuo_sel,
  487. ziye: this.ziye,
  488. qianmin: this.qianmin,
  489. aihao: aihao,
  490. };
  491. // console.log("obj2", obj2);
  492. uni.request({
  493. url: this.$apiHost + "/Member/setinfoData", //仅为示例,并非真实接口地址。
  494. data: obj2,
  495. method: "POST",
  496. header: {
  497. "Content-Type": "application/x-www-form-urlencoded",
  498. sign: getApp().globalData.headerSign,
  499. },
  500. dataType: "json",
  501. // header: {
  502. // 'content-type': 'application/json', //自定义请求头信息
  503. // 'Access-Control-Allow-Origin': '*'
  504. // },
  505. success: (res) => {
  506. console.log("res", res.data);
  507. this.$refs["ToastW3"].showToast({
  508. title: res.data.str,
  509. animation: 0,
  510. });
  511. if (res.data.success == "yes") {
  512. uni.switchTab({
  513. url: "/pages/index/index",
  514. });
  515. }
  516. },
  517. });
  518. },
  519. // upload() {
  520. // let that = this;
  521. // this.$refs['DialogBox'].confirm({
  522. // title: '提示',
  523. // content: '该权限用于获取设备拍摄或获取本地应用相册,进行头像的图片上传。',
  524. // DialogType: 'inquiry',
  525. // btn1: '拒绝',
  526. // btn2: '同意',
  527. // animation: 0
  528. // }).then((res) => {
  529. // that.upload2();
  530. // })
  531. // },
  532. upload() {
  533. this.checkRights();
  534. console.log("----upload");
  535. var _self = this;
  536. uni.chooseImage({
  537. count: 1,
  538. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  539. sourceType: ["album", "camera"], //从相册、相机选择
  540. extension: [".png", ".jpeg", ".jpg"],
  541. success: function (res) {
  542. console.log("res:", res);
  543. _self.imglocal = res.tempFilePaths[0];
  544. const tempFilePaths = res.tempFilePaths[0];
  545. console.log("tempFilePaths:", tempFilePaths);
  546. // 图片上传
  547. const uploadTask = uni.uploadFile({
  548. url: _self.$apiHost + "/Xweb/upload_img?skey=" + _self.skey, // post请求地址
  549. filePath: res.tempFilePaths[0],
  550. name: "file", // 待确认
  551. success: function (uploadFileRes) {
  552. let resdata = JSON.parse(uploadFileRes.data);
  553. console.log("Success11:", uploadFileRes);
  554. console.log("Success21:", resdata);
  555. if (resdata.success == "yes") {
  556. _self.avator = resdata.url;
  557. }
  558. },
  559. fail: function (uploadFileFail) {
  560. console.log("Error:", uploadFileFail.data);
  561. },
  562. complete: () => {
  563. console.log("Complete:");
  564. },
  565. });
  566. },
  567. error: function (e) {
  568. console.log(e);
  569. },
  570. });
  571. },
  572. checkRights() {
  573. let that = this;
  574. that.showRights = true;
  575. requestAndroidPermission("android.permission.CAMERA")
  576. .then((result) => {
  577. that.showRights = false;
  578. // 根据返回的结果进行处理
  579. if (result === 1) {
  580. } else if (result === 0) {
  581. console.log("权限被拒绝");
  582. } else if (result === -1) {
  583. console.log("权限被永久拒绝");
  584. }
  585. })
  586. .catch((error) => {
  587. that.showRights = true;
  588. console.log("权限申请失败:", error);
  589. });
  590. },
  591. chooseAvatar() {
  592. uni.chooseImage({
  593. count: 1,
  594. sizeType: ["compressed"],
  595. sourceType: ["album", "camera"],
  596. success: (res) => {
  597. this.userInfo.avatar = res.tempFilePaths[0];
  598. },
  599. });
  600. },
  601. toggleInterest(id) {
  602. if (this.selectedInterests.includes(id)) {
  603. // 取消选择
  604. this.selectedInterests.splice(this.selectedInterests.indexOf(id), 1);
  605. } else if (!this.isMaxSelected) {
  606. // 添加选择
  607. this.selectedInterests.push(id);
  608. } else {
  609. uni.showToast({
  610. title: '最多只能选择5个标签哦',
  611. icon: 'none',
  612. duration: 1500
  613. });
  614. }
  615. },
  616. removeTag(tag) {
  617. if (tag.isPreset) {
  618. const index = this.selectedInterests.indexOf(tag.id);
  619. if (index !== -1) {
  620. this.selectedInterests.splice(index, 1);
  621. }
  622. } else {
  623. const index = this.customTags.findIndex(
  624. (item) => item.name === tag.name
  625. );
  626. if (index !== -1) {
  627. this.customTags.splice(index, 1);
  628. }
  629. }
  630. uni.showToast({
  631. title: '已删除',
  632. icon: 'none',
  633. duration: 1500
  634. });
  635. },
  636. showPopup() {
  637. this.$refs.addTagPopup.open();
  638. },
  639. closePopup() {
  640. this.$refs.addTagPopup.close();
  641. this.newTag = '';
  642. },
  643. addNewTag() {
  644. const tagName = this.newTag.trim();
  645. if (!tagName) {
  646. uni.showToast({
  647. title: '请输入标签内容',
  648. icon: 'none'
  649. });
  650. return;
  651. }
  652. if (tagName.length > 5) {
  653. uni.showToast({
  654. title: '标签最多5个字哦',
  655. icon: 'none'
  656. });
  657. return;
  658. }
  659. if (this.isMaxSelected) {
  660. uni.showToast({
  661. title: '最多只能添加5个标签哦',
  662. icon: 'none'
  663. });
  664. return;
  665. }
  666. const isPresetDuplicate = this.interests.some(
  667. (interest) => interest.name === tagName
  668. );
  669. const isCustomDuplicate = this.customTags.some(
  670. (tag) => tag.name === tagName
  671. );
  672. if (isPresetDuplicate || isCustomDuplicate) {
  673. uni.showToast({
  674. title: '这个标签已经添加过啦',
  675. icon: 'none'
  676. });
  677. return;
  678. }
  679. this.customTags.push({
  680. name: tagName,
  681. isCustom: true,
  682. });
  683. uni.showToast({
  684. title: '添加成功',
  685. icon: 'success',
  686. duration: 1500
  687. });
  688. this.newTag = '';
  689. this.closePopup();
  690. },
  691. generateRandomNickname() {
  692. const characters = "0123456789";
  693. let result = "织梦者_";
  694. for (let i = 0; i < 8; i++) {
  695. result += characters.charAt(
  696. Math.floor(Math.random() * characters.length)
  697. );
  698. }
  699. this.userInfo.nickname = result;
  700. },
  701. bindDateChange(e) {
  702. const selectedDate = new Date(e.detail.value);
  703. const now = new Date();
  704. if (selectedDate > now) {
  705. uni.showToast({
  706. title: "不能选择未来日期",
  707. icon: "none",
  708. });
  709. return;
  710. }
  711. this.userInfo.birthday = e.detail.value;
  712. this.setXinzuoByDate(e.detail.value);
  713. },
  714. bindXinzuoChange(e) {
  715. const index = e.detail.value;
  716. this.xinzuoIndex = index;
  717. this.userInfo.xinzuo = this.xinzuo[index];
  718. },
  719. setXinzuoByDate(birthday) {
  720. if (!birthday) return;
  721. const date = new Date(birthday);
  722. const month = date.getMonth() + 1;
  723. const day = date.getDate();
  724. let xinzuoIndex = 0;
  725. if ((month == 1 && day >= 20) || (month == 2 && day <= 18)) {
  726. xinzuoIndex = 0; // 水瓶座
  727. } else if ((month == 2 && day >= 19) || (month == 3 && day <= 20)) {
  728. xinzuoIndex = 1; // 双鱼座
  729. } else if ((month == 3 && day >= 21) || (month == 4 && day <= 19)) {
  730. xinzuoIndex = 2; // 白羊座
  731. } else if ((month == 4 && day >= 20) || (month == 5 && day <= 20)) {
  732. xinzuoIndex = 3; // 金牛座
  733. } else if ((month == 5 && day >= 21) || (month == 6 && day <= 21)) {
  734. xinzuoIndex = 4; // 双子座
  735. } else if ((month == 6 && day >= 22) || (month == 7 && day <= 22)) {
  736. xinzuoIndex = 5; // 巨蟹座
  737. } else if ((month == 7 && day >= 23) || (month == 8 && day <= 22)) {
  738. xinzuoIndex = 6; // 狮子座
  739. } else if ((month == 8 && day >= 23) || (month == 9 && day <= 22)) {
  740. xinzuoIndex = 7; // 处女座
  741. } else if ((month == 9 && day >= 23) || (month == 10 && day <= 23)) {
  742. xinzuoIndex = 8; // 天秤座
  743. } else if ((month == 10 && day >= 24) || (month == 11 && day <= 22)) {
  744. xinzuoIndex = 9; // 天蝎座
  745. } else if ((month == 11 && day >= 23) || (month == 12 && day <= 21)) {
  746. xinzuoIndex = 10; // 射手座
  747. } else {
  748. xinzuoIndex = 11; // 摩羯座
  749. }
  750. this.xinzuoIndex = xinzuoIndex;
  751. this.userInfo.xinzuo = this.xinzuo[xinzuoIndex];
  752. },
  753. getCircleStyle(index) {
  754. const {
  755. size,
  756. gap,
  757. rowGap,
  758. rows,
  759. baseTop,
  760. offsetLefts,
  761. offsetTops,
  762. baseLeft,
  763. } = this.circleConfig;
  764. const row = index % rows;
  765. const column = Math.floor(index / rows);
  766. let offsetLeft = 0;
  767. let offsetTop = 0;
  768. if (row == 0 || row == 2) {
  769. offsetLeft = offsetLefts;
  770. } else {
  771. offsetLeft = -offsetLefts;
  772. }
  773. if (column == 1 || column == 3) {
  774. offsetTop = offsetTops;
  775. } else {
  776. offsetTop = -offsetTops;
  777. }
  778. const left = baseLeft + column * (size + gap) + offsetLeft + "rpx";
  779. const top = baseTop + row * (size + rowGap) + offsetTop + "rpx";
  780. return {
  781. position: "absolute",
  782. left,
  783. top,
  784. width: size + "rpx",
  785. height: size + "rpx",
  786. };
  787. },
  788. getContainerStyle() {
  789. return {
  790. width: this.totalWidth,
  791. height: "648rpx",
  792. position: "relative",
  793. };
  794. },
  795. handleTouchStart(e) {
  796. this.touchStartX = e.touches[0].clientX;
  797. this.touchStartScrollLeft = e.currentTarget.scrollLeft;
  798. },
  799. handleTouchMove(e) {
  800. if (!this.touchStartX) return;
  801. const deltaX = this.touchStartX - e.touches[0].clientX;
  802. e.currentTarget.scrollLeft = this.touchStartScrollLeft + deltaX;
  803. },
  804. handleTouchEnd() {
  805. this.touchStartX = null;
  806. this.touchStartScrollLeft = null;
  807. },
  808. handleNext() {
  809. if (this.currentStep === 1) {
  810. // 验证第一步数据
  811. if (!this.userInfo.nickname) {
  812. uni.showToast({
  813. title: "请输入昵称",
  814. icon: "none",
  815. });
  816. return;
  817. }
  818. if (!this.userInfo.gender) {
  819. uni.showToast({
  820. title: "请选择性别",
  821. icon: "none",
  822. });
  823. return;
  824. }
  825. this.currentStep = 2;
  826. } else {
  827. // 验证第二步数据
  828. if (
  829. this.selectedInterests.length === 0 &&
  830. this.selectedTags.length === 0
  831. ) {
  832. uni.showToast({
  833. title: "请至少选择一个兴趣",
  834. icon: "none",
  835. });
  836. return;
  837. }
  838. // 提交所有数据
  839. this.submitUserInfo();
  840. }
  841. },
  842. submitUserInfo() {
  843. let tagStr = this.selectedTags.map(item => item.name).join(',');
  844. const data = {
  845. ...this.userInfo,
  846. interests: this.selectedInterests,
  847. tags: tagStr,
  848. uuid: getApp().globalData.uuid,
  849. };
  850. uni.showLoading({
  851. title: "保存中...",
  852. });
  853. uni.request({
  854. url: this.$apiHost + "/Member/setinfoData", //仅为示例,并非真实接口地址。
  855. data: data,
  856. method: "POST",
  857. header: {
  858. "Content-Type": "application/x-www-form-urlencoded",
  859. sign: getApp().globalData.headerSign,
  860. },
  861. dataType: "json",
  862. // header: {
  863. // 'content-type': 'application/json', //自定义请求头信息
  864. // 'Access-Control-Allow-Origin': '*'
  865. // },
  866. success: (res) => {
  867. if (res.data.success === "yes") {
  868. uni.showToast({
  869. title: "保存成功",
  870. icon: "success",
  871. });
  872. // 延迟跳转
  873. setTimeout(() => {
  874. uni.switchTab({
  875. url: "/pages/index/index",
  876. });
  877. }, 1500);
  878. } else {
  879. uni.showToast({
  880. title: res.data.msg || "保存失败",
  881. icon: "none",
  882. });
  883. }
  884. }, fail: () => {
  885. uni.showToast({
  886. title: "网络错误",
  887. icon: "none",
  888. });
  889. },
  890. complete: () => {
  891. uni.hideLoading();
  892. },
  893. });
  894. },
  895. onScroll(e) {
  896. this.scrollTop = e.detail.scrollTop;
  897. }
  898. },
  899. };
  900. </script>
  901. <style lang="scss">
  902. .reserveASeat {
  903. width: 100%;
  904. height: calc(var(--status-bar-height) + 20rpx);
  905. }
  906. .popSel {
  907. position: fixed;
  908. z-index: 101;
  909. top: 0;
  910. left: 0;
  911. background-color: #f2f6f2;
  912. width: 100%;
  913. height: 100vh;
  914. overflow-y: scroll;
  915. -webkit-overflow-scrolling: touch;
  916. box-sizing: border-box;
  917. padding-bottom: 100rpx;
  918. }
  919. .tag_all_select {
  920. padding: 20rpx;
  921. height: 100%;
  922. overflow-y: auto;
  923. .tag_items {
  924. display: flex;
  925. flex-wrap: wrap;
  926. gap: 30rpx;
  927. justify-content: center;
  928. align-items: center;
  929. padding-bottom: 50rpx;
  930. .tag_item {
  931. display: flex;
  932. align-items: center;
  933. justify-content: center;
  934. border-radius: 50%;
  935. background: rgba(255, 255, 255, 0.1);
  936. color: #333;
  937. font-size: 26rpx;
  938. transition: all 0.3s ease;
  939. cursor: pointer;
  940. &.small {
  941. width: 120rpx;
  942. height: 120rpx;
  943. }
  944. &.medium {
  945. width: 160rpx;
  946. height: 160rpx;
  947. font-size: 28rpx;
  948. }
  949. &.large {
  950. width: 200rpx;
  951. height: 200rpx;
  952. font-size: 32rpx;
  953. }
  954. &.active {
  955. transform: scale(1.2);
  956. background: rgba(255, 255, 255, 0.2);
  957. box-shadow: 0 0 20rpx rgba(255, 255, 255, 0.3);
  958. z-index: 1;
  959. }
  960. &:not(.active):hover {
  961. transform: scale(1.05);
  962. }
  963. }
  964. }
  965. }
  966. .step-container {
  967. min-height: 100vh;
  968. background: url("../../static/me/step/wd_bg_bianjiziliao.png") top center/100%
  969. no-repeat,
  970. #f2f6f2;
  971. padding: 40rpx 0;
  972. padding-bottom: 230rpx;
  973. box-sizing: border-box;
  974. }
  975. .step-header {
  976. margin-bottom: 20rpx;
  977. padding: 0 40rpx;
  978. .step-number {
  979. font-size: 48rpx;
  980. font-weight: bold;
  981. color: #000;
  982. margin-bottom: 20rpx;
  983. display: block;
  984. text-align: center;
  985. }
  986. .progress-container {
  987. height: 6rpx;
  988. background: #f1f1f1;
  989. border-radius: 4rpx;
  990. overflow: hidden;
  991. .progress-inner {
  992. height: 100%;
  993. background: #1f1f1f;
  994. border-radius: 4rpx;
  995. transition: width 0.3s ease;
  996. height: 6rpx;
  997. }
  998. }
  999. }
  1000. .step-content {
  1001. padding:0 40rpx;
  1002. .step-title {
  1003. text-align: center;
  1004. font-size: 32rpx;
  1005. font-weight: bold;
  1006. color: #666;
  1007. margin-bottom: 50rpx;
  1008. letter-spacing: 1rpx;
  1009. text {
  1010. font-size: 40rpx;
  1011. }
  1012. }
  1013. }
  1014. .avatar-section {
  1015. display: flex;
  1016. justify-content: center;
  1017. margin-bottom: 60rpx;
  1018. .avatar-wrapper {
  1019. width: 200rpx;
  1020. height: 200rpx;
  1021. border-radius: 50%;
  1022. background: #f8f8f8;
  1023. display: flex;
  1024. align-items: center;
  1025. justify-content: center;
  1026. border: 4rpx dashed #e5e5e5;
  1027. position: relative;
  1028. .avatar {
  1029. width: 100%;
  1030. height: 100%;
  1031. }
  1032. .avatar-placeholder {
  1033. width: 64rpx;
  1034. height: 64rpx;
  1035. position: absolute;
  1036. bottom: 0;
  1037. right: 0;
  1038. .camera-icon {
  1039. width: 100%;
  1040. height: 100%;
  1041. }
  1042. }
  1043. }
  1044. }
  1045. .input-section {
  1046. margin-bottom: 20rpx;
  1047. .input-wrapper {
  1048. position: relative;
  1049. display: flex;
  1050. align-items: center;
  1051. background: #f8f8f8;
  1052. border-radius: 16rpx;
  1053. padding-right: 20rpx;
  1054. input {
  1055. flex: 1;
  1056. height: 88rpx;
  1057. padding: 0 20rpx 0 30rpx;
  1058. font-size: 28rpx;
  1059. color: #333;
  1060. background: transparent;
  1061. &::placeholder {
  1062. color: #999;
  1063. }
  1064. }
  1065. .input-actions {
  1066. display: flex;
  1067. align-items: center;
  1068. gap: 16rpx;
  1069. .close-icon {
  1070. width: 36rpx;
  1071. height: 36rpx;
  1072. }
  1073. .random {
  1074. width: 44rpx;
  1075. height: 44rpx;
  1076. }
  1077. }
  1078. }
  1079. }
  1080. .gender-section {
  1081. margin-bottom: 20rpx;
  1082. .gender-options {
  1083. display: flex;
  1084. gap: 20rpx;
  1085. .gender-item {
  1086. flex: 1;
  1087. background: #f8f8f8;
  1088. border-radius: 20rpx;
  1089. display: flex;
  1090. flex-direction: column;
  1091. align-items: center;
  1092. justify-content: center;
  1093. transition: all 0.3s ease;
  1094. width: 184px;
  1095. height: 168rpx;
  1096. border-radius: 20rpx;
  1097. border: 4rpx solid #e9e9e9;
  1098. &.active {
  1099. background: linear-gradient(
  1100. 180deg,
  1101. #f0ffd9 0%,
  1102. rgba(240, 255, 217, 0) 99%
  1103. );
  1104. transform: scale(1.02);
  1105. border-color: #1f1f1f;
  1106. }
  1107. .gender-icon {
  1108. width: 80rpx;
  1109. height: 80rpx;
  1110. margin-bottom: 16rpx;
  1111. }
  1112. text {
  1113. font-size: 28rpx;
  1114. color: #333;
  1115. }
  1116. }
  1117. }
  1118. }
  1119. .birthday-section {
  1120. margin-bottom: 20rpx;
  1121. background: #fff;
  1122. padding: 20rpx;
  1123. border-radius: 20rpx;
  1124. .input-label {
  1125. font-size: 28rpx;
  1126. color: #333;
  1127. padding-bottom: 20rpx;
  1128. }
  1129. .birthday-picker {
  1130. height: 88rpx;
  1131. background: #f8f8f8;
  1132. border-radius: 16rpx;
  1133. padding: 0 30rpx;
  1134. display: flex;
  1135. align-items: center;
  1136. justify-content: space-between;
  1137. picker {
  1138. flex: 1;
  1139. height: 100%;
  1140. .uni-input {
  1141. width: 100%;
  1142. height: 100%;
  1143. display: flex;
  1144. align-items: center;
  1145. gap: 12rpx;
  1146. text {
  1147. font-size: 28rpx;
  1148. color: #333;
  1149. &.placeholder {
  1150. color: #999;
  1151. }
  1152. &.constellation {
  1153. font-size: 28rpx;
  1154. color: #1f1f1f;
  1155. padding: 4rpx 12rpx;
  1156. border-radius: 8rpx;
  1157. }
  1158. }
  1159. }
  1160. }
  1161. .arrow-icon {
  1162. width: 32rpx;
  1163. height: 32rpx;
  1164. flex-shrink: 0;
  1165. }
  1166. }
  1167. }
  1168. .interest-section {
  1169. .interest-tip {
  1170. font-size: 28rpx;
  1171. color: #666;
  1172. margin-bottom: 30rpx;
  1173. padding: 0 20rpx;
  1174. }
  1175. .interest-circles {
  1176. width: 100%;
  1177. height: 648rpx;
  1178. overflow-x: scroll;
  1179. overflow-y: hidden;
  1180. position: relative;
  1181. margin-bottom: 60rpx;
  1182. padding: 10rpx;
  1183. box-sizing: border-box;
  1184. -webkit-overflow-scrolling: touch;
  1185. &::-webkit-scrollbar {
  1186. display: none;
  1187. }
  1188. -ms-overflow-style: none;
  1189. scrollbar-width: none;
  1190. .interest-circles-container {
  1191. position: relative;
  1192. height: 100%;
  1193. display: flex;
  1194. flex-wrap: wrap;
  1195. gap: 20rpx;
  1196. padding: 20rpx;
  1197. }
  1198. .interest-circle-box {
  1199. width: 132rpx;
  1200. height: 132rpx;
  1201. border-radius: 50%;
  1202. position: relative;
  1203. display: flex;
  1204. align-items: center;
  1205. justify-content: center;
  1206. &.active {
  1207. background: url("../../static/me/step/dlzc_btn_xuanzhong.png") no-repeat
  1208. center center / 100% 100%;
  1209. }
  1210. &.disabled {
  1211. opacity: 0.5;
  1212. cursor: not-allowed;
  1213. .interest-circle {
  1214. background: rgba(0, 0, 0, 0.02);
  1215. }
  1216. }
  1217. .interest-circle {
  1218. width: 120rpx;
  1219. height: 120rpx;
  1220. display: flex;
  1221. align-items: center;
  1222. justify-content: center;
  1223. border-radius: 50%;
  1224. background: rgba(0, 0, 0, 0.04);
  1225. font-size: 24rpx;
  1226. color: #666;
  1227. transition: all 0.3s ease;
  1228. text-align: center;
  1229. box-sizing: border-box;
  1230. max-width: 120rpx;
  1231. padding: 10rpx;
  1232. > view {
  1233. width: 100%;
  1234. white-space: nowrap;
  1235. overflow: hidden;
  1236. text-overflow: ellipsis;
  1237. }
  1238. }
  1239. }
  1240. }
  1241. }
  1242. .interest-tags {
  1243. display: flex;
  1244. flex-wrap: wrap;
  1245. gap: 20rpx;
  1246. margin-top: 30rpx;
  1247. padding: 0 20rpx;
  1248. .interest-tag {
  1249. padding: 16rpx 24rpx;
  1250. background: #FFFFFF;
  1251. border-radius: 100rpx;
  1252. font-size: 28rpx;
  1253. color: #333333;
  1254. display: flex;
  1255. align-items: center;
  1256. box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.05);
  1257. position: relative;
  1258. .remove-tag {
  1259. margin-left: 12rpx;
  1260. font-size: 32rpx;
  1261. color: #333333;
  1262. padding: 0 6rpx;
  1263. display: flex;
  1264. align-items: center;
  1265. position: relative;
  1266. z-index: 1;
  1267. &::after {
  1268. content: '';
  1269. position: absolute;
  1270. left: -8rpx;
  1271. right: -8rpx;
  1272. top: -8rpx;
  1273. bottom: -8rpx;
  1274. z-index: 0;
  1275. }
  1276. }
  1277. }
  1278. .add-tag {
  1279. padding: 16rpx 24rpx;
  1280. background: #FFFFFF;
  1281. border-radius: 100rpx;
  1282. font-size: 28rpx;
  1283. color: #333333;
  1284. display: flex;
  1285. align-items: center;
  1286. box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.05);
  1287. .add-icon {
  1288. width: 32rpx;
  1289. height: 32rpx;
  1290. margin-right: 12rpx;
  1291. }
  1292. }
  1293. }
  1294. .bottom-button {
  1295. position: fixed;
  1296. left: 40rpx;
  1297. right: 40rpx;
  1298. bottom: 40rpx;
  1299. height: 88rpx;
  1300. background: #000;
  1301. border-radius: 44rpx;
  1302. color: #fff;
  1303. font-size: 32rpx;
  1304. display: flex;
  1305. align-items: center;
  1306. justify-content: center;
  1307. transition: all 0.3s ease;
  1308. &.step2 {
  1309. background: linear-gradient(90deg, #acf934 0%, #23c343 100%);
  1310. color: #000;
  1311. }
  1312. }
  1313. .add-tag-popup {
  1314. background: #FFFFFF;
  1315. border-radius: 24rpx;
  1316. width: 580rpx;
  1317. height: 70vh;
  1318. max-height: 800rpx;
  1319. display: flex;
  1320. flex-direction: column;
  1321. .popup-title {
  1322. padding: 40rpx 30rpx 20rpx;
  1323. font-size: 32rpx;
  1324. color: #333333;
  1325. text-align: center;
  1326. font-weight: 600;
  1327. flex-shrink: 0;
  1328. }
  1329. .popup-content {
  1330. flex: 1;
  1331. overflow-y: auto;
  1332. padding: 0 30rpx;
  1333. margin-bottom: 20rpx;
  1334. .popup-input {
  1335. margin-bottom: 30rpx;
  1336. .tag-input {
  1337. width: 100%;
  1338. height: 80rpx;
  1339. background: #f2f6f2;
  1340. border-radius: 12rpx;
  1341. padding: 0 24rpx;
  1342. font-size: 28rpx;
  1343. color: #333333;
  1344. &.disabled {
  1345. background: rgba(0, 0, 0, 0.02);
  1346. color: #999;
  1347. }
  1348. }
  1349. }
  1350. .selected-tags {
  1351. .selected-tags-title {
  1352. font-size: 28rpx;
  1353. color: #666666;
  1354. margin-bottom: 20rpx;
  1355. display: flex;
  1356. align-items: center;
  1357. justify-content: space-between;
  1358. .max-hint {
  1359. font-size: 24rpx;
  1360. color: #FF6B6B;
  1361. }
  1362. }
  1363. .selected-tags-list {
  1364. display: flex;
  1365. flex-wrap: wrap;
  1366. gap: 16rpx;
  1367. .selected-tag {
  1368. padding: 12rpx 24rpx;
  1369. background: #f2f6f2;
  1370. border-radius: 100rpx;
  1371. font-size: 26rpx;
  1372. color: #333333;
  1373. }
  1374. }
  1375. }
  1376. }
  1377. .popup-buttons {
  1378. padding: 20rpx 30rpx 30rpx;
  1379. display: flex;
  1380. gap: 20rpx;
  1381. background: #FFFFFF;
  1382. flex-shrink: 0;
  1383. position: relative;
  1384. &::before {
  1385. content: '';
  1386. position: absolute;
  1387. left: 0;
  1388. right: 0;
  1389. top: -20rpx;
  1390. height: 20rpx;
  1391. background: linear-gradient(to top, rgba(255,255,255,1), rgba(255,255,255,0));
  1392. }
  1393. button {
  1394. flex: 1;
  1395. height: 80rpx;
  1396. border-radius: 12rpx;
  1397. font-size: 28rpx;
  1398. display: flex;
  1399. align-items: center;
  1400. justify-content: center;
  1401. border: none;
  1402. &.btn-cancel {
  1403. background: #FFFFFF;
  1404. color: #333333;
  1405. border: 2rpx solid #1F1F1F;
  1406. }
  1407. &.btn-confirm {
  1408. background: #333333;
  1409. color: #FFFFFF;
  1410. &.disabled {
  1411. opacity: 0.5;
  1412. background: #999;
  1413. }
  1414. }
  1415. }
  1416. }
  1417. }
  1418. .birthday-section,
  1419. .input-section,
  1420. .gender-section {
  1421. background: #fff;
  1422. padding: 20rpx;
  1423. border-radius: 20rpx;
  1424. .input-label {
  1425. font-size: 28rpx;
  1426. color: #333;
  1427. padding-bottom: 20rpx;
  1428. }
  1429. }
  1430. </style>