editInfo.vue 29 KB

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