withdraw.vue 7.0 KB

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