withdraw.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <view class="withdraw-page">
  3. <!-- 微信账户信息 -->
  4. <view class="wechat-account">
  5. <image class="avatar" src="../static/t11.png" mode="aspectFill"></image>
  6. <view class="account-info">
  7. <text class="nickname">{{ userInfo.nickname || '这里是微信昵称' }}</text>
  8. <text class="amount">可提现金额:</text>
  9. <text class="amount-number">¥{{ availableAmount }}</text>
  10. </view>
  11. </view>
  12. <!-- 提现金额输入 -->
  13. <view class="amount-input">
  14. <view class="label">提现金额</view>
  15. <view class="input-box flex-a">
  16. <text class="currency">¥</text>
  17. <u-input class="flex-1" v-model="withdrawAmount" type="number" :border="false" placeholder="请输入提现金额"
  18. @input="onAmountInput" placeholder-style="font-size:50rpx;color:#c1c1c1"
  19. :custom-style="{ fontSize: '50rpx' }"></u-input>
  20. <text class="all-btn" @click="withdrawAll">全部提现</text>
  21. </view>
  22. <!-- 到账账户 -->
  23. <view class="flex-a common-gray mt-40">
  24. <view class="common-text-2">到账账户:</view>
  25. <view class="wechat-pay">
  26. <image src="../static/wx.png" mode="aspectFit" class="wechat-icon"></image>
  27. <text>微信零钱</text>
  28. </view>
  29. </view>
  30. <!-- 提现说明 -->
  31. <view class="mt-20 flex-d common-gray">
  32. <text class="tip-item">1.用户需微信实名才能申请提现;</text>
  33. <text class="tip-item">2.用户单笔提现金额需小于200元;</text>
  34. <text class="tip-item">3.用户申请提现以后,余额会显示冻结,提现金额最晚会在72小时到账(周末、节假日顺延)</text>
  35. </view>
  36. </view>
  37. <!-- 提现按钮 -->
  38. <view class="submit-btn mt-60">
  39. <u-button type="primary" @click="submitWithdraw">确认提现</u-button>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. userInfo: {
  48. avatar: '',
  49. nickname: ''
  50. },
  51. availableAmount: '360.08',
  52. withdrawAmount: '',
  53. minAmount: 0.3,
  54. maxAmount: 200
  55. }
  56. },
  57. computed: {
  58. canWithdraw() {
  59. const amount = Number(this.withdrawAmount)
  60. return amount >= this.minAmount &&
  61. amount <= this.maxAmount &&
  62. amount <= Number(this.availableAmount)
  63. }
  64. },
  65. methods: {
  66. // 输入金额
  67. onAmountInput(value) {
  68. // 限制只能输入两位小数
  69. if (value.includes('.')) {
  70. const decimal = value.split('.')[1]
  71. if (decimal.length > 2) {
  72. this.withdrawAmount = Number(value).toFixed(2)
  73. }
  74. }
  75. },
  76. // 全部提现
  77. withdrawAll() {
  78. this.withdrawAmount = this.availableAmount
  79. },
  80. // 提交提现
  81. async submitWithdraw() {
  82. if (!this.canWithdraw) return
  83. try {
  84. uni.showLoading({
  85. title: '提交中...',
  86. mask: true
  87. })
  88. // 这里调用提现接口
  89. await this.$u.api.withdrawAjax({
  90. amount: this.withdrawAmount
  91. })
  92. uni.showToast({
  93. title: '提现申请成功',
  94. icon: 'success'
  95. })
  96. setTimeout(() => {
  97. uni.navigateBack()
  98. }, 1500)
  99. } catch (error) {
  100. uni.showToast({
  101. title: error.message || '提现失败',
  102. icon: 'none'
  103. })
  104. } finally {
  105. uni.hideLoading()
  106. }
  107. }
  108. }
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. .withdraw-page {
  113. min-height: 100vh;
  114. background: #F5F5F5;
  115. padding: 20rpx;
  116. .common-gray {
  117. background: #f9f9f9;
  118. border-radius: 12rpx;
  119. padding: 20rpx;
  120. min-height: 88rpx;
  121. }
  122. .wechat-account {
  123. background: #FFFFFF;
  124. border-radius: 12rpx;
  125. padding: 30rpx;
  126. display: flex;
  127. align-items: center;
  128. .avatar {
  129. width: 110rpx;
  130. height: 110rpx;
  131. border-radius: 50%;
  132. margin-right: 20rpx;
  133. }
  134. .account-info {
  135. .nickname {
  136. font-size: 36rpx;
  137. color: #333;
  138. font-weight: bold;
  139. display: block;
  140. margin-bottom: 10rpx;
  141. }
  142. .amount {
  143. font-size: 28rpx;
  144. color: #333;
  145. font-weight: 500;
  146. }
  147. .amount-number {
  148. font-family: Dosis;
  149. font-weight: bold;
  150. font-size: 34rpx;
  151. color: #333333;
  152. }
  153. }
  154. }
  155. .amount-input {
  156. background: #FFFFFF;
  157. border-radius: 12rpx;
  158. padding: 30rpx;
  159. margin-top: 20rpx;
  160. .label {
  161. font-size: 28rpx;
  162. color: #333;
  163. margin-bottom: 20rpx;
  164. }
  165. .input-box {
  166. display: flex;
  167. align-items: center;
  168. border-bottom: 1px solid #EEEEEE;
  169. padding: 20rpx 0;
  170. .currency {
  171. font-size: 40rpx;
  172. color: #333;
  173. margin-right: 20rpx;
  174. }
  175. :deep(.u-input) {
  176. flex: 1;
  177. input {
  178. font-size: 28rpx;
  179. &::placeholder {
  180. color: #C8C9CC;
  181. font-size: 28rpx;
  182. }
  183. }
  184. }
  185. .all-btn {
  186. font-size: 28rpx;
  187. color: #38C148;
  188. padding-left: 20rpx;
  189. }
  190. }
  191. }
  192. .wechat-pay {
  193. display: flex;
  194. align-items: center;
  195. .wechat-icon {
  196. width: 40rpx;
  197. height: 40rpx;
  198. margin-right: 10rpx;
  199. }
  200. text {
  201. font-size: 28rpx;
  202. color: #333;
  203. }
  204. }
  205. .tip-item {
  206. font-family: PingFang SC;
  207. font-weight: 400;
  208. font-size: 26rpx;
  209. color: #333333;
  210. line-height: 42rpx;
  211. }
  212. }
  213. </style>