svip.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <!-- svip页面 -->
  2. <template>
  3. <view class="ezy-svip-page">
  4. <view class="icon-title-navBar-box">
  5. <!-- 返回按钮 ↓ -->
  6. <view class="nav-bar-icon" @click="goBack"></view>
  7. <view class="nav-bar-title">开通svip</view>
  8. </view>
  9. <!-- :class="'svip-login'+Id" 改到下方 -->
  10. <icon :class="'svip-login'+cardId"></icon>
  11. <view class="svip-list-box">
  12. <view v-for="(item, index) in svipArr" :key="index" class="list-item-box">
  13. <icon class="list-icon" :style="{backgroundImage: 'url(' + item.iconPath + ')'}"></icon>
  14. <view>
  15. <view class="list-title">{{item.title}}</view>
  16. <view class="list-content" v-html="item.content"></view>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="open-svip-box">
  21. <view class="svip-price-box">
  22. <view>原价:<text class="original-price">¥598</text></view>
  23. <view class="discount-price">活动价:¥198</view>
  24. </view>
  25. <radio-group @change="radioChange" class="pay-type-box">
  26. <view class="type-radio-title">支付方式</view>
  27. <view class="type-radio-content">
  28. <view class="type-radio-box">
  29. <icon class="wx-radio"></icon>
  30. <text>微信</text>
  31. <radio value="weixin" :checked="payType==='weixin'" activeBackgroundColor="transparent"
  32. :class="{'radio-checked': payType==='weixin'}" />
  33. </view>
  34. <view class="type-radio-box">
  35. <icon class="zfb-radio"></icon>
  36. <text>支付宝</text>
  37. <radio value="zhifubao" :checked="payType==='zhifubao'" activeBackgroundColor="transparent"
  38. :class="{'radio-checked': payType==='zhifubao'}" style="margin-right: 0;" />
  39. </view>
  40. </view>
  41. </radio-group>
  42. <view class="open-svip-btn" @click="creatOrder">立即开通</view>
  43. </view>
  44. <CustomTabBar></CustomTabBar>
  45. <!-- 蛋破壳 -->
  46. <pay-success ref="daoPokeRef"></pay-success>
  47. <pay-successAll ref="daoPokeAllRef"></pay-successAll>
  48. </view>
  49. </template>
  50. <script setup>
  51. import {
  52. ref
  53. } from "vue";
  54. import {
  55. orderAdd
  56. } from "@/api/order.js"
  57. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  58. import cacheManager from "@/utils/cacheManager.js";
  59. import paySuccess from './paySuccess.vue';
  60. import paySuccessAll from './paySuccessAll.vue';
  61. import {
  62. onLoad,
  63. onReady
  64. } from '@dcloudio/uni-app';
  65. import {
  66. toast,
  67. getUserIdentity,
  68. hasUserIdentity
  69. } from "@/utils/common";
  70. let payType = ref('weixin')
  71. let cardId = ref('')
  72. let formPage = ref('')
  73. const daoPokeRef = ref(null);
  74. const daoPokeAllRef = ref(null);
  75. const selectZhangId = ref(null);//来自岛目录选择的章Id,支付后需要修改章id缓存记录,方便返回时定位到选中章的岛
  76. const isAlreadyVip = hasUserIdentity();
  77. const svipArr = [{
  78. iconPath: 'static/images/pay/svip-list-icon1.png',
  79. title: '学习资源,随心畅学',
  80. content: `解锁L1~L6全等级数学思维优质学习资源,<br/>满足多样学习需求`
  81. },
  82. {
  83. iconPath: 'static/images/pay/svip-list-icon2.png',
  84. title: '名师打造,优质路径',
  85. content: '资深名师精心规划学习路径,引领高效提升方向'
  86. },
  87. {
  88. iconPath: 'static/images/pay/svip-list-icon3.png',
  89. title: '进度分析,个性贴心',
  90. content: '优先参与丰富真题测试,精准洞察学习状况'
  91. },
  92. {
  93. iconPath: 'static/images/pay/svip-list-icon4.png',
  94. title: '真题测试,优先体验',
  95. content: '成为会员,即刻畅享专属权益,开启无忧学习之旅'
  96. }
  97. ];
  98. onLoad((options) => {
  99. cardId.value = options.cardId
  100. formPage.value = options.formPage
  101. selectZhangId.value = options.selectZhangId||''
  102. })
  103. function radioChange(data) {
  104. payType.value = data.detail.value;
  105. }
  106. function creatOrder(data) {
  107. let req = {
  108. cardId: cardId.value
  109. }
  110. orderAdd(req).then(res => {
  111. cacheManager.updateVipStatus('auth', cardId.value)
  112. cacheManager.updateObject('auth', {
  113. growthType: 1
  114. })
  115. if (isAlreadyVip != 'VIP') {
  116. daoPokeRef.value.handleShow();
  117. } else {
  118. daoPokeAllRef.value.handleShow();
  119. }
  120. setTimeout(() => {
  121. daoPokeRef.value.handleClose();
  122. daoPokeAllRef.value.handleClose();
  123. if(formPage.value =='my'){
  124. uni.redirectTo({
  125. url: '/pages/my/index'
  126. })
  127. } else if (formPage.value =='studyWithCatalgue'&& selectZhangId.value ) {
  128. // 来自目录并且支付成功有章Id,更新缓存然后返回新岛
  129. if( cacheManager.get('auth')){
  130. const zhangList = cacheManager.get('zhangInfo').zhangList;
  131. cacheManager.updateObject('auth', {
  132. currentZhang: zhangList.findIndex(citem => citem.zhangId == +selectZhangId.value),
  133. zhangId: +selectZhangId.value
  134. })
  135. }
  136. uni.redirectTo({
  137. url: '/pages/study/index'
  138. })
  139. } else{
  140. uni.redirectTo({
  141. url: '/pages/study/index'
  142. })
  143. }
  144. }, 3000)
  145. })
  146. }
  147. function goBack(data) {
  148. if (formPage.value == 'studyWithCatalgue' ) {
  149. // 返回到需要展示弹窗 studyWithCatalgue=1
  150. uni.redirectTo({
  151. url: '/pages/study/index?studyWithCatalgue=1'
  152. })
  153. return;
  154. }
  155. uni.redirectTo({
  156. url: '/pages/study/index'
  157. })
  158. }
  159. </script>
  160. <style>
  161. </style>