|
|
@@ -6,11 +6,11 @@
|
|
|
<image class="logo" :src="`${constant.imgUrl}/logo4.png`" alt mode="widthFix" ></image>
|
|
|
<div class="title">{{ ghsInfo.name?ghsInfo.name:'' }}</div>
|
|
|
</div>
|
|
|
+ <view class="debt-detail-btn" hover-class="none" @click="goGathering">待结明细</view>
|
|
|
</div>
|
|
|
<div style="padding:10upx 0 25upx 10upx;font-size:30upx;">
|
|
|
{{ customInfo.name?customInfo.name:'' }},
|
|
|
- <text v-if="Number(customInfo.remainDebtAmount)>0">您的待结款<text style="color:red;font-weight:bold;">{{ customInfo.remainDebtAmount }}元</text>,这里直接付款销账</text>
|
|
|
- <text v-else>您的账单已结清</text>
|
|
|
+ <text v-if="customerOutstandingAmount(customInfo)>0">您待结款<text style="color:red;font-weight:bold;">{{ customerOutstandingAmount(customInfo) }}元</text>,这里付款结账</text>
|
|
|
</div>
|
|
|
<div class="module-com pay-input-wrap">
|
|
|
<pay-input-module :focus="inpFocus" :num="amount" @focusFn="focusFn" @blurFn="blurFn" @clickKey="clickKeyFn" />
|
|
|
@@ -21,7 +21,7 @@
|
|
|
<div style="text-align:center;margin-top:10upx;">
|
|
|
<image :src="imgUrl" mode="widthFix" style="width:230upx;height:230upx;margin:0 auto;"></image>
|
|
|
<view style="margin-top:10upx;margin-bottom:10upx;font-size:32upx;">支付宝扫此二维码付款</view>
|
|
|
- <button @click="downloadImg()" class="button-com red" style="margin:0 auto;width:600upx;">保存二维码</button>
|
|
|
+ <button @click="downloadImg()" class="button-com blue" style="margin:0 auto;width:380upx;">保存二维码</button>
|
|
|
<div style="margin-top:58upx;font-size:30upx;text-decoration: underline;" @click="teachPayFn()">不会用支付宝付款?点这里教您</div>
|
|
|
</div>
|
|
|
<!-- #endif -->
|
|
|
@@ -63,27 +63,47 @@
|
|
|
salt:'',
|
|
|
ghsInfo:[],
|
|
|
customInfo:[],
|
|
|
- imgUrl:''
|
|
|
+ imgUrl:'',
|
|
|
+ ghsDataLoading: false,
|
|
|
+ ghsDataLoadedKey: ''
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
...mapGetters({ orderShop: 'getOrderShop' }),
|
|
|
...mapGetters({ shopUser: 'getShopUser' })
|
|
|
},
|
|
|
- onLoad(option) {
|
|
|
+ onLoad() {
|
|
|
+ // H5 扫码付款页可能无门店登录态,globalMixins 不会调 init,此处补一次
|
|
|
// #ifdef H5
|
|
|
- this.specialInit()
|
|
|
+ if (this.$util.isEmpty(this.getLoginInfo)) {
|
|
|
+ this.init()
|
|
|
+ }
|
|
|
// #endif
|
|
|
},
|
|
|
- onShow(){
|
|
|
- this.specialInit()
|
|
|
- },
|
|
|
- mounted(){
|
|
|
- },
|
|
|
methods: {
|
|
|
+ // 客户待结金额:合并后净 balance 为负取绝对值(appVersion>=3)
|
|
|
+ customerOutstandingAmount(info) {
|
|
|
+ if (!info || this.$util.isEmpty(info)) {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ const bal = parseFloat(info.balance || 0)
|
|
|
+ if (bal < 0) {
|
|
|
+ return Math.abs(bal)
|
|
|
+ }
|
|
|
+ const remain = parseFloat(info.remainDebtAmount || 0)
|
|
|
+ return remain > 0 ? remain : 0
|
|
|
+ },
|
|
|
teachPayFn() {
|
|
|
this.pageTo({ url: "/admin/ghs/teachPay"})
|
|
|
},
|
|
|
+ // 跳转该供货商待结订单列表
|
|
|
+ goGathering() {
|
|
|
+ if (!this.id) {
|
|
|
+ this.$msg('供货商信息加载中,请稍后再试')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.pageTo({ url: `/pagesPurchase/gathering?id=${this.id}` ,type:2})
|
|
|
+ },
|
|
|
downloadImg(){
|
|
|
let that = this
|
|
|
uni.downloadFile({
|
|
|
@@ -100,68 +120,87 @@
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- init(){
|
|
|
- this.specialInit();
|
|
|
+ init() {
|
|
|
+ this.specialInit()
|
|
|
},
|
|
|
- specialInit() {
|
|
|
- let that = this
|
|
|
+ // 解析路由参数(id/salt/amount),供 init 与分享配置使用
|
|
|
+ parsePayPageParams() {
|
|
|
let id = 0
|
|
|
let salt = ''
|
|
|
- if(this.option.id && this.option.salt){
|
|
|
- id = this.option.id?this.option.id:0
|
|
|
- salt = this.option.salt?this.option.salt:''
|
|
|
- }else{
|
|
|
- if(this.option.q){
|
|
|
- let currentUrl = decodeURIComponent(this.option.q)
|
|
|
- let str = currentUrl.substring(currentUrl.lastIndexOf("?") + 1)
|
|
|
- var sceneItem = str.split("&");
|
|
|
- var arr, name, value;
|
|
|
- var sceneArray = new Array();
|
|
|
- for (var i = 0, l = sceneItem.length; i < l; i++) {
|
|
|
- arr = sceneItem[i].split("=");
|
|
|
- name = arr[0];
|
|
|
- value = arr[1];
|
|
|
- sceneArray[name] = value;
|
|
|
- }
|
|
|
- if(sceneArray.id){
|
|
|
- id =sceneArray.id
|
|
|
- }
|
|
|
- if(sceneArray.salt){
|
|
|
- salt = sceneArray.salt
|
|
|
- }
|
|
|
+ const option = this.option || {}
|
|
|
+ if (option.id && option.salt) {
|
|
|
+ id = option.id ? option.id : 0
|
|
|
+ salt = option.salt ? option.salt : ''
|
|
|
+ } else if (option.q) {
|
|
|
+ const currentUrl = decodeURIComponent(option.q)
|
|
|
+ const str = currentUrl.substring(currentUrl.lastIndexOf('?') + 1)
|
|
|
+ const sceneItem = str.split('&')
|
|
|
+ const sceneArray = {}
|
|
|
+ for (let i = 0, l = sceneItem.length; i < l; i++) {
|
|
|
+ const arr = sceneItem[i].split('=')
|
|
|
+ sceneArray[arr[0]] = arr[1]
|
|
|
+ }
|
|
|
+ if (sceneArray.id) {
|
|
|
+ id = sceneArray.id
|
|
|
+ }
|
|
|
+ if (sceneArray.salt) {
|
|
|
+ salt = sceneArray.salt
|
|
|
}
|
|
|
}
|
|
|
+ return { id, salt }
|
|
|
+ },
|
|
|
+ specialInit() {
|
|
|
+ const that = this
|
|
|
+ const { id, salt } = this.parsePayPageParams()
|
|
|
this.id = id
|
|
|
this.salt = salt
|
|
|
+ if (!id || !salt) {
|
|
|
+ return
|
|
|
+ }
|
|
|
if (this.option.amount && Number(this.option.amount) > 0) {
|
|
|
that.amount = parseFloat(Number(this.option.amount).toFixed(2))
|
|
|
}
|
|
|
- getGhsData({id:id,salt:salt}).then(res=>{
|
|
|
- if(res.code == 1){
|
|
|
- if (res.data && res.data.ghs && !this.$util.isEmpty(res.data.ghs)){
|
|
|
+ const reqKey = `${id}_${salt}`
|
|
|
+ // 防止 onShow + globalMixins.init 等重复触发同一请求
|
|
|
+ if (this.ghsDataLoading && this.ghsDataLoadedKey === reqKey) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.ghsDataLoadedKey === reqKey && !this.$util.isEmpty(this.ghsInfo)) {
|
|
|
+ this.setupPayPageUi()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.ghsDataLoading = true
|
|
|
+ this.ghsDataLoadedKey = reqKey
|
|
|
+ getGhsData({ id, salt }).then(res => {
|
|
|
+ if (res.code == 1) {
|
|
|
+ if (res.data && res.data.ghs && !this.$util.isEmpty(res.data.ghs)) {
|
|
|
that.ghsInfo = res.data.ghs
|
|
|
- that.customInfo = res.data.custom?res.data.custom:[]
|
|
|
+ that.customInfo = res.data.custom ? res.data.custom : []
|
|
|
if (!(that.option.amount && Number(that.option.amount) > 0)) {
|
|
|
- if(that.customInfo.remainDebtAmount && Number(that.customInfo.remainDebtAmount)>0){
|
|
|
- that.amount = parseFloat(that.customInfo.remainDebtAmount)
|
|
|
+ const outstanding = that.customerOutstandingAmount(that.customInfo)
|
|
|
+ if (outstanding > 0) {
|
|
|
+ that.amount = parseFloat(outstanding.toFixed(2))
|
|
|
}
|
|
|
}
|
|
|
that.imgUrl = res.data.imgUrl ? res.data.imgUrl : ''
|
|
|
}
|
|
|
}
|
|
|
+ }).finally(() => {
|
|
|
+ that.ghsDataLoading = false
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
+ this.setupPayPageUi()
|
|
|
+ },
|
|
|
+ setupPayPageUi() {
|
|
|
this.inpFocus = true
|
|
|
// #ifdef MP-WEIXIN
|
|
|
- // 设置分享
|
|
|
- let shareParams = {
|
|
|
- title: `点击结账付款`,
|
|
|
+ const shareParams = {
|
|
|
+ title: '点击结账付款',
|
|
|
desc: '',
|
|
|
imgUrl: '',
|
|
|
pagePath: `/admin/ghs/pay?id=${this.id}&salt=${this.salt}`
|
|
|
}
|
|
|
this.jweixinFn(shareParams)
|
|
|
- console.log(`/admin/ghs/pay?id=${this.id}&salt=${this.salt}`)
|
|
|
// #endif
|
|
|
},
|
|
|
toPay() {
|
|
|
@@ -320,29 +359,44 @@
|
|
|
}
|
|
|
}
|
|
|
.shop-logo-wrap {
|
|
|
- padding-bottom: 20upx;
|
|
|
- @include disFlex(center, center);
|
|
|
+ padding: 10upx 20upx 20upx;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
.logo-img {
|
|
|
- width: 100%;
|
|
|
- margin: 10upx auto;
|
|
|
+ flex: 1;
|
|
|
+ min-width: 0;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
align-items: center;
|
|
|
.logo {
|
|
|
- width: 100upx;
|
|
|
- height:100upx;
|
|
|
- border-radius: 10upx;
|
|
|
- margin-left:10upx;
|
|
|
- float: left;
|
|
|
+ width: 50upx;
|
|
|
+ height: 50upx;
|
|
|
+ border-radius: 5upx;
|
|
|
+ flex-shrink: 0;
|
|
|
}
|
|
|
- .title{
|
|
|
- margin-left:20upx;
|
|
|
- float:left;
|
|
|
- width:600upx;
|
|
|
- height:100upx;
|
|
|
- line-height:100upx;
|
|
|
- font-size:38upx;
|
|
|
+ .title {
|
|
|
+ margin-left: 20upx;
|
|
|
+ height: 50upx;
|
|
|
+ line-height: 50upx;
|
|
|
+ font-size: 38upx;
|
|
|
font-weight: bold;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ white-space: nowrap;
|
|
|
}
|
|
|
}
|
|
|
+ .debt-detail-btn {
|
|
|
+ flex-shrink: 0;
|
|
|
+ margin-left: 20upx;
|
|
|
+ padding: 12upx 24upx;
|
|
|
+ font-size: 26upx;
|
|
|
+ color: #3385FF;
|
|
|
+ border: 1upx solid #3385FF;
|
|
|
+ border-radius: 8upx;
|
|
|
+ line-height: 1.2;
|
|
|
+ }
|
|
|
}
|
|
|
// 可选优惠
|
|
|
.discount-wrap {
|