recharge.vue 6.2 KB

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