step.vue 37 KB

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