withdraw.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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="number" :border="false" placeholder="请输入提现金额"
  18. @input="onAmountInput" placeholder-style="font-size:50rpx;color:#c1c1c1;font-weight:400"
  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. 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. if (res.code === 200) {
  92. uni.showToast({ title: '提现申请成功', icon: 'success' })
  93. setTimeout(() => {
  94. uni.navigateBack()
  95. }, 1500)
  96. } else {
  97. uni.showToast({ title: res.msg, icon: 'none' })
  98. }
  99. }).finally(() => {
  100. uni.hideLoading()
  101. })
  102. }
  103. }
  104. }
  105. </script>
  106. <style lang="scss" scoped>
  107. .withdraw-page {
  108. min-height: 100vh;
  109. background: #F5F5F5;
  110. padding: 20rpx;
  111. .common-gray {
  112. background: #f9f9f9;
  113. border-radius: 12rpx;
  114. padding: 20rpx;
  115. min-height: 88rpx;
  116. }
  117. .wechat-account {
  118. background: #FFFFFF;
  119. border-radius: 12rpx;
  120. padding: 30rpx;
  121. display: flex;
  122. align-items: center;
  123. .avatar {
  124. width: 110rpx;
  125. height: 110rpx;
  126. border-radius: 50%;
  127. margin-right: 20rpx;
  128. }
  129. .account-info {
  130. .nickname {
  131. font-size: 36rpx;
  132. color: #333;
  133. font-weight: bold;
  134. display: block;
  135. margin-bottom: 10rpx;
  136. }
  137. .amount {
  138. font-size: 28rpx;
  139. color: #333;
  140. font-weight: 500;
  141. }
  142. .amount-number {
  143. font-family: Dosis;
  144. font-weight: bold;
  145. font-size: 34rpx;
  146. color: #333333;
  147. }
  148. }
  149. }
  150. .amount-input {
  151. background: #FFFFFF;
  152. border-radius: 12rpx;
  153. padding: 30rpx;
  154. margin-top: 20rpx;
  155. .label {
  156. font-size: 28rpx;
  157. color: #333;
  158. margin-bottom: 20rpx;
  159. }
  160. .input-box {
  161. display: flex;
  162. align-items: center;
  163. border-bottom: 1px solid #EEEEEE;
  164. padding: 20rpx 0;
  165. .currency {
  166. font-size: 40rpx;
  167. color: #333;
  168. margin-right: 20rpx;
  169. }
  170. :deep(.u-input) {
  171. flex: 1;
  172. input {
  173. font-size: 28rpx;
  174. &::placeholder {
  175. color: #C8C9CC;
  176. font-size: 28rpx;
  177. }
  178. }
  179. }
  180. .all-btn {
  181. font-size: 28rpx;
  182. color: #38C148;
  183. padding-left: 20rpx;
  184. }
  185. }
  186. }
  187. .wechat-pay {
  188. display: flex;
  189. align-items: center;
  190. .wechat-icon {
  191. width: 40rpx;
  192. height: 40rpx;
  193. margin-right: 10rpx;
  194. }
  195. text {
  196. font-size: 28rpx;
  197. color: #333;
  198. }
  199. }
  200. .tip-item {
  201. font-family: PingFang SC;
  202. font-weight: 400;
  203. font-size: 26rpx;
  204. color: #333333;
  205. line-height: 42rpx;
  206. }
  207. }
  208. </style>