withdraw.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <view class="withdraw-page">
  3. <!-- 微信账户信息 -->
  4. <view class="wechat-account">
  5. <image class="avatar" :src="userInfo.imgPath" 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">¥{{ userInfo.restMoney }}</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="digit" :border="false" placeholder="请输入提现金额"
  18. @input="onAmountInput" placeholder-style="font-size:50rpx;color:#c1c1c1;font-weight:400"
  19. :custom-style="{ fontSize: '50rpx' }" :max="userInfo.restMoney"></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. restMoney: ''
  51. },
  52. withdrawAmount: '',
  53. }
  54. },
  55. onLoad() {
  56. this.getUserInfo()
  57. },
  58. methods: {
  59. // 输入金额
  60. onAmountInput(value) {
  61. // 限制只能输入两位小数
  62. if (value.includes('.')) {
  63. const decimal = value.split('.')[1]
  64. if (decimal.length > 2) {
  65. this.withdrawAmount = Number(value).toFixed(2)
  66. }
  67. }
  68. },
  69. //获取用户信息
  70. getUserInfo() {
  71. uni.$u.http.get('/token/user/withdrawInfo').then(res => {
  72. if (res.code === 200) {
  73. this.userInfo = res.data
  74. }
  75. })
  76. },
  77. // 全部提现
  78. withdrawAll() {
  79. this.withdrawAmount = this.userInfo.restMoney
  80. },
  81. // 提交提现
  82. async submitWithdraw() {
  83. uni.showLoading({
  84. title: '提交中...',
  85. mask: true
  86. })
  87. // 这里调用提现接口
  88. uni.$u.http.post('/token/user/withdrawApply', {
  89. money: this.withdrawAmount
  90. }).then(res => {
  91. console.log(res, "res");
  92. if (res.code === 200) {
  93. uni.showToast({ title: '提现申请成功', icon: 'success' })
  94. setTimeout(() => {
  95. uni.navigateBack()
  96. }, 1500)
  97. } else {
  98. uni.showToast({ title: res.msg, icon: 'none' })
  99. }
  100. }).finally(() => {
  101. uni.hideLoading()
  102. })
  103. }
  104. }
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. .withdraw-page {
  109. min-height: 100vh;
  110. background: #F5F5F5;
  111. padding: 20rpx;
  112. .common-gray {
  113. background: #f9f9f9;
  114. border-radius: 12rpx;
  115. padding: 20rpx;
  116. min-height: 88rpx;
  117. }
  118. .wechat-account {
  119. background: #FFFFFF;
  120. border-radius: 12rpx;
  121. padding: 30rpx;
  122. display: flex;
  123. align-items: center;
  124. .avatar {
  125. width: 110rpx;
  126. height: 110rpx;
  127. border-radius: 50%;
  128. margin-right: 20rpx;
  129. }
  130. .account-info {
  131. .nickname {
  132. font-size: 36rpx;
  133. color: #333;
  134. font-weight: bold;
  135. display: block;
  136. margin-bottom: 10rpx;
  137. }
  138. .amount {
  139. font-size: 28rpx;
  140. color: #333;
  141. font-weight: 500;
  142. }
  143. .amount-number {
  144. font-family: Dosis;
  145. font-weight: bold;
  146. font-size: 34rpx;
  147. color: #333333;
  148. }
  149. }
  150. }
  151. .amount-input {
  152. background: #FFFFFF;
  153. border-radius: 12rpx;
  154. padding: 30rpx;
  155. margin-top: 20rpx;
  156. .label {
  157. font-size: 28rpx;
  158. color: #333;
  159. margin-bottom: 20rpx;
  160. }
  161. .input-box {
  162. display: flex;
  163. align-items: center;
  164. border-bottom: 1px solid #EEEEEE;
  165. padding: 20rpx 0;
  166. .currency {
  167. font-size: 40rpx;
  168. color: #333;
  169. margin-right: 20rpx;
  170. }
  171. :deep(.u-input) {
  172. flex: 1;
  173. input {
  174. font-size: 28rpx;
  175. &::placeholder {
  176. color: #C8C9CC;
  177. font-size: 28rpx;
  178. }
  179. }
  180. }
  181. .all-btn {
  182. font-size: 28rpx;
  183. color: #38C148;
  184. padding-left: 20rpx;
  185. }
  186. }
  187. }
  188. .wechat-pay {
  189. display: flex;
  190. align-items: center;
  191. .wechat-icon {
  192. width: 40rpx;
  193. height: 40rpx;
  194. margin-right: 10rpx;
  195. }
  196. text {
  197. font-size: 28rpx;
  198. color: #333;
  199. }
  200. }
  201. .tip-item {
  202. font-family: PingFang SC;
  203. font-weight: 400;
  204. font-size: 26rpx;
  205. color: #333333;
  206. line-height: 42rpx;
  207. }
  208. }
  209. </style>