editInfo.vue 27 KB

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