withdraw.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. {{ info.isTransfer ? '可以提现,当前您可以进行提现的金额:' + (info.total/100) +'元' : '不可提现,' + info.remark }}
  23. 提现规则:
  24. {{ getRole() }},您可进行上月返利额提现操作余额提现至微信钱包,提现限额单笔最低{{ info.minTotal / 100}}元/笔限额{{ info.maxTotal / 100 }}元/日,{{ getRole(true) }}恢复提现额度
  25. </text>
  26. </view>
  27. </view>
  28. <view class="btn">
  29. <u-button color="#1F1F1F" :loading="loading" @click="submit" size="large" shape="circle">确定</u-button>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import { transfer, getWallet, transferRulerInfo } from '@/api/wallet'
  35. import currency from "@/utils/currency"
  36. export default {
  37. data() {
  38. return {
  39. currency,
  40. amount: 0,
  41. walletId: '',
  42. price: null,
  43. openid: '',
  44. loading: false,
  45. info: {
  46. commission: 1,
  47. createTime: 0,
  48. dayMaxTotal: 0,
  49. endDay: null,
  50. endHour: 0,
  51. endMinute: 0,
  52. id: "",
  53. isTransfer: false,
  54. maxTotal: 0,
  55. minTotal: 0,
  56. remark: "可提现余额不足",
  57. size: 0,
  58. startDay: null,
  59. startHour: 0,
  60. startMinute: 0,
  61. timeUnit: "DAY",
  62. total: 0,
  63. updateTime: 0,
  64. }
  65. };
  66. },
  67. methods: {
  68. getRole(isEnd) {
  69. if (this.info.timeUnit == 'DAY') {
  70. let text = ''
  71. if (isEnd) {
  72. text = `次日${this.info.startHour.toString().padStart(2, 0)}:${this.info.startMinute.toString().padStart(2, 0)}`
  73. } else {
  74. text = `每日${this.info.startHour.toString().padStart(2, 0)}:${this.info.startMinute.toString().padStart(2, 0)}-${this.info.endHour.toString().padStart(2, 0)}:${this.info.endMinute.toString().padStart(2, 0)}`
  75. }
  76. return text
  77. } else if (this.info.timeUnit == 'MONTH') {
  78. let text = ''
  79. if (isEnd) {
  80. return `次月${this.info.startDay}日`
  81. } else {
  82. return `每月${this.info.startDay}日-${this.info.endDay}日`
  83. }
  84. return text
  85. } else {
  86. return '每日'
  87. }
  88. },
  89. submit() {
  90. uni.showLoading({
  91. title: '加载中'
  92. });
  93. this.loading = true
  94. if (!isNaN(this.price) && this.price > 0) {
  95. console.log(this.walletId)
  96. transfer({
  97. appid: 'wx3be1d6d84d46cdf7',
  98. openid: this.openid,
  99. total: this.price * 100,
  100. walletId: this.walletId
  101. }).then(
  102. res => {
  103. this.loading = false
  104. if (res.state == 'Success') {
  105. uni.showToast({
  106. title: '提现成功',
  107. icon: 'success',
  108. duration: 5000
  109. });
  110. this.getWallet()
  111. this.price = null
  112. }
  113. uni.hideLoading({ noConflict: true });
  114. }
  115. )
  116. } else {
  117. uni.showToast({
  118. title: '请输入正确的金额',
  119. icon: 'none',
  120. duration: 2000
  121. });
  122. this.price = null
  123. this.loading = false
  124. uni.hideLoading({ noConflict: true });
  125. }
  126. },
  127. getAll() {
  128. if (this.amount > 0) {
  129. this.price = this.amount / 100;
  130. }
  131. },
  132. getWallet() {
  133. getWallet().then(({ content }) => {
  134. if (content) {
  135. this.amount = content.amount
  136. }
  137. })
  138. }
  139. },
  140. onShow() {
  141. const userInfo = JSON.parse(uni.getStorageSync('userInfo'));
  142. this.openid = userInfo.openId;
  143. transferRulerInfo().then(res => {
  144. if (res.success) {
  145. this.info = res.content
  146. }
  147. })
  148. },
  149. onLoad({ amount }) {
  150. const walletId = uni.getStorageSync('walletId');
  151. this.walletId = walletId;
  152. this.amount = amount;
  153. },
  154. };
  155. </script>
  156. <style lang="scss" scoped>
  157. .page {
  158. min-height: 100vh;
  159. background-color: #F9F9F9;
  160. padding: 20rpx;
  161. .card {
  162. border-radius: 16rpx;
  163. background-color: #ffffff;
  164. padding: 40rpx;
  165. .input {
  166. display: flex;
  167. align-items: center;
  168. padding-bottom: 20rpx;
  169. .prefix {
  170. font-size: 80rpx;
  171. font-weight: bold;
  172. color: #333333;
  173. }
  174. .inner {
  175. flex: 1;
  176. padding: 0 20rpx;
  177. }
  178. .text {
  179. color: #333333;
  180. font-weight: bold;
  181. font-size: 28rpx;
  182. }
  183. }
  184. .amount {
  185. border-bottom: 1px solid #f2f2f2;
  186. padding-bottom: 30rpx;
  187. color: #AAAAAA;
  188. }
  189. .title {
  190. font-size: 32rpx;
  191. color: #333333;
  192. margin: 30rpx 0;
  193. font-weight: bold;
  194. }
  195. .info {
  196. font-size: 28rpx;
  197. color: #666666;
  198. line-height: 40rpx;
  199. margin-top: 20rpx 0 40rpx 0;
  200. }
  201. }
  202. .btn {
  203. margin: 60rpx 0;
  204. }
  205. }
  206. /deep/.u-input__content__field-wrapper__field {
  207. height: 80rpx !important;
  208. }
  209. </style>