recharge.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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="number"
  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 === 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 state = reactive({
  65. recharge_money: '',
  66. data: {},
  67. faceValueList: [],
  68. });
  69. // 点击卡片
  70. function onCard(e) {
  71. state.recharge_money = e;
  72. }
  73. async function getRechargeTabs() {
  74. const list = await sheep.$api.trade.rechargeRules();
  75. state.data = list;
  76. state.data.status = list.status;
  77. state.faceValueList = list.quick_amounts;
  78. }
  79. function onChange(e) {
  80. state.data.gift_type = e.detail.value;
  81. }
  82. async function onConfirm() {
  83. const { error, data } = await sheep.$api.trade.recharge({
  84. recharge_money: state.recharge_money,
  85. });
  86. if (error === 0) {
  87. sheep.$router.go('/pages/pay/index', { orderSN: data.order_sn, type: 'recharge' });
  88. }
  89. }
  90. onLoad(() => {
  91. getRechargeTabs();
  92. });
  93. </script>
  94. <style lang="scss" scoped>
  95. :deep() {
  96. .uni-input-input {
  97. font-family: OPPOSANS !important;
  98. }
  99. }
  100. .wallet-num-box {
  101. padding: 0 40rpx 80rpx;
  102. background: var(--ui-BG-Main) v-bind("sheep.$url.css('/static/img/shop/user/withdraw_bg.png')")
  103. center/750rpx 100% no-repeat;
  104. border-radius: 0 0 5% 5%;
  105. .num-title {
  106. font-size: 26rpx;
  107. font-weight: 500;
  108. color: $white;
  109. margin-bottom: 20rpx;
  110. }
  111. .wallet-num {
  112. font-size: 60rpx;
  113. font-weight: 500;
  114. color: $white;
  115. font-family: OPPOSANS;
  116. }
  117. .log-btn {
  118. width: 170rpx;
  119. height: 60rpx;
  120. line-height: 60rpx;
  121. border: 1rpx solid $white;
  122. border-radius: 30rpx;
  123. padding: 0;
  124. font-size: 26rpx;
  125. font-weight: 500;
  126. color: $white;
  127. }
  128. }
  129. .recharge-box {
  130. position: relative;
  131. padding: 0 30rpx;
  132. margin-top: -60rpx;
  133. }
  134. .save-btn {
  135. width: 620rpx;
  136. height: 86rpx;
  137. border-radius: 44rpx;
  138. font-size: 30rpx;
  139. }
  140. .recharge-card-box {
  141. width: 690rpx;
  142. background: var(--ui-BG);
  143. border-radius: 20rpx;
  144. padding: 30rpx;
  145. box-sizing: border-box;
  146. .input-label {
  147. font-size: 30rpx;
  148. font-weight: 500;
  149. color: #333;
  150. }
  151. .unit {
  152. display: flex;
  153. align-items: center;
  154. font-size: 48rpx;
  155. font-weight: 500;
  156. }
  157. .uni-easyinput__placeholder-class {
  158. font-size: 30rpx;
  159. height: 60rpx;
  160. display: flex;
  161. align-items: center;
  162. }
  163. :deep(.uni-easyinput__content-input) {
  164. font-size: 48rpx;
  165. }
  166. .face-value-btn {
  167. width: 200rpx;
  168. height: 144rpx;
  169. border: 1px solid var(--ui-BG-Main);
  170. border-radius: 10rpx;
  171. position: relative;
  172. z-index: 1;
  173. margin-bottom: 15rpx;
  174. margin-right: 15rpx;
  175. &:nth-of-type(3n) {
  176. margin-right: 0;
  177. }
  178. .face-value-title {
  179. font-size: 36rpx;
  180. font-weight: 500;
  181. color: var(--ui-BG-Main);
  182. font-family: OPPOSANS;
  183. &::after {
  184. content: '元';
  185. font-size: 24rpx;
  186. margin-left: 6rpx;
  187. }
  188. }
  189. .face-value-tag {
  190. position: absolute;
  191. z-index: 2;
  192. height: 40rpx;
  193. line-height: 40rpx;
  194. background: var(--ui-BG-Main);
  195. opacity: 0.8;
  196. border-radius: 10rpx 0 20rpx 0;
  197. top: 0;
  198. left: -2rpx;
  199. padding: 0 16rpx;
  200. font-size: 22rpx;
  201. color: $white;
  202. font-family: OPPOSANS;
  203. }
  204. &::before {
  205. position: absolute;
  206. content: ' ';
  207. width: 100%;
  208. height: 100%;
  209. background: var(--ui-BG-Main);
  210. opacity: 0.1;
  211. z-index: 0;
  212. left: 0;
  213. top: 0;
  214. }
  215. }
  216. .btn-active {
  217. z-index: 1;
  218. &::before {
  219. content: '';
  220. background: var(--ui-BG-Main);
  221. opacity: 1;
  222. }
  223. .face-value-title {
  224. color: $white;
  225. position: relative;
  226. z-index: 1;
  227. font-family: OPPOSANS;
  228. }
  229. .face-value-tag {
  230. background: $white;
  231. color: var(--ui-BG-Main);
  232. font-family: OPPOSANS;
  233. }
  234. }
  235. }
  236. </style>