VIP.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <template>
  2. <view class="level-container">
  3. <!-- 顶部会员信息区域 -->
  4. <view class="vip-info">
  5. <view class="flex-between vip-box">
  6. <view class="flex_2">
  7. <view class="flex-between">
  8. <view class="vip-text">
  9. <view class="vip-title">VIP会员</view>
  10. <view class="vip-desc"
  11. >会员等级 {{ appStore?.$userInfo?.level || 0 }}</view
  12. >
  13. </view>
  14. <view class="point-info">
  15. <text class="point-text">{{
  16. appStore?.$userInfo?.integral || 0
  17. }}</text>
  18. <text class="point-desc">会员贝币</text>
  19. </view>
  20. </view>
  21. <view>
  22. <view class="growth-info">
  23. <text>成长值 {{ appStore?.$userInfo?.experience || 0 }}</text>
  24. <text class="growth-progress">
  25. {{ appStore?.$userInfo?.experience || 0 }}/{{
  26. appStore?.$userInfo?.experienceCount || 0
  27. }}
  28. </text>
  29. </view>
  30. <up-line-progress
  31. :percentage="percentExperience"
  32. activeColor="#d6c3a3"
  33. inactiveColor="#808080"
  34. height="6"
  35. :showText="false"
  36. ></up-line-progress>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="vip-benefit">
  42. <!-- VIP尊享权益区域 -->
  43. <view class="vip-benefit-title">VIP尊享权益</view>
  44. <view class="benefit-content">
  45. <view class="benefit-list">
  46. <view
  47. class="benefit-item"
  48. v-for="(item, index) in benefitList"
  49. :key="index"
  50. >
  51. <image :src="item.icon" class="benefit-icon"></image>
  52. <text class="benefit-text">{{ item.text }}</text>
  53. </view>
  54. </view>
  55. <view class="benefit-desc">
  56. <view>当前已解锁权益:</view>
  57. <view>
  58. 买金-<text>{{ appStore.$userInfo?.buy || 0 }}</text
  59. >元/克
  60. </view>
  61. <view>
  62. 回收+<text
  63. ><text>{{ appStore.$userInfo?.sold || 0 }}</text></text
  64. >元/克
  65. </view>
  66. <view>
  67. 购物折扣:<text>{{ appStore.$userInfo?.discount || "无" }}</text
  68. >折
  69. </view>
  70. </view>
  71. </view>
  72. <!-- 做任务赚成长值/贝币区域 -->
  73. <view class="task-title">做任务赚成长值/贝币</view>
  74. <view class="task-item" v-for="(task, index) in taskList" :key="index">
  75. <view class="task-desc">
  76. <text class="task-name">{{ task.name }}</text>
  77. <text class="task-reward">{{ task.reward }}</text>
  78. </view>
  79. <view class="submit-btn">
  80. <up-button
  81. v-if="!appStore.$wxConfig?.auditModeEnabled"
  82. @click="toPages(task)"
  83. type="warning"
  84. :text="task.btnText"
  85. size="mini"
  86. shape="circle"
  87. ></up-button>
  88. </view>
  89. </view>
  90. </view>
  91. <!-- vip成长系统 -->
  92. <view class="vip-level-box">
  93. <view class="vip-level-title">会员成长系统</view>
  94. <view class="title-box">
  95. <view class="title-item">等级</view>
  96. <view class="title-item">图标</view>
  97. <view class="title-item">成长值</view>
  98. <view class="title-item">权益</view>
  99. </view>
  100. <scroll-view class="title-content" :scroll-y="true">
  101. <view
  102. class="content-list"
  103. v-for="(item, index) in leveList"
  104. :key="index"
  105. >
  106. <view class="content-item">{{ index + 1 }}</view>
  107. <view class="content-item">
  108. <image mode="heightFix" :src="item.icon"></image>
  109. </view>
  110. <view class="content-item">{{ item.experience }}</view>
  111. <view class="content-item quanyi" style="width: 27%">
  112. <text
  113. >买金- <text class="gw"> {{ item.buy }}元/克</text>
  114. </text>
  115. <text>
  116. 卖金+<text class="gw"> {{ item.sold }}元/克</text>
  117. </text>
  118. <text
  119. >购物 :<text class="gw zk">{{ item.discount }} 折</text></text
  120. >
  121. </view>
  122. </view>
  123. <veiw class="content-desc">
  124. 以上显示{{ leveList.length }}级,继续努力,更多等级权益等你探索~
  125. </veiw>
  126. </scroll-view>
  127. </view>
  128. <!-- 邀请新人弹窗 -->
  129. <up-popup
  130. :show="showInvite"
  131. closeOnClickOverlay
  132. mode="center"
  133. @close="showInvite = !showInvite"
  134. >
  135. <view class="upopup-box">
  136. <image
  137. style="width: 100%"
  138. src="https://sb-admin.oss-cn-shenzhen.aliyuncs.com/shuibei-mini/Invite/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20250807170542.jpg"
  139. mode="widthFix"
  140. showMenuByLongpress
  141. ></image>
  142. <button open-type="share" class="upopup-button">点击邀约</button>
  143. </view>
  144. </up-popup>
  145. </view>
  146. </template>
  147. <script setup>
  148. import { ref, computed, onMounted } from "vue";
  149. import { useAppStore } from "@/stores/app";
  150. import { onLoad, onShareAppMessage } from "@dcloudio/uni-app";
  151. import { levelGrowthList } from "@/api/svip";
  152. const appStore = useAppStore();
  153. let leveList = ref([]);
  154. const showInvite = ref(false);
  155. onMounted(() => {
  156. console.log("mounted1", appStore.$userInfo);
  157. getLevelGrowthList();
  158. });
  159. // 权益列表数据
  160. const benefitList = ref([
  161. {
  162. icon: "https://sb-admin.oss-cn-shenzhen.aliyuncs.com/shuibei-mini/vip/storeGold.png",
  163. text: "存金",
  164. },
  165. {
  166. icon: "https://sb-admin.oss-cn-shenzhen.aliyuncs.com/shuibei-mini/vip/swapModel.png",
  167. text: "换款",
  168. },
  169. {
  170. icon: "https://sb-admin.oss-cn-shenzhen.aliyuncs.com/shuibei-mini/vip/Recycling.png",
  171. text: "回收",
  172. },
  173. {
  174. icon: "https://sb-admin.oss-cn-shenzhen.aliyuncs.com/shuibei-mini/vip/exchange.png",
  175. text: "兑换",
  176. },
  177. ]);
  178. // 任务列表数据
  179. const taskList = ref([
  180. {
  181. name: "完善基本资料",
  182. reward: "获得200成长值,200贝币",
  183. btnText: "立即前往",
  184. url: "/pages/personal_info/personal_info",
  185. },
  186. // {
  187. // name: "每日签到",
  188. // reward: "获得20成长值,20贝币",
  189. // btnText: "立即前往",
  190. // url: "/pages/bb_mall/index",
  191. // },
  192. {
  193. name: "卖料",
  194. reward: "每回收黄金1g,获得20成长值,20贝币",
  195. btnText: "立即前往",
  196. url: "/pages/users/vault/storeMetal/index",
  197. },
  198. {
  199. name: "买料",
  200. reward: "每买料黄金1g,获得20成长值,20贝币",
  201. btnText: "立即前往",
  202. url: "/pages/users/vault/rechargeGold",
  203. },
  204. {
  205. name: "攒金",
  206. reward: "每攒1克,获得20成长值,20贝币",
  207. btnText: "立即前往",
  208. url: "/pages/users/utils/wool/index",
  209. },
  210. {
  211. name: "消费",
  212. reward: "每消费1元工费,获得1成长值,1贝币",
  213. btnText: "立即前往",
  214. url: "/pages/users/vault/rechargeGold",
  215. },
  216. {
  217. name: "邀请新人",
  218. reward:
  219. "邀请一位新人注册,可获得100成长值,100贝币;新人升级会员,可获得200成长值,200贝币。",
  220. btnText: "立即邀请",
  221. url: "invite",
  222. },
  223. {
  224. name: "升级SVIP",
  225. reward: "升级SVIP解锁更多功能,加速成长值成长",
  226. btnText: "立即前往",
  227. url: "/pages/SVIP/SVIP",
  228. },
  229. ]);
  230. // 跳转任务页面
  231. function toPages(task) {
  232. // 买料、卖料、消费需要通过webview跳转
  233. if (
  234. [
  235. "/pages/users/vault/rechargeGold",
  236. "/pages/users/vault/storeMetal/index",
  237. "/pages/users/vault/storeMetal/order",
  238. ].includes(task.url)
  239. ) {
  240. const webviewPageUrl = `/pages/webview/index?path=${task.url}`;
  241. uni.navigateTo({
  242. url: webviewPageUrl,
  243. fail: (err) => {
  244. console.error("跳转到webview页面失败:", err);
  245. uni.showToast({
  246. title: "跳转失败,请重试",
  247. icon: "none",
  248. duration: 1500,
  249. });
  250. },
  251. });
  252. return; // 阻止继续执行后续跳转逻辑
  253. }
  254. // 其他任务的跳转逻辑
  255. if (["/pages/index/index"].includes(task.url)) {
  256. uni.switchTab({ url: task.url });
  257. } else if (task.url === "invite") {
  258. showInvite.value = true;
  259. } else {
  260. uni.navigateTo({ url: task.url });
  261. }
  262. }
  263. // 计算成长值百分比
  264. const percentExperience = computed(() => {
  265. if (appStore.isLogin) {
  266. const percent = Math.floor(
  267. (appStore?.$userInfo?.experience / appStore?.$userInfo?.experienceCount) *
  268. 100
  269. );
  270. return percent > 100 ? 100 : percent;
  271. }
  272. return 0;
  273. });
  274. const getLevelGrowthList = async () => {
  275. const res = await levelGrowthList();
  276. leveList.value = res.data;
  277. };
  278. // 分享功能
  279. onShareAppMessage(() => {
  280. return {
  281. title: "邀请您加入水贝搬运工",
  282. path: `/pages/users/login/index?invite_code=${appStore.$userInfo.inviteCode}`,
  283. imageUrl:
  284. "https://sb-admin.oss-cn-shenzhen.aliyuncs.com/shuibei-mini/Invite/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20250807170542.jpg",
  285. };
  286. });
  287. </script>
  288. <style scoped lang="scss">
  289. // 邀请新人弹窗
  290. .upopup-box {
  291. width: 600rpx;
  292. border-radius: 30rpx;
  293. overflow: hidden;
  294. position: relative;
  295. background-color: none;
  296. .upopup-button {
  297. position: absolute;
  298. bottom: 80rpx;
  299. left: 50%;
  300. transform: translateX(-50%);
  301. width: 200rpx;
  302. height: 60rpx;
  303. display: flex;
  304. justify-content: center;
  305. align-items: center;
  306. background-color: #cc9933;
  307. color: #ffffff;
  308. font-size: 30rpx;
  309. border-radius: 40rpx;
  310. box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.2);
  311. }
  312. }
  313. .level-container {
  314. // background-color: #fff;
  315. .up-nav-slot-title {
  316. color: #fff;
  317. }
  318. color: black;
  319. position: relative;
  320. top: -130rpx;
  321. }
  322. /* 顶部会员信息 */
  323. .vip-info {
  324. color: #dfd7bc;
  325. background: url("https://sb-admin.oss-cn-shenzhen.aliyuncs.com/shuibei-mini/svip/vip-bg.jpg")
  326. no-repeat center top;
  327. background-size: 100%;
  328. height: 450rpx;
  329. overflow: hidden;
  330. .vip-box {
  331. margin: 200rpx 90rpx 100rpx 265rpx;
  332. }
  333. }
  334. .vip-avatar {
  335. width: 151rpx;
  336. height: 161rpx;
  337. margin-right: 70rpx;
  338. margin-top: 50rpx;
  339. }
  340. .vip-title {
  341. font-size: 36rpx;
  342. font-weight: bold;
  343. margin-bottom: 8rpx;
  344. }
  345. .vip-desc {
  346. font-size: 24rpx;
  347. margin-bottom: 12rpx;
  348. }
  349. .growth-info {
  350. display: flex;
  351. justify-content: space-between;
  352. align-items: center;
  353. margin-top: 20rpx;
  354. margin-bottom: 5rpx;
  355. font-size: 20rpx;
  356. }
  357. .point-info {
  358. text-align: right;
  359. }
  360. .point-text {
  361. font-size: 40rpx;
  362. font-weight: bold;
  363. display: block;
  364. }
  365. .point-desc {
  366. font-size: 20rpx;
  367. opacity: 0.8;
  368. }
  369. /* VIP尊享权益标题 */
  370. .vip-benefit {
  371. padding: 30rpx;
  372. .vip-benefit-title {
  373. font-size: 32rpx;
  374. font-weight: bold;
  375. margin: 32rpx 0 16rpx 0;
  376. }
  377. .benefit-content {
  378. background-color: #323141;
  379. padding: 40rpx 30rpx;
  380. padding-bottom: 10rpx;
  381. border-radius: 20rpx;
  382. /* 权益列表 */
  383. .benefit-list {
  384. display: flex;
  385. justify-content: space-between;
  386. padding-bottom: 20rpx;
  387. border-bottom: 1px dashed #797887;
  388. }
  389. .benefit-desc {
  390. display: flex;
  391. justify-content: space-between;
  392. align-items: flex-end;
  393. font-size: 18rpx;
  394. color: #bdc3c7;
  395. padding: 10rpx 0;
  396. box-sizing: border-box;
  397. text {
  398. color: #d1bb9c;
  399. font-size: 18rpx;
  400. }
  401. }
  402. .benefit-item {
  403. display: flex;
  404. flex-direction: column;
  405. align-items: center;
  406. }
  407. .benefit-icon {
  408. width: 100rpx;
  409. height: 100rpx;
  410. margin-bottom: 8rpx;
  411. }
  412. .benefit-text {
  413. font-size: 20rpx;
  414. color: #fff;
  415. }
  416. }
  417. }
  418. /* 任务标题 */
  419. .task-title {
  420. font-size: 32rpx;
  421. font-weight: bold;
  422. margin: 32rpx 0 16rpx 0;
  423. }
  424. /* 任务项 */
  425. .task-item {
  426. display: flex;
  427. justify-content: space-between;
  428. align-items: center;
  429. padding: 20rpx 30rpx;
  430. border: 1px solid #f2f2f2;
  431. border-radius: 8rpx;
  432. margin-bottom: 16rpx;
  433. background-color: #f4f3f1;
  434. .submit-btn {
  435. width: 120rpx;
  436. }
  437. }
  438. .task-desc {
  439. display: flex;
  440. flex-direction: column;
  441. flex: 1;
  442. }
  443. .task-name {
  444. font-size: 28rpx;
  445. font-weight: bold;
  446. margin-bottom: 4rpx;
  447. }
  448. .task-reward {
  449. font-size: 24rpx;
  450. color: #999;
  451. }
  452. .vip-level-box {
  453. .vip-level-title {
  454. font-size: 32rpx;
  455. font-weight: bold;
  456. text-align: center;
  457. margin-bottom: 30rpx;
  458. }
  459. .title-box {
  460. height: 60rpx;
  461. background: #302f3f;
  462. display: flex;
  463. align-items: center;
  464. .title-item {
  465. flex: 1;
  466. display: flex;
  467. justify-content: center;
  468. align-items: center;
  469. color: #fff;
  470. }
  471. }
  472. .title-content {
  473. width: 100%;
  474. min-height: 500rpx;
  475. .content-list {
  476. display: flex;
  477. }
  478. .content-item {
  479. flex: 1;
  480. display: flex;
  481. flex-direction: column;
  482. align-items: center;
  483. justify-content: center;
  484. font-size: 22rpx;
  485. height: 120rpx;
  486. border-bottom: 1px dashed #eee;
  487. // width: 24%;
  488. image {
  489. height: 25rpx;
  490. // height: 100%;
  491. }
  492. }
  493. .quanyi {
  494. align-items: flex-start;
  495. // margin-right: 30rpx;
  496. }
  497. .gw {
  498. margin-left: 5rpx;
  499. &.zk {
  500. letter-spacing: 6rpx;
  501. margin-left: 9rpx;
  502. }
  503. }
  504. }
  505. .vip-level-img {
  506. width: 100%;
  507. }
  508. }
  509. .content-desc {
  510. width: 100%;
  511. display: flex;
  512. align-items: center;
  513. justify-content: center;
  514. margin-top: 20rpx;
  515. font-size: 22rpx;
  516. }
  517. uni-page-body{
  518. background-color: #fff !important;
  519. }
  520. </style>