withdraw.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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" @click="submit" size="large" shape="circle">确定</u-button>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import { transfer } 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: 2000
  67. });
  68. }
  69. uni.hideLoading();
  70. uni.navigateBack();
  71. }
  72. )
  73. } else {
  74. uni.showToast({
  75. title: '请输入正确的金额',
  76. icon: 'none',
  77. duration: 2000
  78. });
  79. this.loading = false
  80. uni.hideLoading();
  81. }
  82. },
  83. getAll() {
  84. if (this.amount > 0) {
  85. this.price = this.amount / 100;
  86. }
  87. }
  88. },
  89. onShow() {
  90. const userInfo = JSON.parse(uni.getStorageSync('userInfo'));
  91. this.openid = userInfo.openId
  92. },
  93. onLoad({ amount }) {
  94. const walletId = uni.getStorageSync('walletId');
  95. this.walletId = walletId;
  96. this.amount = amount;
  97. },
  98. };
  99. </script>
  100. <style lang="scss" scoped>
  101. .page {
  102. min-height: 100vh;
  103. background-color: #F9F9F9;
  104. padding: 20rpx;
  105. .card {
  106. border-radius: 16rpx;
  107. background-color: #ffffff;
  108. padding: 40rpx;
  109. .input {
  110. display: flex;
  111. align-items: center;
  112. padding-bottom: 20rpx;
  113. .prefix {
  114. font-size: 80rpx;
  115. font-weight: bold;
  116. color: #333333;
  117. }
  118. .inner {
  119. flex: 1;
  120. padding: 0 20rpx;
  121. }
  122. .text {
  123. color: #333333;
  124. font-weight: bold;
  125. font-size: 28rpx;
  126. }
  127. }
  128. .amount {
  129. border-bottom: 1px solid #f2f2f2;
  130. padding-bottom: 30rpx;
  131. color: #AAAAAA;
  132. }
  133. .title {
  134. font-size: 32rpx;
  135. color: #333333;
  136. margin: 30rpx 0;
  137. font-weight: bold;
  138. }
  139. .info {
  140. font-size: 28rpx;
  141. color: #666666;
  142. line-height: 40rpx;
  143. margin-top: 20rpx 0 40rpx 0;
  144. }
  145. }
  146. .btn {
  147. margin: 60rpx 0;
  148. }
  149. }
  150. /deep/.u-input__content__field-wrapper__field {
  151. height: 80rpx !important;
  152. }
  153. </style>