withdraw.vue 3.4 KB

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