withdraw.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view class="withdraw-page">
  3. <!-- 微信账户信息 -->
  4. <view class="wechat-account">
  5. <image class="avatar" :src="userInfo.imgPath || 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/logo3.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">¥{{ 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. <!-- #ifdef MP-WEIXIN -->
  26. <view class="wechat-pay">
  27. <image src="../static/wx.png" mode="aspectFit" class="wechat-icon"></image>
  28. <text>微信零钱</text>
  29. </view>
  30. <!-- #endif -->
  31. <!-- #ifdef MP-ALIPAY -->
  32. <view class="wechat-pay">
  33. <image src="../static/alipay.png" mode="aspectFit" class="wechat-icon"></image>
  34. <text>支付宝</text>
  35. </view>
  36. <!-- #endif -->
  37. </view>
  38. <!-- 提现说明 -->
  39. <view class="mt-20 flex-d common-gray">
  40. <!-- #ifdef MP-WEIXIN -->
  41. <text class="tip-item">1.用户需微信实名才能申请提现;</text>
  42. <!-- #endif -->
  43. <!-- #ifdef MP-ALIPAY -->
  44. <text class="tip-item">1.用户需支付宝实名才能申请提现;</text>
  45. <!-- #endif -->
  46. <text class="tip-item">2.用户单笔提现金额需小于200元;</text>
  47. <text class="tip-item">3.用户申请提现以后,余额会显示冻结,提现金额最晚会在72小时到账(周末、节假日顺延)</text>
  48. </view>
  49. </view>
  50. <!-- 提现按钮 -->
  51. <view class="submit-btn mt-60">
  52. <u-button type="primary" @click="submitWithdraw">确认提现</u-button>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. export default {
  58. data() {
  59. return {
  60. userInfo: {
  61. avatar: '',
  62. nickname: '',
  63. restMoney: ''
  64. },
  65. withdrawAmount: '',
  66. }
  67. },
  68. onLoad() {
  69. this.getUserInfo()
  70. },
  71. methods: {
  72. // 输入金额
  73. onAmountInput(value) {
  74. // 限制只能输入两位小数
  75. if (value.includes('.')) {
  76. const decimal = value.split('.')[1]
  77. if (decimal.length > 2) {
  78. this.withdrawAmount = Number(value).toFixed(2)
  79. }
  80. }
  81. },
  82. //获取用户信息
  83. getUserInfo() {
  84. uni.$u.http.get('/token/user/withdrawInfo').then(res => {
  85. if (res.code === 200) {
  86. this.userInfo = res.data
  87. }
  88. })
  89. },
  90. // 全部提现
  91. withdrawAll() {
  92. this.withdrawAmount = this.userInfo.restMoney
  93. },
  94. // 提交提现
  95. async submitWithdraw() {
  96. if (this.withdrawAmount <= 0) {
  97. uni.showToast({ title: '请输入提现金额', icon: 'none' })
  98. return
  99. }
  100. if (this.withdrawAmount > this.userInfo.restMoney) {
  101. uni.showToast({ title: '提现金额不能大于可提现金额', icon: 'none' })
  102. return
  103. }
  104. if (this.withdrawAmount > 200) {
  105. uni.showToast({ title: '单笔提现金额不能大于200元', icon: 'none' })
  106. return
  107. }
  108. uni.showLoading({
  109. title: '提交中...',
  110. mask: true
  111. })
  112. // 这里调用提现接口
  113. uni.$u.http.post('/token/user/withdrawApply', {
  114. money: this.withdrawAmount
  115. }).then(res => {
  116. console.log(res, "res");
  117. if (res.code === 200) {
  118. uni.showToast({ title: '提现申请成功', icon: 'success' })
  119. setTimeout(() => {
  120. uni.navigateBack()
  121. }, 1500)
  122. } else {
  123. uni.showToast({ title: res.msg, icon: 'none' })
  124. }
  125. }).finally(() => {
  126. uni.hideLoading()
  127. })
  128. }
  129. }
  130. }
  131. </script>
  132. <style lang="scss" scoped>
  133. .withdraw-page {
  134. min-height: 100vh;
  135. background: #F5F5F5;
  136. padding: 20rpx;
  137. .common-gray {
  138. background: #f9f9f9;
  139. border-radius: 12rpx;
  140. padding: 20rpx;
  141. min-height: 88rpx;
  142. }
  143. .wechat-account {
  144. background: #FFFFFF;
  145. border-radius: 12rpx;
  146. padding: 30rpx;
  147. display: flex;
  148. align-items: center;
  149. .avatar {
  150. width: 110rpx;
  151. height: 110rpx;
  152. border-radius: 50%;
  153. margin-right: 20rpx;
  154. }
  155. .account-info {
  156. .nickname {
  157. font-size: 36rpx;
  158. color: #333;
  159. font-weight: bold;
  160. display: block;
  161. margin-bottom: 10rpx;
  162. }
  163. .amount {
  164. font-size: 28rpx;
  165. color: #333;
  166. font-weight: 500;
  167. }
  168. .amount-number {
  169. font-family: Dosis;
  170. font-weight: bold;
  171. font-size: 34rpx;
  172. color: #333333;
  173. }
  174. }
  175. }
  176. .amount-input {
  177. background: #FFFFFF;
  178. border-radius: 12rpx;
  179. padding: 30rpx;
  180. margin-top: 20rpx;
  181. .label {
  182. font-size: 28rpx;
  183. color: #333;
  184. margin-bottom: 20rpx;
  185. }
  186. .input-box {
  187. display: flex;
  188. align-items: center;
  189. border-bottom: 1px solid #EEEEEE;
  190. padding: 20rpx 0;
  191. .currency {
  192. font-size: 40rpx;
  193. color: #333;
  194. margin-right: 20rpx;
  195. }
  196. :deep(.u-input) {
  197. flex: 1;
  198. input {
  199. font-size: 28rpx;
  200. &::placeholder {
  201. color: #C8C9CC;
  202. font-size: 28rpx;
  203. }
  204. }
  205. }
  206. .all-btn {
  207. font-size: 28rpx;
  208. color: #38C148;
  209. padding-left: 20rpx;
  210. }
  211. }
  212. }
  213. .wechat-pay {
  214. display: flex;
  215. align-items: center;
  216. .wechat-icon {
  217. width: 40rpx;
  218. height: 40rpx;
  219. margin-right: 10rpx;
  220. }
  221. text {
  222. font-size: 28rpx;
  223. color: #333;
  224. }
  225. }
  226. .tip-item {
  227. font-family: PingFang SC;
  228. font-weight: 400;
  229. font-size: 26rpx;
  230. color: #333333;
  231. line-height: 42rpx;
  232. }
  233. }
  234. </style>