withdraw.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. if (res.code === 200) {
  139. uni.showToast({ title: '提现申请成功', icon: 'success' })
  140. setTimeout(() => {
  141. uni.navigateBack()
  142. }, 1500)
  143. } else {
  144. uni.showToast({ title: res.msg, icon: 'none' })
  145. }
  146. }).finally(() => {
  147. uni.hideLoading()
  148. })
  149. }
  150. }
  151. }
  152. </script>
  153. <style lang="scss" scoped>
  154. .withdraw-page {
  155. min-height: 100vh;
  156. background: #F5F5F5;
  157. padding: 20rpx;
  158. .common-gray {
  159. background: #f9f9f9;
  160. border-radius: 12rpx;
  161. padding: 20rpx;
  162. min-height: 88rpx;
  163. }
  164. .wechat-account {
  165. background: #FFFFFF;
  166. border-radius: 12rpx;
  167. padding: 30rpx;
  168. display: flex;
  169. align-items: center;
  170. .avatar {
  171. width: 110rpx;
  172. height: 110rpx;
  173. border-radius: 50%;
  174. margin-right: 20rpx;
  175. }
  176. .account-info {
  177. .nickname {
  178. font-size: 36rpx;
  179. color: #333;
  180. font-weight: bold;
  181. display: block;
  182. margin-bottom: 10rpx;
  183. }
  184. .amount {
  185. font-size: 28rpx;
  186. color: #333;
  187. font-weight: 500;
  188. }
  189. .amount-number {
  190. font-family: Dosis;
  191. font-weight: bold;
  192. font-size: 34rpx;
  193. color: #333333;
  194. }
  195. }
  196. }
  197. .amount-input {
  198. background: #FFFFFF;
  199. border-radius: 12rpx;
  200. padding: 30rpx;
  201. margin-top: 20rpx;
  202. .label {
  203. font-size: 28rpx;
  204. color: #333;
  205. margin-bottom: 20rpx;
  206. }
  207. .input-box {
  208. display: flex;
  209. align-items: center;
  210. border-bottom: 1px solid #EEEEEE;
  211. padding: 20rpx 0;
  212. .currency {
  213. font-size: 40rpx;
  214. color: #333;
  215. margin-right: 20rpx;
  216. }
  217. :deep(.u-input) {
  218. flex: 1;
  219. input {
  220. font-size: 28rpx;
  221. &::placeholder {
  222. color: #C8C9CC;
  223. font-size: 28rpx;
  224. }
  225. }
  226. }
  227. .all-btn {
  228. font-size: 28rpx;
  229. color: #38C148;
  230. padding-left: 20rpx;
  231. }
  232. }
  233. }
  234. .wechat-pay {
  235. display: flex;
  236. align-items: center;
  237. .wechat-icon {
  238. width: 40rpx;
  239. height: 40rpx;
  240. margin-right: 10rpx;
  241. }
  242. text {
  243. font-size: 28rpx;
  244. color: #333;
  245. }
  246. }
  247. .tip-item {
  248. font-family: PingFang SC;
  249. font-weight: 400;
  250. font-size: 26rpx;
  251. color: #333333;
  252. line-height: 42rpx;
  253. }
  254. .dialog-tip-content {
  255. text-align: left;
  256. font-size: 28rpx;
  257. color: #666;
  258. line-height: 48rpx;
  259. padding: 10rpx 0;
  260. .highlight {
  261. color: #ee0a24;
  262. font-weight: bold;
  263. margin: 0 4rpx;
  264. }
  265. .mt-10 {
  266. margin-top: 20rpx;
  267. }
  268. }
  269. }
  270. </style>