recharge.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <s-layout title="充值" class="withdraw-wrap" navbar="inner">
  3. <view class="wallet-num-box ss-flex ss-col-center ss-row-between" :style="[
  4. {
  5. marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
  6. paddingTop: Number(statusBarHeight + 108) + 'rpx',
  7. },
  8. ]">
  9. <view class="">
  10. <view class="num-title">当前余额(元)</view>
  11. <view class="wallet-num">{{ userInfo.money }}</view>
  12. </view>
  13. <button class="ss-reset-button log-btn" @tap="sheep.$router.go('/pages/pay/recharge-log')">充值记录</button>
  14. </view>
  15. <view class="recharge-box">
  16. <view class="recharge-card-box" v-if="state.data.status">
  17. <view class="input-label ss-m-b-50">充值金额</view>
  18. <view class="input-box ss-flex border-bottom ss-p-b-20" v-if="state.data.custom_status">
  19. <view class="unit">¥</view>
  20. <uni-easyinput v-model="state.recharge_money" type="digit" placeholder="请输入充值金额"
  21. :inputBorder="false">
  22. </uni-easyinput>
  23. </view>
  24. <view class="face-value-box ss-flex ss-flex-wrap ss-m-y-40">
  25. <button class="ss-reset-button face-value-btn" v-for="item in state.faceValueList" :key="item.money"
  26. :class="[{ 'btn-active': state.recharge_money == parseFloat(item.money) }]"
  27. @tap="onCard(item.payPrice/100)">
  28. <text class="face-value-title">{{ item.payPrice/100 }}</text>
  29. <view v-if="item.bonusPrice" class="face-value-tag">
  30. 送{{ item.bonusPrice/100 }}{{ state.data.gift_type == 'money' ? '元' : '积分' }}</view>
  31. </button>
  32. </view>
  33. <button class="ss-reset-button save-btn ui-BG-Main-Gradient ss-m-t-60 ui-Shadow-Main" @tap="onConfirm">
  34. 确认充值
  35. </button>
  36. </view>
  37. <view class="" v-if="state.data.status === 0"> 关闭充值 </view>
  38. </view>
  39. </s-layout>
  40. </template>
  41. <script setup>
  42. import {
  43. computed,
  44. reactive
  45. } from 'vue';
  46. import sheep from '@/sheep';
  47. import {
  48. onLoad
  49. } from '@dcloudio/uni-app';
  50. const userInfo = computed(() => sheep.$store('user').userInfo);
  51. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  52. const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
  53. const state = reactive({
  54. recharge_money: '',
  55. data: {},
  56. faceValueList: [],
  57. });
  58. // 点击卡片
  59. function onCard(e) {
  60. state.recharge_money = e;
  61. }
  62. async function getRechargeTabs() {
  63. const res = await sheep.$api.trade.rechargeRules();
  64. const res2 = await sheep.$api.trade.rechargeRules2();
  65. if (res.error === 0) {
  66. state.data = res.data;
  67. state.data.status = res.data.status;
  68. console.log(res);
  69. console.log(res2);
  70. // state.faceValueList = res.data.quick_amounts;
  71. state.faceValueList = res2.data;
  72. }
  73. }
  74. function onChange(e) {
  75. state.data.gift_type = e.detail.value;
  76. }
  77. async function onConfirm() {
  78. const {
  79. code,
  80. data
  81. } = await sheep.$api.trade.recharge({
  82. packageId: 0,
  83. payPrice: state.recharge_money * 100
  84. });
  85. if (code === 0) {
  86. // #ifdef MP
  87. sheep.$platform.useProvider('wechat').subscribeMessage('money_change');
  88. // #endif
  89. sheep.$router.go('/pages/pay/index', {
  90. orderSN: data.order_sn,
  91. type: 'recharge'
  92. });
  93. }
  94. }
  95. onLoad(() => {
  96. getRechargeTabs();
  97. });
  98. </script>
  99. <style lang="scss" scoped>
  100. :deep() {
  101. .uni-input-input {
  102. font-family: OPPOSANS !important;
  103. }
  104. }
  105. .wallet-num-box {
  106. padding: 0 40rpx 80rpx;
  107. background: var(--ui-BG-Main) v-bind(headerBg) center/750rpx 100% no-repeat;
  108. border-radius: 0 0 5% 5%;
  109. .num-title {
  110. font-size: 26rpx;
  111. font-weight: 500;
  112. color: $white;
  113. margin-bottom: 20rpx;
  114. }
  115. .wallet-num {
  116. font-size: 60rpx;
  117. font-weight: 500;
  118. color: $white;
  119. font-family: OPPOSANS;
  120. }
  121. .log-btn {
  122. width: 170rpx;
  123. height: 60rpx;
  124. line-height: 60rpx;
  125. border: 1rpx solid $white;
  126. border-radius: 30rpx;
  127. padding: 0;
  128. font-size: 26rpx;
  129. font-weight: 500;
  130. color: $white;
  131. }
  132. }
  133. .recharge-box {
  134. position: relative;
  135. padding: 0 30rpx;
  136. margin-top: -60rpx;
  137. }
  138. .save-btn {
  139. width: 620rpx;
  140. height: 86rpx;
  141. border-radius: 44rpx;
  142. font-size: 30rpx;
  143. }
  144. .recharge-card-box {
  145. width: 690rpx;
  146. background: var(--ui-BG);
  147. border-radius: 20rpx;
  148. padding: 30rpx;
  149. box-sizing: border-box;
  150. .input-label {
  151. font-size: 30rpx;
  152. font-weight: 500;
  153. color: #333;
  154. }
  155. .unit {
  156. display: flex;
  157. align-items: center;
  158. font-size: 48rpx;
  159. font-weight: 500;
  160. }
  161. .uni-easyinput__placeholder-class {
  162. font-size: 30rpx;
  163. height: 60rpx;
  164. display: flex;
  165. align-items: center;
  166. }
  167. :deep(.uni-easyinput__content-input) {
  168. font-size: 48rpx;
  169. }
  170. .face-value-btn {
  171. width: 200rpx;
  172. height: 144rpx;
  173. border: 1px solid var(--ui-BG-Main);
  174. border-radius: 10rpx;
  175. position: relative;
  176. z-index: 1;
  177. margin-bottom: 15rpx;
  178. margin-right: 15rpx;
  179. &:nth-of-type(3n) {
  180. margin-right: 0;
  181. }
  182. .face-value-title {
  183. font-size: 36rpx;
  184. font-weight: 500;
  185. color: var(--ui-BG-Main);
  186. font-family: OPPOSANS;
  187. &::after {
  188. content: '元';
  189. font-size: 24rpx;
  190. margin-left: 6rpx;
  191. }
  192. }
  193. .face-value-tag {
  194. position: absolute;
  195. z-index: 2;
  196. height: 40rpx;
  197. line-height: 40rpx;
  198. background: var(--ui-BG-Main);
  199. opacity: 0.8;
  200. border-radius: 10rpx 0 20rpx 0;
  201. top: 0;
  202. left: -2rpx;
  203. padding: 0 16rpx;
  204. font-size: 22rpx;
  205. color: $white;
  206. font-family: OPPOSANS;
  207. }
  208. &::before {
  209. position: absolute;
  210. content: ' ';
  211. width: 100%;
  212. height: 100%;
  213. background: var(--ui-BG-Main);
  214. opacity: 0.1;
  215. z-index: 0;
  216. left: 0;
  217. top: 0;
  218. }
  219. }
  220. .btn-active {
  221. z-index: 1;
  222. &::before {
  223. content: '';
  224. background: var(--ui-BG-Main);
  225. opacity: 1;
  226. }
  227. .face-value-title {
  228. color: $white;
  229. position: relative;
  230. z-index: 1;
  231. font-family: OPPOSANS;
  232. }
  233. .face-value-tag {
  234. background: $white;
  235. color: var(--ui-BG-Main);
  236. font-family: OPPOSANS;
  237. }
  238. }
  239. }
  240. </style>