<!--
|
* @Author: 小明丶
|
* @Date: 2020-11-26 15:12:47
|
* @LastEditors: 小明丶
|
* @LastEditTime: 2020-12-16 10:01:32
|
* @Description: 商户收款页面
|
-->
|
<template>
|
<div class="store-shsk-page">
|
<van-nav-bar
|
title="商户收款"
|
left-text="返回"
|
left-arrow
|
@click-left="onClickLeft"
|
style="line-height: 43px"
|
>
|
<i
|
class="iconfont iconzuojiantou"
|
slot="left"
|
style="font-size: 25px"
|
></i>
|
</van-nav-bar>
|
<div class="content">
|
<p class="title">收款金额</p>
|
<div class="input-box">
|
<span>¥</span>
|
<input type="text" v-model="price" placeholder="请输入收款金额" />
|
</div>
|
<p class="tip">本次收款渠道手续费:{{rate}}%</p>
|
</div>
|
<button
|
class="getQrCode"
|
@click="getQrCode"
|
:style="{ background: $store.state.backColor, color: '#fff' }"
|
>
|
生成收款二维码
|
</button>
|
<button
|
v-if="$route.query.zfbVersion != 5"
|
class="toQrCode"
|
@click="toQrCode"
|
:style="{
|
background: '#fff',
|
border: `solid 1px ${$store.state.backColor}`,
|
color: $store.state.backColor,
|
}"
|
>
|
扫描用户付款码
|
</button>
|
</div>
|
</template>
|
<script>
|
export default {
|
data() {
|
return {
|
rate:'0.38',
|
price:'',//金额
|
};
|
},
|
created() {
|
this.getWeChatConfig();
|
},
|
mounted(){
|
this.$api.shskProdFee({
|
payMethod:this.$route.query.payMethod,
|
zfbVersion:this.$route.query.zfbVersion
|
}).then(res=>{
|
this.rate = res.body.fee
|
})
|
},
|
methods: {
|
onClickLeft() {
|
this.$router.go(-1);
|
},
|
getQrCode(){
|
if(!this.price){
|
this.$tool.toast('交易金额不能为空');
|
return
|
}
|
this.$api.facepay_create({
|
payAmt:this.price,
|
term:0,
|
payType: 1,//反扫
|
zfbVersion:this.$route.query.zfbVersion,
|
payMethod:this.$route.query.payMethod
|
}).then(res=>{
|
let url = res.body.payQrCodeUrl;
|
let id = res.body.orderId;
|
this.$router.push({
|
path:'/getShskQRCode',
|
query:{
|
url:res.body.payQrCodeUrl,
|
orderId:res.body.orderId
|
}
|
})
|
})
|
},
|
toQrCode() {
|
let that = this
|
if(!this.price){
|
this.$tool.toast('交易金额不能为空');
|
return
|
}
|
this.checkIsReady().then(() => {
|
wx.scanQRCode({
|
needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
|
scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
|
success: function (res) {
|
// 当needResult 为 1 时,扫码返回的结果
|
// 扫码成功后调用接口
|
console.log(res)
|
that.$api.facepay_create({
|
payAmt:that.price,
|
term:0,
|
payType: 2,//正扫
|
zfbVersion:that.$route.query.zfbVersion,
|
payMethod:that.$route.query.payMethod,
|
authCode: res.resultStr,
|
}).then(res=>{
|
let id = res.body.orderId;
|
that.$router.push({
|
path:'/shsk-payResult',
|
query:{
|
orderId:id,
|
needSearch:1
|
}
|
})
|
})
|
},
|
});
|
});
|
},
|
// 异步准备微信环境
|
checkIsReady() {
|
return new Promise((resolve, reject) => {
|
wx.ready(() => resolve());
|
wx.error(err => reject(console.log(res + "wx.error")));
|
});
|
},
|
// 获取微信配置
|
getWeChatConfig() {
|
let url = location.href.split("#")[0];
|
// let url = 'http://t.finlean.com/'
|
this.$api
|
.getTokenInfo({
|
url: url,
|
})
|
.then((res) => {
|
// 获取微信配置
|
wx.config({
|
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印
|
appId: res.body.appId, // 必填,公众号的唯一标识
|
timestamp: res.body.timestamp, // 必填,生成签名的时间戳
|
nonceStr: res.body.nonceStr, // 必填,生成签名的随机串
|
signature: res.body.signature, // 必填,签名
|
jsApiList: ["checkJsApi", "scanQRCode"], // 必填,需要使用的JS接口列表
|
openTagList: [], // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
|
});
|
});
|
},
|
},
|
};
|
</script>
|
<style lang="less" scoped>
|
.store-shsk-page {
|
& {
|
min-height: 100vh;
|
background: #f5f5f5;
|
text-align: center;
|
}
|
.content {
|
& {
|
text-align: left;
|
background: #fff;
|
width: 359px;
|
// height: 154px;
|
margin: auto;
|
margin-top: 10px;
|
box-sizing: border-box;
|
padding: 32px 12px;
|
}
|
.title {
|
font-size: 14px;
|
font-family: PingFang SC;
|
font-weight: 500;
|
color: #333333;
|
}
|
.input-box {
|
border-bottom: 1px solid #e6e6e6;
|
padding: 24px 0 7px 0;
|
span {
|
font-size: 20px;
|
font-family: PingFang SC;
|
font-weight: bold;
|
color: #333333;
|
}
|
input {
|
border: 0;
|
outline: none;
|
height: 30px;
|
font-size: 20px;
|
}
|
input::placeholder {
|
font-size: 20px;
|
}
|
}
|
.tip {
|
font-size: 12px;
|
font-family: PingFang SC;
|
font-weight: 500;
|
color: #999999;
|
margin-top: 16px;
|
}
|
}
|
.getQrCode {
|
width: 320px;
|
height: 44px;
|
outline: none;
|
border-radius: 22px;
|
border: 0;
|
margin-top: 42px;
|
}
|
.toQrCode {
|
width: 320px;
|
height: 44px;
|
outline: none;
|
border-radius: 22px;
|
margin-top: 16px;
|
}
|
}
|
</style>
|