index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <Container title="VIP充值">
  3. <view class="recharge-main">
  4. <!-- 内容区 -->
  5. <view class="content">
  6. <!-- 套餐选择 -->
  7. <view class="plan-list">
  8. <view class="p"
  9. ><view
  10. class="plan-card"
  11. :class="activeCurrent === 1 && 'active'"
  12. @click="activeCurrent = 1"
  13. >
  14. <view class="plan-title">
  15. {{ data[1]?.package_name }}
  16. <text class="plan-tag">首月</text>
  17. </view>
  18. <view class="plan-price">
  19. <text class="price">{{
  20. data[1]?.automatic_renewal_first_price
  21. }}</text>
  22. <view class="plan-origin"
  23. >¥{{ data[1]?.package_original_price }}</view
  24. >
  25. </view>
  26. </view>
  27. <view
  28. class="plan-tip"
  29. :style="{
  30. opacity: activeCurrent === 1 ? 1 : 0,
  31. }"
  32. >每期自动续费{{
  33. data[1]?.automatic_renewal_price
  34. }}元,可取消</view
  35. ></view
  36. >
  37. <view
  38. class="plan-card"
  39. :class="activeCurrent === 0 && 'active'"
  40. @click="activeCurrent = 0"
  41. >
  42. <view class="plan-title">{{ data[0]?.package_name }}</view>
  43. <view class="plan-price">
  44. <text class="price">{{
  45. data[0]?.package_preferential_price
  46. }}</text>
  47. <view class="plan-origin"
  48. >¥{{ data[0]?.package_original_price }}</view
  49. >
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 权益展示 -->
  54. <div class="title">权益展示</div>
  55. <view class="benefit" v-show="activeCurrent === 1">
  56. <view v-for="item in data[1]?.binding_rights_info" :key="item.id">{{
  57. item.authority_title
  58. }}</view>
  59. </view>
  60. <view class="benefit" v-show="activeCurrent === 0">
  61. <view v-for="item in data[0]?.binding_rights_info" :key="item.id">{{
  62. item.authority_title
  63. }}</view>
  64. </view>
  65. </view>
  66. <!-- 底部按钮 -->
  67. </view>
  68. <template #footer>
  69. <!-- 协议勾选 -->
  70. <view class="agreement">
  71. <uni-data-checkbox
  72. v-model="isSelected"
  73. multiple
  74. :localdata="[
  75. {
  76. text: '阅读并确认',
  77. value: 1,
  78. },
  79. ]"
  80. >
  81. <template #label="{ item }">
  82. <text
  83. :style="{
  84. paddingLeft: '10rpx',
  85. }"
  86. >{{ item.text }}</text
  87. >
  88. <text>《会员服务权益》</text>
  89. <text>(自动续费协议)</text>
  90. </template>
  91. </uni-data-checkbox>
  92. </view>
  93. <button class="open-btn" @click="onSubmit">立即开通</button>
  94. </template>
  95. <!-- 客服 -->
  96. <view class="service">
  97. <CustomerService>联系客服</CustomerService>
  98. </view>
  99. </Container>
  100. </template>
  101. <script setup name="recharge">
  102. import Container from "@/components/Container/Container.vue";
  103. import CustomerService from "@/components/CustomerService/CustomerService.vue";
  104. import { ref, onMounted, getCurrentInstance } from "vue";
  105. import { request } from "../../utils/request";
  106. import ext from "../../ext.json";
  107. const instance = getCurrentInstance();
  108. const activeCurrent = ref(0);
  109. const isSelected = ref([0]);
  110. const data = ref([]);
  111. const onSubmit = () => {
  112. // if (!isSelected.value[0])
  113. // return uni.showToast({
  114. // icon: "none",
  115. // title: "请阅读并确认",
  116. // });
  117. uni.login({
  118. provider: instance.proxy.$mpPlatform.substring(3),
  119. success: async ({ code }) => {
  120. const package_id = data.value[activeCurrent.value]?.id;
  121. // 先调用新增订单再支付
  122. // const order = await request('api/question_bank/question_reception/orders/add', {
  123. // package_id
  124. // })
  125. // console.log(order.data.order_id);
  126. const { miniProgram } = uni.getAccountInfoSync();
  127. const res = await request(
  128. "api/question_bank/question_reception/orders/wechat_pay",
  129. {
  130. code,
  131. order_id: 3,
  132. // app_id: miniProgram.appId,
  133. app_id: ext.extAppid,
  134. }
  135. );
  136. console.log(res);
  137. },
  138. });
  139. };
  140. onMounted(async () => {
  141. const res = await request(
  142. "api/question_bank/question_reception/recharge_package/list"
  143. );
  144. data.value = res.data.data;
  145. });
  146. </script>
  147. <style scoped lang="scss">
  148. @import "@/uni.scss";
  149. .recharge-main {
  150. display: flex;
  151. flex-direction: column;
  152. background: #fff;
  153. position: relative;
  154. padding-bottom: 120rpx; // 预留底部按钮高度
  155. }
  156. .content {
  157. flex: 1;
  158. padding: 32rpx 24rpx 0 24rpx;
  159. }
  160. .plan-list {
  161. display: flex;
  162. gap: 24rpx;
  163. margin-bottom: 12rpx;
  164. }
  165. .title {
  166. font-family: PingFang SC, PingFang SC;
  167. font-weight: bold;
  168. font-size: 32rpx;
  169. color: #000000;
  170. margin-bottom: 10rpx;
  171. }
  172. .p {
  173. flex: 1;
  174. }
  175. .plan-card {
  176. flex: 1;
  177. border: 2rpx solid $default;
  178. border-radius: 16rpx;
  179. height: 332rpx;
  180. background: #fff;
  181. transition: border-color 0.2s;
  182. position: relative;
  183. display: flex;
  184. flex-direction: column;
  185. align-items: center;
  186. justify-content: center;
  187. gap: 52rpx;
  188. color: #666666;
  189. &.active {
  190. color: $uni-primary;
  191. border-color: $uni-primary;
  192. }
  193. .plan-title {
  194. font-size: 28rpx;
  195. color: #333;
  196. margin-bottom: 8rpx;
  197. .plan-tag {
  198. color: $error;
  199. font-size: 20rpx;
  200. margin-left: 8rpx;
  201. border: 1rpx solid $error;
  202. border-radius: 6rpx;
  203. padding: 0 8rpx;
  204. height: 28rpx;
  205. line-height: 28rpx;
  206. background: #fff;
  207. vertical-align: middle;
  208. }
  209. }
  210. .plan-price {
  211. display: flex;
  212. flex-direction: column;
  213. align-items: center;
  214. .price {
  215. font-size: 60rpx;
  216. font-weight: bold;
  217. ::before {
  218. content: "¥";
  219. font-size: 32rpx;
  220. }
  221. }
  222. }
  223. .plan-origin {
  224. font-size: 22rpx;
  225. text-decoration: line-through;
  226. margin-top: 4rpx;
  227. }
  228. }
  229. .plan-tip {
  230. font-size: 22rpx;
  231. font-weight: bold;
  232. margin-bottom: 24rpx;
  233. margin-left: 8rpx;
  234. margin-top: 15rpx;
  235. }
  236. .benefit {
  237. border: 2rpx solid $default;
  238. border-radius: 12rpx;
  239. padding: 24rpx;
  240. font-weight: bold;
  241. view {
  242. font-size: 28rpx;
  243. color: #333;
  244. margin-bottom: 12rpx;
  245. &:last-child {
  246. margin-bottom: 0;
  247. }
  248. }
  249. }
  250. .service {
  251. color: $uni-primary;
  252. font-size: 28rpx;
  253. margin-bottom: 40rpx;
  254. text-align: right;
  255. position: absolute;
  256. bottom: 10%;
  257. right: 5%;
  258. }
  259. .agreement {
  260. display: flex;
  261. align-items: center;
  262. font-size: 22rpx;
  263. color: #666;
  264. margin-bottom: 32rpx;
  265. .radio {
  266. margin-right: 12rpx;
  267. }
  268. }
  269. .footer-btn {
  270. position: fixed;
  271. left: 0;
  272. bottom: 0;
  273. width: 100vw;
  274. background: #fff;
  275. padding: 24rpx;
  276. box-sizing: border-box;
  277. z-index: 10;
  278. box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.03);
  279. }
  280. .open-btn {
  281. width: 100%;
  282. background: $uni-primary;
  283. color: #fff;
  284. font-size: 32rpx;
  285. border-radius: 12rpx;
  286. height: 88rpx;
  287. line-height: 88rpx;
  288. text-align: center;
  289. font-weight: bold;
  290. border: none;
  291. margin-top: 0;
  292. &:active {
  293. background: $uni-primary-disable;
  294. }
  295. }
  296. </style>