withdraw.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <view class="container flex-center flex-column">
  3. <view class="addressBack-box">
  4. <view class="consignee-box bor-line-F7F7F7">
  5. <input
  6. v-model="balance" type="number" maxlength="9" class="fs28"
  7. placeholder-class="consignee"
  8. placeholder="提现金额(元)" @input="applycheck"
  9. />
  10. </view>
  11. <view class="bankTag-box bor-line-F7F7F7 flex-row-plus flex-sp-between flex-items" @click="bankTagClick">
  12. <view class="fs28 addressTag">银行卡</view>
  13. <view>
  14. <label v-model="cardNum">{{ cardNum }}</label>
  15. <image class="arrow mar-left-20" src="../../static/images/origin/arrow.png"></image>
  16. </view>
  17. </view>
  18. <view class="apply-box">
  19. <view class="apply-withdraw" @click="applyWithdraw">申请提现</view>
  20. </view>
  21. </view>
  22. <view class="withdraw-history">
  23. <view class="history-list">
  24. <view class="history-head">
  25. <label class="history-label fs30 font-color-333">历史记录</label>
  26. </view>
  27. <view v-for="(item, index) in withdrawHistoryList" :key="index" class="history-content">
  28. <view class="withdraw-detail flex-items flex-sp-between">
  29. <view class="detail-top">
  30. <view class="detail-bottom">
  31. <label v-if="item.state == 0" class="status fs28 font-color-333">审核中</label>
  32. <label v-else-if="item.state == 1" class="status fs28 font-color-333">通过</label>
  33. <label v-else-if="item.state == 2" class="status fs28 font-color-333">拒绝</label>
  34. </view>
  35. <view>
  36. <label class="cardnum fs24 font-color-999">银行卡号:{{ item.bankCard }}</label>
  37. </view>
  38. </view>
  39. <view>
  40. <label class="apply-balance">{{ item.withdrawalMoney }}</label>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <!-- 弹窗 -->
  47. <u-select
  48. v-model="bankTagShowFlag" mode="single-column" title="银行卡" :list="bankcardselectList"
  49. @confirm="bankcardConfirm"
  50. ></u-select>
  51. <!-- <u-select v-model="bankTagShowFlag" :default-value="choosedValueList" mode="single-column" :list="list"
  52. @confirm="bankcardConfirm" title="银行卡" value-name="id" label-name="cardNum"></u-select> -->
  53. </view>
  54. </template>
  55. <script>
  56. const NET = require('../../utils/request')
  57. const API = require('../../config/api')
  58. import { getDistributorApi } from '../../api/user'
  59. export default {
  60. filters: {
  61. parseMoney(money) {
  62. return parseFloat(money / 100).toFixed(2)
  63. },
  64. parseStatus(status) {
  65. if (status == 0) {
  66. return '审核中'
  67. } else if (status == 1) {
  68. return '已通过'
  69. }
  70. return '已拒绝'
  71. }
  72. },
  73. data() {
  74. return {
  75. balance: '',
  76. cardNum: '',
  77. bankcardId: 0,
  78. bankName: '',
  79. bankTagShowFlag: false,
  80. choosedValueList: [ 0 ],
  81. bankcardList: [],
  82. withdrawHistoryList: [],
  83. bankcardselectList: [ { value: '', label: '' } ],
  84. price: 0
  85. }
  86. },
  87. onLoad(options) {
  88. this.initBankcardList()
  89. this.getBalance()
  90. },
  91. onShow() {
  92. },
  93. methods: {
  94. getBalance() {
  95. const _ = this
  96. getDistributorApi({}).then((res) => {
  97. _.price = res.data.price
  98. _.withdrawHistoryList = res.data.withdrawals
  99. })
  100. .catch((res) => {
  101. })
  102. },
  103. initBankcardList() {
  104. this.bankcardselectList = []
  105. NET.request(API.QueryBankcardList, {
  106. page: 1,
  107. pageSize: 100
  108. }, 'GET').then((res) => {
  109. this.bankcardList = res.data
  110. for (let i = 0; i < this.bankcardList.total; i++) {
  111. this.bankcardselectList.push({ value: this.bankcardList.list[i].bankName, label: this.bankcardList.list[i].bankCard })
  112. }
  113. })
  114. .catch((res) => {
  115. })
  116. },
  117. applycheck(e) {
  118. // 正则表达试
  119. e.target.value = e.target.value.match(/^\d*(\.?\d{0,2})/g)[0] || null
  120. // 重新赋值给input
  121. this.$nextTick(() => {
  122. this.balance = e.target.value
  123. })
  124. },
  125. applyWithdraw() {
  126. const _ = this
  127. if (this.balance === '') {
  128. uni.showToast({
  129. title: '提现金额不能为空',
  130. duration: 2000,
  131. icon: 'none'
  132. })
  133. } else if (this.balance > this.price) {
  134. uni.showToast({
  135. title: '余额不足,请重新输入申请金额',
  136. duration: 2000,
  137. icon: 'none'
  138. })
  139. } else if (parseFloat(this.balance) > 1000000) {
  140. uni.showToast({
  141. title: '提现金额不能超过1000000',
  142. duration: 2000,
  143. icon: 'none'
  144. })
  145. } else if (this.bankName == '' || this.bankName == null) {
  146. uni.showToast({
  147. title: '请选择银行卡',
  148. duration: 2000,
  149. icon: 'none'
  150. })
  151. } else {
  152. NET.request(API.MemberAccountWithdraw, {
  153. bankName: this.bankName,
  154. bankCard: this.cardNum,
  155. withdrawalMoney: this.balance
  156. }, 'POST').then((res) => {
  157. uni.showToast({
  158. title: '申请成功',
  159. duration: 2000,
  160. icon: 'none'
  161. })
  162. this.balance = ''
  163. this.getBalance()
  164. this.initBankcardList()
  165. })
  166. .catch((res) => {
  167. if (res.data && res.data.code == 40001) {
  168. uni.navigateTo({
  169. url: 'login'
  170. })
  171. } else if (res.data) {
  172. uni.showToast({
  173. title: res.data.msg,
  174. duration: 2000,
  175. icon: 'none'
  176. })
  177. }
  178. })
  179. }
  180. // else {
  181. // let dotPos = this.balance.indexOf(".")
  182. // let length = this.balance.length
  183. // console.log(dotPos,222)
  184. // console.log(length,333)
  185. // if (length - dotPos > 3) {
  186. // uni.showToast({
  187. // title: "提现金额只能精确到小数点后两位",
  188. // duration: 2000,
  189. // icon: 'none'
  190. // })
  191. // return
  192. // }
  193. // }
  194. },
  195. bankTagClick() {
  196. if (this.bankcardList.total > 0) {
  197. this.bankTagShowFlag = true
  198. } else {
  199. uni.showToast({
  200. title: '你还没有添加银行卡~',
  201. duration: 2000,
  202. icon: 'none'
  203. })
  204. setTimeout(function () {
  205. uni.navigateTo({
  206. url: 'addBankcard?withdraw=1'
  207. })
  208. }, 3000)
  209. }
  210. },
  211. bankcardConfirm(e) {
  212. this.cardNum = e[0].label
  213. this.bankName = e[0].value
  214. }
  215. }
  216. }
  217. </script>
  218. <style lang="scss">
  219. page {
  220. background-color: #F8F8F8;
  221. }
  222. .container {
  223. padding: 20rpx;
  224. .addressBack-box {
  225. background-color: #FFFFFF;
  226. padding: 30upx 30upx;
  227. .consignee-box {
  228. padding-bottom: 36upx;
  229. width: 690upx;
  230. margin-top: 20upx;
  231. .consignee {
  232. color: #999999;
  233. font-size: 28upx;
  234. }
  235. }
  236. .apply-withdraw {
  237. width: 100%;
  238. height: 100upx;
  239. line-height: 100upx;
  240. color: #FFEBC4;
  241. text-align: center;
  242. background: #333333;
  243. margin: 0 auto;
  244. margin-top: 20rpx;
  245. }
  246. .bankTag-box {
  247. margin-top: 19px;
  248. padding-bottom: 19px;
  249. .addressTag {
  250. color: #999999
  251. }
  252. .arrow {
  253. width: 16upx;
  254. height: 24upx;
  255. }
  256. }
  257. }
  258. .withdraw-history {
  259. margin-top: 14rpx;
  260. .history-list {
  261. background: white;
  262. padding: 30rpx;
  263. .history-label {
  264. height: 92rpx;
  265. line-height: 92rpx;
  266. }
  267. .history-content {
  268. border-top: 2rpx solid #F3F4F5;
  269. .withdraw-detail {
  270. height: 150rpx;
  271. .apply-balance {
  272. width: 160rpx;
  273. height: 58rpx;
  274. line-height: 58rpx;
  275. font-size: 24rpx;
  276. background: #EEEEEE;
  277. display: block;
  278. text-align: center;
  279. color: #999999;
  280. }
  281. }
  282. }
  283. }
  284. }
  285. }
  286. .content {
  287. font-size: 35rpx;
  288. width: 500rpx;
  289. .btn {
  290. margin-bottom: 20rpx;
  291. width: 200rpx;
  292. background-image: linear-gradient(135deg, #FFA100 10%, #FF7911 100%);
  293. }
  294. }
  295. </style>