withdraw.vue 3.5 KB

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