withdraw.vue 7.1 KB

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