recharge.vue 6.0 KB

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