多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

303 lines
7.6 KiB

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