From b34f21f6048a1be23ed3b27bceef774e9f84c914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=93=E5=B9=B3=E8=89=BA?= <52643018@qq.com> Date: Thu, 23 Sep 2021 16:55:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E5=AE=8C=E6=88=90=E5=95=86?= =?UTF-8?q?=E5=AE=B6=E4=B8=AD=E5=BF=83=E6=8F=90=E7=8E=B0=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=AF=B9=E6=8E=A5=E5=95=86=E5=AE=B6?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E6=89=AB=E7=A0=81=E8=BE=93=E5=85=A5=E9=87=91?= =?UTF-8?q?=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/business/center/center.vue | 4 +- pages/business/payment/money.vue | 34 +++++++- pages/business/withdrawal/withdrawal.vue | 104 ++++++++++++++++++----- 3 files changed, 116 insertions(+), 26 deletions(-) diff --git a/pages/business/center/center.vue b/pages/business/center/center.vue index bcf0334..5214f62 100644 --- a/pages/business/center/center.vue +++ b/pages/business/center/center.vue @@ -138,7 +138,9 @@ console.log(res); // 二维码内的内容 let result = res.result; - this.$url('/pages/business/payment/money'); + + // 成功后页面跳转 TODO 待对接判断result + this.$url('/pages/business/payment/money?user_id=1'); } }) } diff --git a/pages/business/payment/money.vue b/pages/business/payment/money.vue index fef19e1..7b354e6 100644 --- a/pages/business/payment/money.vue +++ b/pages/business/payment/money.vue @@ -23,15 +23,41 @@ export default { data(){ return { - money: '' + money: '', + user_id: 0 } }, - onLoad(){ - + onLoad(options){ + if(options.user_id){ + this.user_id = options.user_id; + }else{ + this.$msg('二维码错误', {icon: 'error'}).then(() => { + this.$toBack(); + }) + } }, methods: { confirm(){ - this.$url('/pages/business/payment/wait', {type: 'redirect'}) + if(!this.money) return this.$msg('请输入金额'); + if(!this.$check(this.money, 'money')) return this.$msg('请输入正确的金额'); + let token = this.$cookieStorage.get('store_token'); + this.$http.post({ + api: 'api/supplier/offline/order', + data: { + user_id: this.user_id, + amount: this.money + }, + header: { + token: token + } + }).then(res => { + if(res.data.code == 200){ + this.$url('/pages/business/payment/wait', {type: 'redirect'}) + }else{ + let msg = res.data.msg || '网络错误'; + this.$msg(msg); + } + }) } } } diff --git a/pages/business/withdrawal/withdrawal.vue b/pages/business/withdrawal/withdrawal.vue index 9b3dbea..48e64f1 100644 --- a/pages/business/withdrawal/withdrawal.vue +++ b/pages/business/withdrawal/withdrawal.vue @@ -2,19 +2,19 @@ - - 支付宝 - - - 银行卡 + + {{ item }} + - - 雅诗兰黛专卖店 + + {{ brand.name }} @@ -79,7 +79,10 @@ - 提现金额 + + 提现金额 + (当前可用余额{{ balance }}元) + @@ -92,12 +95,10 @@ 输入金额超过可用余额 - + 提现说明 - 1、提现到账时间为T+1; - 2、提现最高单笔为10000元; - 3、提现手续单笔收费10%; + {{ item }} @@ -109,6 +110,7 @@ export default { data(){ return { + tab_list: ['支付宝', '银行卡'], current: 0, // 支付宝0、银行卡1 alipay_name: '', // 支付宝姓名 alipay_account: '', // 支付宝账号 @@ -116,19 +118,41 @@ bank_sub_branch: '', // 银行卡所属支行 bank_number: '', // 银行卡号 bank_account_name: '', // 银行卡开户名 - money: '' // 提现金额 + money: '', // 提现金额 + token: '', + remark: [], // 提现说明 + brand: {}, // 商家信息 + balance: 0 // 当前可用余额 } }, computed: { isMoney(){ - // TODO 假设我现在的余额为10块钱 - return Number(this.money) > 10; + return Number(this.money) > this.balance; } }, onLoad(){ - + let token = this.$cookieStorage.get('store_token'); + this.token = token; + this.getApplyInfo(); }, methods: { + // 提现申请信息获取 + getApplyInfo(){ + this.$http.get({ + api: 'api/supplier/apply_info', + header: { + token: this.token + } + }).then(res => { + this.balance = res.data.data.balance; + this.brand = res.data.data.brand; + this.remark = res.data.data.remark; + }) + }, + // 切换tab + switchTab(index){ + this.current = index; + }, confirm(){ if(this.current == 0){ // 提现到支付宝 @@ -137,7 +161,7 @@ if(!this.money) return this.$msg('请输入提现金额'); if(this.isMoney) return this.$msg('提现金额超出当前余额'); if(this.money <= 0) return this.$msg('提现金额需大于0'); - this.launch(); + this.launch('alipay'); }else if(this.current == 1){ // 提现到银行卡 if(!this.bank_name) return this.$msg('请输入银行名称'); @@ -147,12 +171,50 @@ if(!this.money) return this.$msg('请输入提现金额'); if(this.isMoney) return this.$msg('提现金额超出当前余额'); if(this.money <= 0) return this.$msg('提现金额需大于0'); - this.launch(); + this.launch('bankcard'); } }, - launch(){ - // TODO 在此发起网络请求 - console.log("发起提现"); + launch(type_name){ + uni.showLoading({ + title: '正在提现中' + }) + let par = { + type: type_name, + value: this.money + }; + if(type_name == 'bankcard'){ + par.bank_name = this.bank_name; + par.bank_branch = this.bank_sub_branch; + par.bank_number = this.bank_number; + par.bank_username = this.bank_account_name; + }else if(type_name == 'alipay'){ + par.alipay_name = this.alipay_name; + par.alipay_account = this.alipay_account; + } + + this.$http.post({ + api: 'api/supplier/cash_apply', + data: par, + header: { + token: this.token + } + }).then(res => { + if(res.data.code == 200){ + if(type_name == 'bankcard'){ + this.bank_name = ''; + this.bank_sub_branch = ''; + this.bank_number = ''; + this.bank_account_name = ''; + }else if(type_name == 'alipay'){ + this.alipay_name = ''; + this.alipay_account = ''; + } + this.money = ''; + this.$msg('提现成功', {icon: 'success'}); + this.getApplyInfo(); + } + uni.hideLoading(); + }).catch(err => uni.hideLoading()); } } }