editInfo.vue 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060
  1. <template>
  2. <view class="page">
  3. <PageHeader title="" class="PageHeader">
  4. <template v-slot:center>
  5. <view style="font-size: 32rpx;">基本资料</view>
  6. </template>
  7. </PageHeader>
  8. <view class="reserveASeat"></view>
  9. <!-- <view style="height: 90rpx;"></view> -->
  10. <view class="list_info">
  11. <view class="bcenter">
  12. <view class="avator" @click="chooseAvatar">
  13. <!-- <image class="img" :src="avator" mode="aspectFill" /> -->
  14. <CircleAvatar class="avator" :src="avator" style="width: 200rpx; height: 200rpx;"></CircleAvatar>
  15. <image class="photo" src="../../static/me/photo.png" mode="widthFix" />
  16. </view>
  17. </view>
  18. <view class="section_title">基本信息</view>
  19. <view class="info_card">
  20. <view class="info_item" @click="openNicknamePopUpWindow">
  21. <text class="label">昵称</text>
  22. <view class="content">
  23. <text v-if="nickname" class="textContent">{{ nickname }}</text>
  24. <text v-else class="textPrompt">请输入昵称</text>
  25. <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" />
  26. </view>
  27. </view>
  28. <view class="info_item" @click="SetSex">
  29. <text class="label">性别</text>
  30. <view class="content">
  31. <input type="text" placeholder="选择你的性别" v-model="sexText" disabled="true" />
  32. <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" />
  33. </view>
  34. </view>
  35. <view class="info_item" @click="open()">
  36. <text class="label">生日</text>
  37. <view class="content">
  38. <!-- <picker mode="date" :value="birthday" :end="endDate" @change="onBirthdayChange"> -->
  39. <!-- <input type="text" placeholder="选择你的生日" v-model="birthday" disabled="true" /> -->
  40. <view class="birthday" style="color:#1f1f1f;" v-if="birthday">{{ birthday }}</view>
  41. <view class="birthday" style="color: grey;" v-else>请选择你的生日</view>
  42. <!-- </picker> -->
  43. <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" />
  44. </view>
  45. </view>
  46. <uni-calendar :date="birthday || '2000-01-01'" ref="calendar" :insert="false" @confirm="confirm" />
  47. <view class="info_item">
  48. <text class="label">星座</text>
  49. <view class="content">
  50. <input type="text" placeholder="根据你的生日自动匹配" :value="xinzuo_sel" disabled="true"
  51. style="padding-right: 43rpx;" />
  52. <!-- <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" /> -->
  53. </view>
  54. </view>
  55. <view class="info_item" @click="openContentPopUpWindow">
  56. <text class="label">简介</text>
  57. <view class="content">
  58. <!-- <input type="text" placeholder="做个自我介绍吧~" v-model="content" maxlength="32" /> -->
  59. <text v-if="content" class="textContent one-omit">{{ content }}</text>
  60. <text v-else class="textPrompt">做个自我介绍吧</text>
  61. <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" />
  62. </view>
  63. </view>
  64. <view class="info_item" @click="openBackgroundImage">
  65. <text class="label">背景图</text>
  66. <view class="content">
  67. <image class="backgroundImage" :src="bgImage" mode="aspectFill"></image>
  68. <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" />
  69. </view>
  70. </view>
  71. </view>
  72. <view class="section_title">个性标签</view>
  73. <view class="info_card">
  74. <view class="item_tag">
  75. <view class="tag" v-for="(item, index) in sel_tags" :key="index">
  76. {{ item }}
  77. <image class="close" src="../../static/me/close.png" mode="widthFix" @click="delTag(item)" />
  78. </view>
  79. <view class="addNew blick-btn-animation" @click="showPop = true;">+ 添加</view>
  80. </view>
  81. </view>
  82. <view class="blankHeight"></view>
  83. </view>
  84. <view class="btn_submit blick-btn-animation" @click="submitData(true)">保存</view>
  85. <DialogBox ref="DialogBox"></DialogBox>
  86. <view class="popSel" v-if="showPop" @tap.stop="onPreview">
  87. <PageHeader title="添加标签" @back="showPop = false" :isBack="false" style="background: #f2f6f2;" />
  88. <view class="reserveASeat"></view>
  89. <view class="headLabel">
  90. <view class="avator-box">
  91. <CircleAvatar class="avator" :src="avator"></CircleAvatar>
  92. <view class="one-omit">{{ nickname }}</view>
  93. </view>
  94. <view class="tag-box">
  95. <view class="tag" v-for="(item, index) in sel_tags" :key="index">
  96. {{ item }}
  97. <image class="close" src="../../static/me/close.png" mode="widthFix" @click="delTag(item)" />
  98. </view>
  99. </view>
  100. </view>
  101. <view class="list_info">
  102. <view class="name">你的兴趣爱好是?</view>
  103. <view class="desc">提示:最多选择5个兴趣爱好标签</view>
  104. <view style="height: 700rpx; overflow-y: scroll; margin-top: 20rpx; padding-bottom: 100rpx;">
  105. <view class="add-tag-box" style="color: #000;" v-if="showAddTag">
  106. <input class="add-tag-input" v-model="newTag" placeholder="请输入标签名称" maxlength="10"
  107. @confirm="addCustomTag" />
  108. <view class="add-tag-btns">
  109. <text class="cancel-btn" @tap="cancelAddTag">取消</text>
  110. <text class="confirm-btn" @tap="addCustomTag">确定</text>
  111. </view>
  112. </view>
  113. <view class="item_tag">
  114. <view class="tag add-tag" @tap="showAddTagInput">
  115. <text>+ 自定义</text>
  116. </view>
  117. <view @tap.stop="chkTag(item)" class="tag" :class="selTags(item) ? 'active' : ''"
  118. v-for="(item, index) in list_tag" :key="index">
  119. {{ item }}
  120. </view>
  121. </view>
  122. </view>
  123. </view>
  124. <view class="btn_submit blick-btn-animation" @click="showPop = false;">提交选择</view>
  125. </view>
  126. <ToastW3 ref="ToastW3"></ToastW3>
  127. <!-- <view v-if="showRights"
  128. style="width:100%;height:300rpx;background-color: rgba(255,255,255,0.9);position: fixed;top:0;display: flex;flex-direction: column;justify-content: center;align-items: center;">
  129. <text
  130. style="width:90%;color:#000000;font-size:38rpx;text-align: left;padding:10rpx 20rpx;padding-top:10rpx;">正在获取相机、存储权限</text>
  131. <text
  132. style="width:90%;color:#666666;font-size:28rpx;text-align: left;padding:10rpx 20rpx;">该权限用于获取设备拍摄或获取本地应用相册,进行头像或图片上传。</text>
  133. </view> -->
  134. <view>
  135. <NicknamePopup title="编辑昵称" subtitle="" class="openNicknamePopUpWindow" ref="openNicknamePopUpWindow">
  136. <template v-slot:content>
  137. <view class="input-box">
  138. <uv-input placeholder="请输入昵称" border="surround" v-model="nickname" maxlength="12"></uv-input>
  139. <view class="length-indicator">{{ nickname.length }}/12</view>
  140. </view>
  141. <view class="btn-box" @click="submitData">保存</view>
  142. </template>
  143. </NicknamePopup>
  144. <NicknamePopup title="专属于你的简介" subtitle="好的简介让你在社区更受关注" class="openContentPopUpWindow"
  145. ref="openContentPopUpWindow">
  146. <template v-slot:content>
  147. <uv-textarea v-model="content" maxlength="50" count placeholder="请输入内容"></uv-textarea>
  148. <view class="btn-box" @click="submitData">保存</view>
  149. </template>
  150. </NicknamePopup>
  151. <NicknamePopup title="背景图" subtitle="" ref="backgroundImage" class="NicknamePopup-backgroundImage">
  152. <template v-slot:content>
  153. <view class="content">
  154. <view style="padding: 20rpx 0;">
  155. <uv-swiper :list="bgList" height="80" indicator :autoplay="false" keyName="url"
  156. :displayMultipleItems="2" next-margin="40" imgMode="aspectFit" :indicator="false"
  157. :current="currentBgIndex" @click="changeBgSwiper"
  158. style="width: 100%; overflow: hidden; background: transparent;" />
  159. </view>
  160. <view class="info_item" @click="chooseBgImage">
  161. <text class="label">上传背景图</text>
  162. <view class="content">
  163. <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix" />
  164. </view>
  165. </view>
  166. </view>
  167. </template>
  168. </NicknamePopup>
  169. </view>
  170. </view>
  171. </template>
  172. <script>
  173. import PageHeader from '@/components/PageHeader/PageHeader.vue';
  174. import CircleAvatar from '@/components/CircleAvatar/CircleAvatar.vue';
  175. import NicknamePopup from '@/components/NicknamePopup/NicknamePopup.vue';
  176. import permission from '@/common/permission.js';
  177. import uvSwiper from '@/uni_modules/uv-swiper/components/uv-swiper/uv-swiper.vue';
  178. export default {
  179. components: {
  180. PageHeader,
  181. CircleAvatar,
  182. NicknamePopup,
  183. uvSwiper
  184. },
  185. data() {
  186. return {
  187. showRights: false,
  188. title: '',
  189. sel: 1,
  190. info: {},
  191. showPop: false,
  192. nickname: '',
  193. content: '',
  194. sex: 1,
  195. age: 18,
  196. height: 160,
  197. weight: 50,
  198. avator: '../../static/me/avator.png',
  199. ziye: '',
  200. qianmin: '',
  201. bgImage: '',
  202. xinzuo_sel: '',
  203. xinzuo: ['水瓶座', '双鱼座', '白羊座', '金牛座', '双子座', '巨蟹座', '狮子座', '处女座', '天秤座', '天蝎座', '射手座', '摩羯座'],
  204. list_tag: [],
  205. sel_tags: [],
  206. sexText: '',
  207. birthday: '',
  208. sexOptions: ['男', '女', '其他'],
  209. endDate: new Date().toISOString().split('T')[0],
  210. showAddTag: false,
  211. newTag: '',
  212. bgList: [
  213. { url: require('../../static/me/theme1.jpg') },
  214. { url: require('../../static/me/theme2.jpg') },
  215. { url: require('../../static/me/theme3.jpg') },
  216. { url: require('../../static/me/theme4.jpg') },
  217. { url: require('../../static/me/theme5.jpg') },
  218. ],
  219. currentBgIndex: 0,
  220. uploading: false,
  221. }
  222. },
  223. onLoad() {
  224. let tagStr =
  225. "老二次元了、coser、沉迷音乐、网游小达人、AJ控、白日梦想家、撸铁狂魔、古风汉服、爱画画、数码极客、盲盒玩家、三坑玩家、动漫达人、设计师、爱卡通、兜风去、爱夜跑、街头滑板、球类运动、lo娘、rapper、时尚达人、机甲狂潮、养宠物、风轻云淡、养多肉、热爱自然、赛博朋克、骨子里高冷、爱唠嗑、资深中二、天然呆、思想家、极度抽象、学院派、平平无奇、热情奔放、博古通今、labubu粉、玛特收藏家";
  226. this.list_tag = tagStr.split("、");
  227. this.getInfoData();
  228. },
  229. onShow() { },
  230. methods: {
  231. open() {
  232. this.$refs.calendar.open();
  233. },
  234. confirm(e) {
  235. console.log(e);
  236. this.birthday = e.fulldate
  237. this.xinzuo_sel = this.getConstellation(this.birthday);
  238. },
  239. openNicknamePopUpWindow() {
  240. this.$refs.openNicknamePopUpWindow.open();
  241. },
  242. openContentPopUpWindow() {
  243. this.$refs.openContentPopUpWindow.open();
  244. },
  245. openBackgroundImage() {
  246. this.$refs.backgroundImage.open();
  247. },
  248. closePropUp() {
  249. this.$refs.openNicknamePopUpWindow.close();
  250. this.$refs.openContentPopUpWindow.close();
  251. this.$refs.backgroundImage.close();
  252. },
  253. onBack() { },
  254. onPreview() { },
  255. chkSel() {
  256. if (this.sel == 1) {
  257. this.sel = 0;
  258. } else {
  259. this.sel = 1;
  260. }
  261. },
  262. chkSex(sex) {
  263. this.sex = sex;
  264. },
  265. delTag(tg) {
  266. let list_tag2 = [];
  267. for (let i = 0; i < this.sel_tags.length; i++) {
  268. if (this.sel_tags[i] != tg) {
  269. list_tag2.push(this.sel_tags[i]);
  270. }
  271. }
  272. this.sel_tags = list_tag2;
  273. },
  274. selTags(itm) {
  275. let isIn = false;
  276. for (let entry of this.sel_tags) {
  277. if (entry == itm) {
  278. isIn = true;
  279. break;
  280. }
  281. }
  282. return isIn;
  283. },
  284. chkTag(itm) {
  285. if (this.selTags(itm)) {
  286. let tmpTags = [];
  287. for (let entry of this.sel_tags) {
  288. if (entry != itm) {
  289. tmpTags.push(entry);
  290. }
  291. }
  292. this.sel_tags = tmpTags;
  293. } else {
  294. if (this.sel_tags.length <= 4) {
  295. this.sel_tags.push(itm);
  296. } else {
  297. uni.showToast({
  298. title: "最多选择5个标签",
  299. icon: "none"
  300. });
  301. }
  302. }
  303. },
  304. sliderChange1(e) {
  305. this.age = e.detail.value;
  306. },
  307. sliderChange2(e) {
  308. this.height = e.detail.value;
  309. },
  310. sliderChange3(e) {
  311. this.weight = e.detail.value;
  312. },
  313. SetSex() {
  314. let that = this;
  315. uni.showActionSheet({
  316. itemColor: '#000000',
  317. itemList: this.sexOptions,
  318. success: function (res) {
  319. that.sexText = that.sexOptions[res.tapIndex];
  320. that.sex = res.tapIndex + 1;
  321. },
  322. fail: function (res) {
  323. console.log(res.errMsg);
  324. }
  325. });
  326. },
  327. getInfoData() {
  328. uni.request({
  329. url: this.$apiHost + '/Member/getinfoData',
  330. data: {
  331. uuid: getApp().globalData.uuid
  332. },
  333. header: {
  334. 'content-type': 'application/json'
  335. },
  336. success: (res) => {
  337. console.log(res.data);
  338. this.nickname = res.data.nickname;
  339. this.wechat = res.data.wechat;
  340. this.sex = res.data.sex;
  341. this.sexText = this.sexOptions[res.data.sex - 1] || '';
  342. this.birthday = res.data.birthday;
  343. this.content = res.data.content;
  344. this.xinzuo_sel = this.getConstellation(this.birthday);
  345. this.bgImage = res.data.bgimg;
  346. if (res.data.avator != "") {
  347. this.avator = res.data.avator;
  348. }
  349. if (res.data.aihao) {
  350. this.sel_tags = res.data.aihao.split(",");
  351. }
  352. }
  353. });
  354. },
  355. submitData(isBack) {
  356. let aihao = this.sel_tags.join(',')
  357. let obj2 = {
  358. uuid: getApp().globalData.uuid,
  359. avator: this.avator,
  360. nickname: this.nickname,
  361. content: this.content,
  362. sex: this.sex,
  363. birthday: this.birthday,
  364. xinzuo: this.xinzuo_sel,
  365. ziye: this.ziye,
  366. qianmin: this.qianmin,
  367. aihao: aihao,
  368. bgimg: this.bgImage
  369. }
  370. uni.request({
  371. url: this.$apiHost + '/Member/setinfoData',
  372. data: obj2,
  373. method: 'POST',
  374. header: {
  375. 'Content-Type': 'application/x-www-form-urlencoded',
  376. 'sign': getApp().globalData.headerSign
  377. },
  378. dataType: 'json',
  379. success: (res) => {
  380. console.log("res", res.data)
  381. uni.showToast({
  382. title: res.data.str,
  383. animation: 0,
  384. icon: "none"
  385. });
  386. if (res.data.success == 'yes' && isBack == true) {
  387. if (this.nickname) {
  388. getApp().globalData.nickname = this.nickname
  389. uni.removeStorageSync("nickname");
  390. uni.setStorageSync("nickname", this.nickname);
  391. }
  392. if (this.avator) {
  393. getApp().globalData.avator = this.avator
  394. uni.removeStorageSync("avator");
  395. uni.setStorageSync("avator", this.avator);
  396. }
  397. setTimeout(function () {
  398. uni.navigateBack()
  399. }, 800)
  400. } else {
  401. this.closePropUp()
  402. }
  403. this.getInfoData()
  404. }
  405. });
  406. },
  407. chooseAvatar() {
  408. uni.showActionSheet({
  409. itemList: ['拍照', '从相册选择'],
  410. success: (res) => {
  411. const sourceType = res.tapIndex === 0 ? 'camera' : 'album';
  412. this.chooseImage(sourceType);
  413. }
  414. });
  415. },
  416. async chooseImage(sourceType) {
  417. try {
  418. let hasPermission = false;
  419. if (sourceType === 'camera') {
  420. hasPermission = await this.checkCameraPermission();
  421. } else if (sourceType === 'album') {
  422. hasPermission = await this.checkPhotoLibraryPermission();
  423. }
  424. if (!hasPermission) {
  425. uni.showToast({
  426. title: '未获得权限',
  427. icon: 'none'
  428. });
  429. return;
  430. }
  431. uni.chooseImage({
  432. count: 1,
  433. sizeType: ['compressed'],
  434. sourceType: [sourceType],
  435. success: async (res) => {
  436. console.log('res:', res)
  437. if (res.tempFilePaths.length > 0) {
  438. const tempFilePath = res.tempFilePaths[0];
  439. console.log('tempFilePaths:', tempFilePath);
  440. await this.uploadImage(tempFilePath);
  441. }
  442. },
  443. fail: (err) => {
  444. console.error('选择图片失败:', err);
  445. uni.showToast({
  446. title: '选择图片失败',
  447. icon: 'none'
  448. });
  449. }
  450. });
  451. } catch (error) {
  452. console.error('权限检查失败:', error);
  453. uni.showToast({
  454. title: '权限检查失败',
  455. icon: 'none'
  456. });
  457. }
  458. },
  459. async checkCameraPermission() {
  460. const hasPermission = await permission.request(permission.PermissionType.CAMERA, {
  461. title: "“萌创星球”想访问你的相机",
  462. describe: "萌创星球想访问您的摄像头,便于拍摄获取图片来替换头像图片"
  463. });
  464. return hasPermission;
  465. },
  466. async checkPhotoLibraryPermission() {
  467. const hasPermission = await permission.request(permission.PermissionType.PHOTO_LIBRARY, {
  468. title: "“萌创星球”想访问你的照片图库",
  469. describe: "萌创星球想访问您本地照片图库,便于获取图片来替换头像图片"
  470. });
  471. return hasPermission;
  472. },
  473. uploadImage(tempFilePath) {
  474. var _self = this;
  475. const uploadTask = uni.uploadFile({
  476. url: _self.$apiHost + '/Xweb/upload_img?skey=' + _self.skey,
  477. filePath: tempFilePath,
  478. name: 'file',
  479. success: function (uploadFileRes) {
  480. let resdata = JSON.parse(uploadFileRes.data)
  481. console.log('Success11:', uploadFileRes);
  482. console.log('Success21:', resdata);
  483. if (resdata.success == 'yes') {
  484. _self.showRights = false;
  485. _self.avator = resdata.url;
  486. }
  487. },
  488. fail: function (uploadFileFail) {
  489. console.log('Error:', uploadFileFail.data);
  490. },
  491. complete: () => {
  492. console.log('Complete:');
  493. }
  494. });
  495. },
  496. onBirthdayChange(e) {
  497. this.birthday = e.detail.value;
  498. this.xinzuo_sel = this.getConstellation(this.birthday);
  499. },
  500. getConstellation(birthday) {
  501. if (!birthday) return '';
  502. const month = parseInt(birthday.split('-')[1]);
  503. const day = parseInt(birthday.split('-')[2]);
  504. // 星座日期范围数组,每个元素包含 [月份, 起始日期, 结束日期, 星座名称]
  505. const constellationRanges = [
  506. [1, 1, 19, "摩羯座"], // 1月1日-1月19日
  507. [1, 20, 31, "水瓶座"], // 1月20日-1月31日
  508. [2, 1, 18, "水瓶座"], // 2月1日-2月18日
  509. [2, 19, 29, "双鱼座"], // 2月19日-2月29日
  510. [3, 1, 20, "双鱼座"], // 3月1日-3月20日
  511. [3, 21, 31, "白羊座"], // 3月21日-3月31日
  512. [4, 1, 19, "白羊座"], // 4月1日-4月19日
  513. [4, 20, 30, "金牛座"], // 4月20日-4月30日
  514. [5, 1, 20, "金牛座"], // 5月1日-5月20日
  515. [5, 21, 31, "双子座"], // 5月21日-5月31日
  516. [6, 1, 21, "双子座"], // 6月1日-6月21日
  517. [6, 22, 30, "巨蟹座"], // 6月22日-6月30日
  518. [7, 1, 22, "巨蟹座"], // 7月1日-7月22日
  519. [7, 23, 31, "狮子座"], // 7月23日-7月31日
  520. [8, 1, 22, "狮子座"], // 8月1日-8月22日
  521. [8, 23, 31, "处女座"], // 8月23日-8月31日
  522. [9, 1, 22, "处女座"], // 9月1日-9月22日
  523. [9, 23, 30, "天秤座"], // 9月23日-9月30日
  524. [10, 1, 23, "天秤座"], // 10月1日-10月23日
  525. [10, 24, 31, "天蝎座"], // 10月24日-10月31日
  526. [11, 1, 22, "天蝎座"], // 11月1日-11月22日
  527. [11, 23, 30, "射手座"], // 11月23日-11月30日
  528. [12, 1, 21, "射手座"], // 12月1日-12月21日
  529. [12, 22, 31, "摩羯座"] // 12月22日-12月31日
  530. ];
  531. // 查找对应的星座
  532. for (const [m, startDay, endDay, constellation] of constellationRanges) {
  533. if (month === m && day >= startDay && day <= endDay) {
  534. return constellation;
  535. }
  536. }
  537. // 如果没找到匹配的星座(这种情况理论上不会发生,因为日期范围是连续的)
  538. return "未知星座";
  539. },
  540. showAddTagInput() {
  541. this.showAddTag = true;
  542. this.newTag = '';
  543. },
  544. cancelAddTag() {
  545. this.showAddTag = false;
  546. this.newTag = '';
  547. },
  548. addCustomTag() {
  549. if (!this.newTag.trim()) {
  550. uni.showToast({
  551. title: '请输入标签名称',
  552. icon: 'none'
  553. });
  554. return;
  555. }
  556. if (this.list_tag.includes(this.newTag)) {
  557. uni.showToast({
  558. title: '该标签已存在',
  559. icon: 'none'
  560. });
  561. return;
  562. }
  563. this.list_tag.unshift(this.newTag);
  564. this.showAddTag = false;
  565. this.newTag = '';
  566. },
  567. chooseBgImage() {
  568. uni.showActionSheet({
  569. itemList: ['拍照', '从相册选择'],
  570. success: (res) => {
  571. const sourceType = res.tapIndex === 0 ? 'camera' : 'album';
  572. this.checkRights(sourceType);
  573. }
  574. });
  575. },
  576. async checkRights(sourceType) {
  577. try {
  578. let hasPermission = false;
  579. if (sourceType === 'camera') {
  580. hasPermission = await permission.request(permission.PermissionType.CAMERA, {
  581. title: '"萌创星球"想访问你的相机',
  582. describe: '萌创星球想访问您的摄像头,便于拍摄获取图片来替换背景图片'
  583. });
  584. if (!hasPermission) {
  585. uni.showToast({
  586. title: '未获得相机权限',
  587. icon: 'none'
  588. });
  589. return;
  590. }
  591. } else {
  592. hasPermission = await permission.request(permission.PermissionType.PHOTO_LIBRARY, {
  593. title: '"萌创星球"想访问你的照片图库',
  594. describe: '萌创星球想访问您本地照片图库,便于获取图片来替换背景图片'
  595. });
  596. if (!hasPermission) {
  597. uni.showToast({
  598. title: '未获得相册权限',
  599. icon: 'none'
  600. });
  601. return;
  602. }
  603. }
  604. // 权限获取成功后,继续执行上传
  605. if (this.uploading) {
  606. return;
  607. }
  608. this.uploading = true;
  609. uni.showLoading({
  610. title: '上传中...',
  611. mask: true
  612. });
  613. this.uploadBgImage(sourceType);
  614. } catch (error) {
  615. console.error('权限检查失败:', error);
  616. uni.showToast({
  617. title: '权限检查失败',
  618. icon: 'none'
  619. });
  620. }
  621. },
  622. uploadBgImage(sourceType) {
  623. var _self = this;
  624. uni.chooseImage({
  625. count: 1,
  626. sizeType: ['compressed'],
  627. sourceType: [sourceType],
  628. success: function (res) {
  629. console.log('res:', res)
  630. if (res.tempFilePaths.length > 0) {
  631. let filepath = "";
  632. // #ifdef H5
  633. filepath = res.tempFiles[0].path;
  634. // #endif
  635. // #ifdef APP-PLUS
  636. filepath = res.tempFilePaths[0];
  637. // #endif
  638. console.log('filepath:', filepath);
  639. const uploadTask = uni.uploadFile({
  640. url: _self.$apiHost + '/Xweb/upload_img?skey=' + _self.skey,
  641. filePath: filepath,
  642. name: 'file',
  643. success: function (uploadFileRes) {
  644. let resdata = JSON.parse(uploadFileRes.data)
  645. console.log('Success:', resdata);
  646. if (resdata.success == 'yes') {
  647. _self.bgImage = resdata.url;
  648. _self.closePropUp();
  649. uni.showToast({
  650. title: '上传成功',
  651. icon: 'success'
  652. });
  653. } else {
  654. uni.showToast({
  655. title: resdata.str || '上传失败',
  656. icon: 'none'
  657. });
  658. }
  659. },
  660. fail: function (uploadFileFail) {
  661. console.log('Error:', uploadFileFail.data);
  662. uni.showToast({
  663. title: '上传失败',
  664. icon: 'none'
  665. });
  666. },
  667. complete: () => {
  668. console.log('Complete:');
  669. uni.hideLoading();
  670. this.uploading = false;
  671. }
  672. });
  673. }
  674. },
  675. fail: function (err) {
  676. console.log('选择图片失败:', err);
  677. uni.showToast({
  678. title: '选择图片失败',
  679. icon: 'none'
  680. });
  681. }
  682. });
  683. },
  684. changeBgSwiper(index) {
  685. if (this.uploading) {
  686. return;
  687. }
  688. this.uploading = true;
  689. uni.showLoading({
  690. title: '上传中...',
  691. mask: true
  692. });
  693. if (typeof index === 'number') {
  694. this.currentBgIndex = index;
  695. this.bgImage = this.bgList[index].url;
  696. // 上传选中的背景图片
  697. this.uploadBgImage1(this.bgList[index].url);
  698. }
  699. },
  700. uploadBgImage1(filepath) {
  701. var _self = this;
  702. const uploadTask = uni.uploadFile({
  703. url: _self.$apiHost + '/Xweb/upload_img?skey=' + _self.skey,
  704. filePath: filepath,
  705. name: 'file',
  706. success: function (uploadFileRes) {
  707. let resdata = JSON.parse(uploadFileRes.data)
  708. console.log('Success:', resdata);
  709. if (resdata.success == 'yes') {
  710. _self.bgImage = resdata.url;
  711. _self.closePropUp();
  712. uni.showToast({
  713. title: '上传成功',
  714. icon: 'success'
  715. });
  716. } else {
  717. uni.showToast({
  718. title: resdata.str || '上传失败',
  719. icon: 'none'
  720. });
  721. }
  722. },
  723. fail: function (uploadFileFail) {
  724. console.log('Error:', uploadFileFail.data);
  725. uni.showToast({
  726. title: '上传失败',
  727. icon: 'none'
  728. });
  729. },
  730. complete: () => {
  731. console.log('Complete:');
  732. uni.hideLoading();
  733. this.uploading = false;
  734. }
  735. });
  736. },
  737. }
  738. }
  739. </script>
  740. <style scoped lang="scss">
  741. @import 'normal.scss';
  742. page {
  743. font-family: PingFang SC-Medium;
  744. // background: url("../../static/me/wd_bg_bianjiziliao.png") center top / 100%
  745. // auto no-repeat,
  746. // #f2f6f2;
  747. }
  748. page {
  749. background: #000 !important;
  750. }
  751. .popSel {
  752. position: fixed;
  753. z-index: 101;
  754. top: 0;
  755. left: 0;
  756. background-color: #f2f6f2;
  757. width: 100vh;
  758. min-height: 100vh;
  759. .headLabel {
  760. width: 686rpx;
  761. margin: 28rpx 32rpx;
  762. min-height: 222rpx;
  763. background: #fff;
  764. box-sizing: border-box;
  765. padding: 30rpx 40rpx 46rpx 20rpx;
  766. border-radius: 20rpx;
  767. .avator-box {
  768. display: flex;
  769. align-items: center;
  770. .avator {
  771. width: 80rpx;
  772. height: 80rpx;
  773. margin-right: 20rpx;
  774. }
  775. }
  776. .tag-box {
  777. display: flex;
  778. flex-direction: row;
  779. justify-content: flex-start;
  780. align-items: center;
  781. flex-wrap: wrap;
  782. font-size: 24rpx;
  783. .tag {
  784. margin-right: 16rpx;
  785. margin-top: 20rpx;
  786. padding: 6rpx 10rpx;
  787. border: 2rpx solid #DCE1DC;
  788. color: #9E9E9E;
  789. display: flex;
  790. justify-content: center;
  791. align-items: center;
  792. border-radius: 42rpx;
  793. line-height: 1;
  794. .close {
  795. width: 20rpx;
  796. margin-left: 12rpx;
  797. position: relative;
  798. }
  799. }
  800. }
  801. }
  802. }
  803. .openNicknamePopUpWindow {
  804. .length-indicator {
  805. font-size: 24rpx;
  806. color: #999;
  807. text-align: right;
  808. margin-top: 10rpx;
  809. margin-right: 20rpx;
  810. position: absolute;
  811. right: 24rpx;
  812. top: 24rpx;
  813. }
  814. }
  815. .popSel {
  816. .item_tag {
  817. display: flex;
  818. flex-direction: row;
  819. justify-content: flex-start;
  820. align-items: center;
  821. flex-wrap: wrap;
  822. width: 690rpx;
  823. padding: 20rpx;
  824. .tag {
  825. border-radius: 94rpx;
  826. margin-right: 10rpx;
  827. margin-top: 10rpx;
  828. padding: 8rpx 16rpx;
  829. font-size: 28rpx;
  830. color: #333;
  831. display: flex;
  832. flex-direction: row;
  833. justify-content: center;
  834. align-items: center;
  835. background: #fff;
  836. border-width: 0;
  837. .close {
  838. width: 28rpx;
  839. margin-left: 2rpx;
  840. position: relative;
  841. }
  842. }
  843. .active {
  844. border-width: 0;
  845. background: #ACF934;
  846. }
  847. .addNew {
  848. margin-right: 10rpx;
  849. margin-top: 10rpx;
  850. padding: 0rpx 20rpx;
  851. height: 60rpx;
  852. border-radius: 12rpx;
  853. background: #1f1f1f;
  854. color: #fff;
  855. display: flex;
  856. flex-direction: row;
  857. justify-content: center;
  858. align-items: center;
  859. }
  860. }
  861. }
  862. .reserveASeat {
  863. width: 100%;
  864. height: calc(var(--status-bar-height) + 50rpx);
  865. }
  866. .page {
  867. background: url("../../static/me/wd_bg_bianjiziliao.png") top center/ 100% auto no-repeat,
  868. #f2f6f2;
  869. }
  870. .PageHeader {
  871. background: url("../../static/me/wd_bg_bianjiziliao.png") center top / 100% auto no-repeat,
  872. #f2f6f2;
  873. // background-position-y: var(--status-bar-height);
  874. z-index: 99 !important;
  875. }
  876. .add-tag-box {
  877. background: #fff;
  878. padding: 20rpx;
  879. margin: 20rpx;
  880. border-radius: 12rpx;
  881. .add-tag-input {
  882. width: 100%;
  883. height: 80rpx;
  884. background: #f5f5f5;
  885. border-radius: 8rpx;
  886. padding: 0 20rpx;
  887. font-size: 28rpx;
  888. margin-bottom: 20rpx;
  889. }
  890. .add-tag-btns {
  891. display: flex;
  892. justify-content: flex-end;
  893. gap: 20rpx;
  894. .cancel-btn,
  895. .confirm-btn {
  896. padding: 10rpx 30rpx;
  897. border-radius: 8rpx;
  898. font-size: 28rpx;
  899. }
  900. .cancel-btn {
  901. background: #f5f5f5;
  902. color: #666;
  903. }
  904. .confirm-btn {
  905. background: #1f1f1f;
  906. color: #fff;
  907. }
  908. }
  909. }
  910. .item_tag {
  911. .add-tag {
  912. background: #f5f5f5;
  913. color: #666;
  914. border: 2rpx dashed #ddd;
  915. &:active {
  916. background: #e5e5e5;
  917. }
  918. }
  919. }
  920. .backgroundImage {
  921. width: 88rpx;
  922. height: 50rpx;
  923. border-radius: 4rpx;
  924. }
  925. .upload-bg-btn {
  926. width: 100%;
  927. height: 80rpx;
  928. background: #1f1f1f;
  929. color: #fff;
  930. border-radius: 12rpx;
  931. font-size: 32rpx;
  932. margin: 0 auto;
  933. display: block;
  934. }
  935. .NicknamePopup-backgroundImage {
  936. .info_item {
  937. height: 100rpx;
  938. display: flex;
  939. align-items: center;
  940. padding: 0 30rpx;
  941. border-bottom: 1rpx solid #f5f5f5;
  942. padding-right: 20rpx;
  943. background: #fff;
  944. border-radius: 12rpx;
  945. &:last-child {
  946. border-bottom: none;
  947. }
  948. .label {
  949. width: 160rpx;
  950. font-size: 28rpx;
  951. color: #1f1f1f;
  952. font-family: "PingFang SC-Medium";
  953. }
  954. .content {
  955. flex: 1;
  956. display: flex;
  957. align-items: center;
  958. justify-content: flex-end;
  959. input {
  960. text-align: right;
  961. font-size: 28rpx;
  962. color: #333;
  963. }
  964. .arrow {
  965. width: 36rpx;
  966. margin-left: 10rpx;
  967. }
  968. }
  969. }
  970. ::v-deep .uv-popup__content {
  971. background: #f2f6f2 !important;
  972. }
  973. ::v-deep .uv-swiper__wrapper__item__wrapper__image {
  974. border-radius: 20rpx !important;
  975. }
  976. .content {
  977. padding: 0 32rpx;
  978. }
  979. }
  980. </style>