withdraw.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <view class="page">
  3. <view class="card">
  4. <view class="input">
  5. <view class="prefix">¥</view>
  6. <view class="inner">
  7. <u-input border="none" v-model="price" :fontSize="30" type="digit" placeholder="请输入提现金额"></u-input>
  8. </view>
  9. <view class="text" @click="getAll">
  10. 全部提现
  11. </view>
  12. </view>
  13. <view class="amount">可提现金额:{{ currency(amount, {
  14. symbol: '¥',
  15. fromCents: true
  16. }).format() }}</view>
  17. <view class="title">
  18. 提现至微信
  19. </view>
  20. <view class="info">
  21. <text>
  22. 余额提现至微信钱包,提现限额200元/日
  23. 次日00:00恢复提现额度
  24. </text>
  25. </view>
  26. </view>
  27. <view class="btn">
  28. <u-button color="#1F1F1F" :loading="loading" @click="submit" size="large" shape="circle">确定</u-button>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import { transfer, getWallet } from '@/api/wallet'
  34. import currency from "@/utils/currency"
  35. export default {
  36. data() {
  37. return {
  38. currency,
  39. amount: 0,
  40. walletId: '',
  41. price: null,
  42. openid: '',
  43. loading: false,
  44. };
  45. },
  46. methods: {
  47. submit() {
  48. uni.showLoading({
  49. title: '加载中'
  50. });
  51. this.loading = true
  52. if (!isNaN(this.price) && this.price > 0) {
  53. console.log(this.walletId)
  54. transfer({
  55. appid: 'wx3be1d6d84d46cdf7',
  56. openid: this.openid,
  57. total: this.price * 100,
  58. walletId: this.walletId
  59. }).then(
  60. res => {
  61. this.loading = false
  62. if (res.state == 'Success') {
  63. uni.showToast({
  64. title: '提现成功',
  65. icon: 'success',
  66. duration: 5000
  67. });
  68. this.getWallet()
  69. this.price = null
  70. }
  71. uni.hideLoading({ noConflict: true });
  72. }
  73. )
  74. } else {
  75. uni.showToast({
  76. title: '请输入正确的金额',
  77. icon: 'none',
  78. duration: 2000
  79. });
  80. this.price = null
  81. this.loading = false
  82. uni.hideLoading({ noConflict: true });
  83. }
  84. },
  85. getAll() {
  86. if (this.amount > 0) {
  87. this.price = this.amount / 100;
  88. }
  89. },
  90. getWallet() {
  91. getWallet().then(({ content }) => {
  92. if (content) {
  93. this.amount = content.amount
  94. }
  95. })
  96. }
  97. },
  98. onShow() {
  99. const userInfo = JSON.parse(uni.getStorageSync('userInfo'));
  100. this.openid = userInfo.openId
  101. },
  102. onLoad({ amount }) {
  103. const walletId = uni.getStorageSync('walletId');
  104. this.walletId = walletId;
  105. this.amount = amount;
  106. },
  107. };
  108. </script>
  109. <style lang="scss" scoped>
  110. .page {
  111. min-height: 100vh;
  112. background-color: #F9F9F9;
  113. padding: 20rpx;
  114. .card {
  115. border-radius: 16rpx;
  116. background-color: #ffffff;
  117. padding: 40rpx;
  118. .input {
  119. display: flex;
  120. align-items: center;
  121. padding-bottom: 20rpx;
  122. .prefix {
  123. font-size: 80rpx;
  124. font-weight: bold;
  125. color: #333333;
  126. }
  127. .inner {
  128. flex: 1;
  129. padding: 0 20rpx;
  130. }
  131. .text {
  132. color: #333333;
  133. font-weight: bold;
  134. font-size: 28rpx;
  135. }
  136. }
  137. .amount {
  138. border-bottom: 1px solid #f2f2f2;
  139. padding-bottom: 30rpx;
  140. color: #AAAAAA;
  141. }
  142. .title {
  143. font-size: 32rpx;
  144. color: #333333;
  145. margin: 30rpx 0;
  146. font-weight: bold;
  147. }
  148. .info {
  149. font-size: 28rpx;
  150. color: #666666;
  151. line-height: 40rpx;
  152. margin-top: 20rpx 0 40rpx 0;
  153. }
  154. }
  155. .btn {
  156. margin: 60rpx 0;
  157. }
  158. }
  159. /deep/.u-input__content__field-wrapper__field {
  160. height: 80rpx !important;
  161. }
  162. </style>