withdraw.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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="showConfirmDialog">确认提现</u-button>
  53. </view>
  54. <!-- 提现确认弹窗 -->
  55. <common-dialog ref="withdrawDialog" title="温馨提示" cancelText="继续提现" confirmText="购买书籍" @confirm="goToHome" @cancel="submitWithdraw" :customStyle="{ paddingBottom: '20rpx' }">
  56. <view class="dialog-tip-content">
  57. <view>亲,余额不支持充值哦!余额购买商城所有商品可享<text class="highlight">8折优惠</text>。</view>
  58. <view class="mt-10">发起提现后,平台会逐一审核付款,提现金额最晚会在<text class="highlight">72小时到账</text>(周末/节假日顺延)</view>
  59. </view>
  60. </common-dialog>
  61. </view>
  62. </template>
  63. <script>
  64. import CommonDialog from '@/components/common-dialog.vue';
  65. export default {
  66. components: {
  67. CommonDialog
  68. },
  69. data() {
  70. return {
  71. userInfo: {
  72. avatar: '',
  73. nickname: '',
  74. restMoney: ''
  75. },
  76. withdrawAmount: '',
  77. }
  78. },
  79. onLoad() {
  80. this.getUserInfo()
  81. },
  82. methods: {
  83. // 输入金额
  84. onAmountInput(value) {
  85. // 限制只能输入两位小数
  86. if (value.includes('.')) {
  87. const decimal = value.split('.')[1]
  88. if (decimal.length > 2) {
  89. this.withdrawAmount = Number(value).toFixed(2)
  90. }
  91. }
  92. },
  93. //获取用户信息
  94. getUserInfo() {
  95. uni.$u.http.get('/token/user/withdrawInfo').then(res => {
  96. if (res.code === 200) {
  97. this.userInfo = res.data
  98. }
  99. })
  100. },
  101. // 全部提现
  102. withdrawAll() {
  103. this.withdrawAmount = this.userInfo.restMoney
  104. },
  105. // 显示确认提现弹窗
  106. showConfirmDialog() {
  107. if (this.withdrawAmount <= 0) {
  108. uni.showToast({ title: '请输入提现金额', icon: 'none' })
  109. return
  110. }
  111. if (this.withdrawAmount > this.userInfo.restMoney) {
  112. uni.showToast({ title: '提现金额不能大于可提现金额', icon: 'none' })
  113. return
  114. }
  115. if (this.withdrawAmount > 200) {
  116. uni.showToast({ title: '单笔提现金额不能大于200元', icon: 'none' })
  117. return
  118. }
  119. // 参数校验通过后显示弹窗
  120. this.$refs.withdrawDialog.openPopup()
  121. },
  122. // 跳转首页购买书籍
  123. goToHome() {
  124. uni.switchTab({
  125. url: '/pages/sell/index'
  126. })
  127. },
  128. // 提交提现
  129. async submitWithdraw() {
  130. uni.showLoading({
  131. title: '提交中...',
  132. mask: true
  133. })
  134. // 这里调用提现接口
  135. uni.$u.http.post('/token/user/withdrawApply', {
  136. money: this.withdrawAmount
  137. }).then(res => {
  138. console.log(res, "res");
  139. if (res.code === 200) {
  140. uni.showToast({ title: '提现申请成功', icon: 'success' })
  141. setTimeout(() => {
  142. uni.navigateBack()
  143. }, 1500)
  144. } else {
  145. uni.showToast({ title: res.msg, icon: 'none' })
  146. }
  147. }).finally(() => {
  148. uni.hideLoading()
  149. })
  150. }
  151. }
  152. }
  153. </script>
  154. <style lang="scss" scoped>
  155. .withdraw-page {
  156. min-height: 100vh;
  157. background: #F5F5F5;
  158. padding: 20rpx;
  159. .common-gray {
  160. background: #f9f9f9;
  161. border-radius: 12rpx;
  162. padding: 20rpx;
  163. min-height: 88rpx;
  164. }
  165. .wechat-account {
  166. background: #FFFFFF;
  167. border-radius: 12rpx;
  168. padding: 30rpx;
  169. display: flex;
  170. align-items: center;
  171. .avatar {
  172. width: 110rpx;
  173. height: 110rpx;
  174. border-radius: 50%;
  175. margin-right: 20rpx;
  176. }
  177. .account-info {
  178. .nickname {
  179. font-size: 36rpx;
  180. color: #333;
  181. font-weight: bold;
  182. display: block;
  183. margin-bottom: 10rpx;
  184. }
  185. .amount {
  186. font-size: 28rpx;
  187. color: #333;
  188. font-weight: 500;
  189. }
  190. .amount-number {
  191. font-family: Dosis;
  192. font-weight: bold;
  193. font-size: 34rpx;
  194. color: #333333;
  195. }
  196. }
  197. }
  198. .amount-input {
  199. background: #FFFFFF;
  200. border-radius: 12rpx;
  201. padding: 30rpx;
  202. margin-top: 20rpx;
  203. .label {
  204. font-size: 28rpx;
  205. color: #333;
  206. margin-bottom: 20rpx;
  207. }
  208. .input-box {
  209. display: flex;
  210. align-items: center;
  211. border-bottom: 1px solid #EEEEEE;
  212. padding: 20rpx 0;
  213. .currency {
  214. font-size: 40rpx;
  215. color: #333;
  216. margin-right: 20rpx;
  217. }
  218. :deep(.u-input) {
  219. flex: 1;
  220. input {
  221. font-size: 28rpx;
  222. &::placeholder {
  223. color: #C8C9CC;
  224. font-size: 28rpx;
  225. }
  226. }
  227. }
  228. .all-btn {
  229. font-size: 28rpx;
  230. color: #38C148;
  231. padding-left: 20rpx;
  232. }
  233. }
  234. }
  235. .wechat-pay {
  236. display: flex;
  237. align-items: center;
  238. .wechat-icon {
  239. width: 40rpx;
  240. height: 40rpx;
  241. margin-right: 10rpx;
  242. }
  243. text {
  244. font-size: 28rpx;
  245. color: #333;
  246. }
  247. }
  248. .tip-item {
  249. font-family: PingFang SC;
  250. font-weight: 400;
  251. font-size: 26rpx;
  252. color: #333333;
  253. line-height: 42rpx;
  254. }
  255. .dialog-tip-content {
  256. text-align: left;
  257. font-size: 28rpx;
  258. color: #666;
  259. line-height: 48rpx;
  260. padding: 10rpx 0;
  261. .highlight {
  262. color: #ee0a24;
  263. font-weight: bold;
  264. margin: 0 4rpx;
  265. }
  266. .mt-10 {
  267. margin-top: 20rpx;
  268. }
  269. }
  270. }
  271. </style>