editInfo.vue 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073
  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. if (plus.os.name.toLowerCase() === 'android') {
  429. let hasPermission = false;
  430. if (sourceType === 'camera') {
  431. hasPermission = await this.checkCameraPermission();
  432. } else if (sourceType === 'album') {
  433. hasPermission = await this.checkPhotoLibraryPermission();
  434. }
  435. if (!hasPermission) {
  436. uni.showToast({
  437. title: '未获得权限',
  438. icon: 'none'
  439. });
  440. return;
  441. }
  442. } else {
  443. }
  444. uni.chooseImage({
  445. count: 1,
  446. sizeType: ['compressed'],
  447. sourceType: [sourceType],
  448. success: async (res) => {
  449. console.log('res:', res)
  450. if (res.tempFilePaths.length > 0) {
  451. const tempFilePath = res.tempFilePaths[0];
  452. console.log('tempFilePaths:', tempFilePath);
  453. await this.uploadImage(tempFilePath);
  454. }
  455. },
  456. fail: (err) => {
  457. console.error('选择图片失败:', err);
  458. uni.showToast({
  459. title: '选择图片失败',
  460. icon: 'none'
  461. });
  462. }
  463. });
  464. } catch (error) {
  465. console.error('权限检查失败:', error);
  466. uni.showToast({
  467. title: '权限检查失败',
  468. icon: 'none'
  469. });
  470. }
  471. },
  472. async checkCameraPermission() {
  473. const hasPermission = await permission.request(permission.PermissionType.CAMERA, {
  474. title: "“萌创星球”想访问你的相机",
  475. describe: "萌创星球想访问您的摄像头,便于拍摄获取图片来替换头像图片"
  476. });
  477. return hasPermission;
  478. },
  479. async checkPhotoLibraryPermission() {
  480. const hasPermission = await permission.request(permission.PermissionType.PHOTO_LIBRARY, {
  481. title: "“萌创星球”想访问你的照片图库",
  482. describe: "萌创星球想访问您本地照片图库,便于获取图片来替换头像图片"
  483. });
  484. return hasPermission;
  485. },
  486. uploadImage(tempFilePath) {
  487. var _self = this;
  488. const uploadTask = uni.uploadFile({
  489. url: _self.$apiHost + '/Xweb/upload_img?skey=' + _self.skey,
  490. filePath: tempFilePath,
  491. name: 'file',
  492. success: function(uploadFileRes) {
  493. let resdata = JSON.parse(uploadFileRes.data)
  494. console.log('Success11:', uploadFileRes);
  495. console.log('Success21:', resdata);
  496. if (resdata.success == 'yes') {
  497. _self.showRights = false;
  498. _self.avator = resdata.url;
  499. }
  500. },
  501. fail: function(uploadFileFail) {
  502. console.log('Error:', uploadFileFail.data);
  503. },
  504. complete: () => {
  505. console.log('Complete:');
  506. }
  507. });
  508. },
  509. onBirthdayChange(e) {
  510. this.birthday = e.detail.value;
  511. this.xinzuo_sel = this.getConstellation(this.birthday);
  512. },
  513. getConstellation(birthday) {
  514. if (!birthday) return '';
  515. const month = parseInt(birthday.split('-')[1]);
  516. const day = parseInt(birthday.split('-')[2]);
  517. // 星座日期范围数组,每个元素包含 [月份, 起始日期, 结束日期, 星座名称]
  518. const constellationRanges = [
  519. [1, 1, 19, "摩羯座"], // 1月1日-1月19日
  520. [1, 20, 31, "水瓶座"], // 1月20日-1月31日
  521. [2, 1, 18, "水瓶座"], // 2月1日-2月18日
  522. [2, 19, 29, "双鱼座"], // 2月19日-2月29日
  523. [3, 1, 20, "双鱼座"], // 3月1日-3月20日
  524. [3, 21, 31, "白羊座"], // 3月21日-3月31日
  525. [4, 1, 19, "白羊座"], // 4月1日-4月19日
  526. [4, 20, 30, "金牛座"], // 4月20日-4月30日
  527. [5, 1, 20, "金牛座"], // 5月1日-5月20日
  528. [5, 21, 31, "双子座"], // 5月21日-5月31日
  529. [6, 1, 21, "双子座"], // 6月1日-6月21日
  530. [6, 22, 30, "巨蟹座"], // 6月22日-6月30日
  531. [7, 1, 22, "巨蟹座"], // 7月1日-7月22日
  532. [7, 23, 31, "狮子座"], // 7月23日-7月31日
  533. [8, 1, 22, "狮子座"], // 8月1日-8月22日
  534. [8, 23, 31, "处女座"], // 8月23日-8月31日
  535. [9, 1, 22, "处女座"], // 9月1日-9月22日
  536. [9, 23, 30, "天秤座"], // 9月23日-9月30日
  537. [10, 1, 23, "天秤座"], // 10月1日-10月23日
  538. [10, 24, 31, "天蝎座"], // 10月24日-10月31日
  539. [11, 1, 22, "天蝎座"], // 11月1日-11月22日
  540. [11, 23, 30, "射手座"], // 11月23日-11月30日
  541. [12, 1, 21, "射手座"], // 12月1日-12月21日
  542. [12, 22, 31, "摩羯座"] // 12月22日-12月31日
  543. ];
  544. // 查找对应的星座
  545. for (const [m, startDay, endDay, constellation] of constellationRanges) {
  546. if (month === m && day >= startDay && day <= endDay) {
  547. return constellation;
  548. }
  549. }
  550. // 如果没找到匹配的星座(这种情况理论上不会发生,因为日期范围是连续的)
  551. return "未知星座";
  552. },
  553. showAddTagInput() {
  554. this.showAddTag = true;
  555. this.newTag = '';
  556. },
  557. cancelAddTag() {
  558. this.showAddTag = false;
  559. this.newTag = '';
  560. },
  561. addCustomTag() {
  562. if (!this.newTag.trim()) {
  563. uni.showToast({
  564. title: '请输入标签名称',
  565. icon: 'none'
  566. });
  567. return;
  568. }
  569. if (this.list_tag.includes(this.newTag)) {
  570. uni.showToast({
  571. title: '该标签已存在',
  572. icon: 'none'
  573. });
  574. return;
  575. }
  576. this.list_tag.unshift(this.newTag);
  577. this.showAddTag = false;
  578. this.newTag = '';
  579. },
  580. chooseBgImage() {
  581. uni.showActionSheet({
  582. itemList: ['拍照', '从相册选择'],
  583. success: (res) => {
  584. const sourceType = res.tapIndex === 0 ? 'camera' : 'album';
  585. this.checkRights(sourceType);
  586. }
  587. });
  588. },
  589. async checkRights(sourceType) {
  590. try {
  591. let hasPermission = false;
  592. if (sourceType === 'camera') {
  593. hasPermission = await permission.request(permission.PermissionType.CAMERA, {
  594. title: '"萌创星球"想访问你的相机',
  595. describe: '萌创星球想访问您的摄像头,便于拍摄获取图片来替换背景图片'
  596. });
  597. if (!hasPermission) {
  598. uni.showToast({
  599. title: '未获得相机权限',
  600. icon: 'none'
  601. });
  602. return;
  603. }
  604. } else {
  605. hasPermission = await permission.request(permission.PermissionType.PHOTO_LIBRARY, {
  606. title: '"萌创星球"想访问你的照片图库',
  607. describe: '萌创星球想访问您本地照片图库,便于获取图片来替换背景图片'
  608. });
  609. if (!hasPermission) {
  610. uni.showToast({
  611. title: '未获得相册权限',
  612. icon: 'none'
  613. });
  614. return;
  615. }
  616. }
  617. // 权限获取成功后,继续执行上传
  618. if (this.uploading) {
  619. return;
  620. }
  621. this.uploading = true;
  622. uni.showLoading({
  623. title: '上传中...',
  624. mask: true
  625. });
  626. this.uploadBgImage(sourceType);
  627. } catch (error) {
  628. console.error('权限检查失败:', error);
  629. uni.showToast({
  630. title: '权限检查失败',
  631. icon: 'none'
  632. });
  633. }
  634. },
  635. uploadBgImage(sourceType) {
  636. var _self = this;
  637. uni.chooseImage({
  638. count: 1,
  639. sizeType: ['compressed'],
  640. sourceType: [sourceType],
  641. success: function(res) {
  642. console.log('res:', res)
  643. if (res.tempFilePaths.length > 0) {
  644. let filepath = "";
  645. // #ifdef H5
  646. filepath = res.tempFiles[0].path;
  647. // #endif
  648. // #ifdef APP-PLUS
  649. filepath = res.tempFilePaths[0];
  650. // #endif
  651. console.log('filepath:', filepath);
  652. const uploadTask = uni.uploadFile({
  653. url: _self.$apiHost + '/Xweb/upload_img?skey=' + _self.skey,
  654. filePath: filepath,
  655. name: 'file',
  656. success: function(uploadFileRes) {
  657. let resdata = JSON.parse(uploadFileRes.data)
  658. console.log('Success:', resdata);
  659. if (resdata.success == 'yes') {
  660. _self.bgImage = resdata.url;
  661. _self.closePropUp();
  662. uni.showToast({
  663. title: '上传成功',
  664. icon: 'success'
  665. });
  666. } else {
  667. uni.showToast({
  668. title: resdata.str || '上传失败',
  669. icon: 'none'
  670. });
  671. }
  672. },
  673. fail: function(uploadFileFail) {
  674. console.log('Error:', uploadFileFail.data);
  675. uni.showToast({
  676. title: '上传失败',
  677. icon: 'none'
  678. });
  679. },
  680. complete: () => {
  681. console.log('Complete:');
  682. uni.hideLoading();
  683. this.uploading = false;
  684. }
  685. });
  686. }
  687. },
  688. fail: function(err) {
  689. console.log('选择图片失败:', err);
  690. uni.showToast({
  691. title: '选择图片失败',
  692. icon: 'none'
  693. });
  694. }
  695. });
  696. },
  697. changeBgSwiper(index) {
  698. if (this.uploading) {
  699. return;
  700. }
  701. this.uploading = true;
  702. uni.showLoading({
  703. title: '上传中...',
  704. mask: true
  705. });
  706. if (typeof index === 'number') {
  707. this.currentBgIndex = index;
  708. this.bgImage = this.bgList[index].url;
  709. // 上传选中的背景图片
  710. this.uploadBgImage1(this.bgList[index].url);
  711. }
  712. },
  713. uploadBgImage1(filepath) {
  714. var _self = this;
  715. const uploadTask = uni.uploadFile({
  716. url: _self.$apiHost + '/Xweb/upload_img?skey=' + _self.skey,
  717. filePath: filepath,
  718. name: 'file',
  719. success: function(uploadFileRes) {
  720. let resdata = JSON.parse(uploadFileRes.data)
  721. console.log('Success:', resdata);
  722. if (resdata.success == 'yes') {
  723. _self.bgImage = resdata.url;
  724. _self.closePropUp();
  725. uni.showToast({
  726. title: '上传成功',
  727. icon: 'success'
  728. });
  729. } else {
  730. uni.showToast({
  731. title: resdata.str || '上传失败',
  732. icon: 'none'
  733. });
  734. }
  735. },
  736. fail: function(uploadFileFail) {
  737. console.log('Error:', uploadFileFail.data);
  738. uni.showToast({
  739. title: '上传失败',
  740. icon: 'none'
  741. });
  742. },
  743. complete: () => {
  744. console.log('Complete:');
  745. uni.hideLoading();
  746. this.uploading = false;
  747. }
  748. });
  749. },
  750. }
  751. }
  752. </script>
  753. <style scoped lang="scss">
  754. @import 'normal.scss';
  755. page {
  756. font-family: PingFang SC-Medium;
  757. // background: url("../../static/me/wd_bg_bianjiziliao.png") center top / 100%
  758. // auto no-repeat,
  759. // #f2f6f2;
  760. }
  761. page {
  762. background: #000 !important;
  763. }
  764. .popSel {
  765. position: fixed;
  766. z-index: 101;
  767. top: 0;
  768. left: 0;
  769. background-color: #f2f6f2;
  770. width: 100vh;
  771. min-height: 100vh;
  772. .headLabel {
  773. width: 686rpx;
  774. margin: 28rpx 32rpx;
  775. min-height: 222rpx;
  776. background: #fff;
  777. box-sizing: border-box;
  778. padding: 30rpx 40rpx 46rpx 20rpx;
  779. border-radius: 20rpx;
  780. .avator-box {
  781. display: flex;
  782. align-items: center;
  783. .avator {
  784. width: 80rpx;
  785. height: 80rpx;
  786. margin-right: 20rpx;
  787. }
  788. }
  789. .tag-box {
  790. display: flex;
  791. flex-direction: row;
  792. justify-content: flex-start;
  793. align-items: center;
  794. flex-wrap: wrap;
  795. font-size: 24rpx;
  796. .tag {
  797. margin-right: 16rpx;
  798. margin-top: 20rpx;
  799. padding: 6rpx 10rpx;
  800. border: 2rpx solid #DCE1DC;
  801. color: #9E9E9E;
  802. display: flex;
  803. justify-content: center;
  804. align-items: center;
  805. border-radius: 42rpx;
  806. line-height: 1;
  807. .close {
  808. width: 20rpx;
  809. margin-left: 12rpx;
  810. position: relative;
  811. }
  812. }
  813. }
  814. }
  815. }
  816. .openNicknamePopUpWindow {
  817. .length-indicator {
  818. font-size: 24rpx;
  819. color: #999;
  820. text-align: right;
  821. margin-top: 10rpx;
  822. margin-right: 20rpx;
  823. position: absolute;
  824. right: 24rpx;
  825. top: 24rpx;
  826. }
  827. }
  828. .popSel {
  829. .item_tag {
  830. display: flex;
  831. flex-direction: row;
  832. justify-content: flex-start;
  833. align-items: center;
  834. flex-wrap: wrap;
  835. width: 690rpx;
  836. padding: 20rpx;
  837. .tag {
  838. border-radius: 94rpx;
  839. margin-right: 10rpx;
  840. margin-top: 10rpx;
  841. padding: 8rpx 16rpx;
  842. font-size: 28rpx;
  843. color: #333;
  844. display: flex;
  845. flex-direction: row;
  846. justify-content: center;
  847. align-items: center;
  848. background: #fff;
  849. border-width: 0;
  850. .close {
  851. width: 28rpx;
  852. margin-left: 2rpx;
  853. position: relative;
  854. }
  855. }
  856. .active {
  857. border-width: 0;
  858. background: #ACF934;
  859. }
  860. .addNew {
  861. margin-right: 10rpx;
  862. margin-top: 10rpx;
  863. padding: 0rpx 20rpx;
  864. height: 60rpx;
  865. border-radius: 12rpx;
  866. background: #1f1f1f;
  867. color: #fff;
  868. display: flex;
  869. flex-direction: row;
  870. justify-content: center;
  871. align-items: center;
  872. }
  873. }
  874. }
  875. .reserveASeat {
  876. width: 100%;
  877. height: calc(var(--status-bar-height) + 50rpx);
  878. }
  879. .page {
  880. background: url("../../static/me/wd_bg_bianjiziliao.png") top center/ 100% auto no-repeat,
  881. #f2f6f2;
  882. }
  883. .PageHeader {
  884. background: url("../../static/me/wd_bg_bianjiziliao.png") center top / 100% auto no-repeat,
  885. #f2f6f2;
  886. // background-position-y: var(--status-bar-height);
  887. z-index: 99 !important;
  888. }
  889. .add-tag-box {
  890. background: #fff;
  891. padding: 20rpx;
  892. margin: 20rpx;
  893. border-radius: 12rpx;
  894. .add-tag-input {
  895. width: 100%;
  896. height: 80rpx;
  897. background: #f5f5f5;
  898. border-radius: 8rpx;
  899. padding: 0 20rpx;
  900. font-size: 28rpx;
  901. margin-bottom: 20rpx;
  902. }
  903. .add-tag-btns {
  904. display: flex;
  905. justify-content: flex-end;
  906. gap: 20rpx;
  907. .cancel-btn,
  908. .confirm-btn {
  909. padding: 10rpx 30rpx;
  910. border-radius: 8rpx;
  911. font-size: 28rpx;
  912. }
  913. .cancel-btn {
  914. background: #f5f5f5;
  915. color: #666;
  916. }
  917. .confirm-btn {
  918. background: #1f1f1f;
  919. color: #fff;
  920. }
  921. }
  922. }
  923. .item_tag {
  924. .add-tag {
  925. background: #f5f5f5;
  926. color: #666;
  927. border: 2rpx dashed #ddd;
  928. &:active {
  929. background: #e5e5e5;
  930. }
  931. }
  932. }
  933. .backgroundImage {
  934. width: 88rpx;
  935. height: 50rpx;
  936. border-radius: 4rpx;
  937. }
  938. .upload-bg-btn {
  939. width: 100%;
  940. height: 80rpx;
  941. background: #1f1f1f;
  942. color: #fff;
  943. border-radius: 12rpx;
  944. font-size: 32rpx;
  945. margin: 0 auto;
  946. display: block;
  947. }
  948. .NicknamePopup-backgroundImage {
  949. .info_item {
  950. height: 100rpx;
  951. display: flex;
  952. align-items: center;
  953. padding: 0 30rpx;
  954. border-bottom: 1rpx solid #f5f5f5;
  955. padding-right: 20rpx;
  956. background: #fff;
  957. border-radius: 12rpx;
  958. &:last-child {
  959. border-bottom: none;
  960. }
  961. .label {
  962. width: 160rpx;
  963. font-size: 28rpx;
  964. color: #1f1f1f;
  965. font-family: "PingFang SC-Medium";
  966. }
  967. .content {
  968. flex: 1;
  969. display: flex;
  970. align-items: center;
  971. justify-content: flex-end;
  972. input {
  973. text-align: right;
  974. font-size: 28rpx;
  975. color: #333;
  976. }
  977. .arrow {
  978. width: 36rpx;
  979. margin-left: 10rpx;
  980. }
  981. }
  982. }
  983. ::v-deep .uv-popup__content {
  984. background: #f2f6f2 !important;
  985. }
  986. ::v-deep .uv-swiper__wrapper__item__wrapper__image {
  987. border-radius: 20rpx !important;
  988. }
  989. .content {
  990. padding: 0 32rpx;
  991. }
  992. }
  993. </style>