增加:在线买单 - 增加餐费积分抵扣功能

This commit is contained in:
wuhui_zzw 2024-06-21 15:37:15 +08:00
parent 29b4678879
commit 9e6a9ecdff
1 changed files with 327 additions and 211 deletions

View File

@ -22,6 +22,21 @@
</view> </view>
</view> </view>
</view> </view>
<!--积分抵扣-->
<view class="integral" v-if="Number(integral_surplus) > 0 && Number(pay_info.money) > 0">
<view class="box-title">餐费积分抵扣</view>
<view class="box-content">
<view class="use-info">
<text class="iconfont icon-pc-jifen"></text>
<view class="title">使用餐费积分</view>
<input class="use-input" v-model="integral_use" type='number' step="0.01" placeholder="请输入要使用的餐费积分数量!" />
</view>
<view class="hold-info">
<view class="left">剩余餐费积分{{ integral_surplus || '0.00' }}</view>
<view class="right">餐费积分抵扣{{ integral_use || '0.00' }}</view>
</view>
</view>
</view>
<!--支付方式--> <!--支付方式-->
<view class="pay-type"> <view class="pay-type">
<view class="box-title">支付方式</view> <view class="box-title">支付方式</view>
@ -91,7 +106,8 @@ import {mapGetters} from "vuex";
import authorize from '@/components/Authorize'; import authorize from '@/components/Authorize';
import emptyPage from '@/components/emptyPage.vue'; import emptyPage from '@/components/emptyPage.vue';
import spread from "@/libs/spread"; import spread from "@/libs/spread";
import {getUserInfo} from "@/api/user"; import {getUserInfo,merShareholdersIntegralStatistics} from "@/api/user";
const app = getApp(); const app = getApp();
export default { export default {
@ -157,21 +173,25 @@ export default {
}, },
], ],
now_money: 0, now_money: 0,
//
integral_surplus: 0,
integral_use: '',
}; };
}, },
computed: { computed: {
...mapGetters(['isLogin', 'userInfo', 'viewColor']) ...mapGetters(['isLogin', 'userInfo', 'viewColor'])
}, },
onLoad(options) { onLoad(options) {
let mer_id = options.mer_id || 0;
// //
if(options.scene){ if(options.scene){
// console.log(" - ",options.scene) // console.log(" - ",options.scene)
var scene = this.$util.getUrlParams(decodeURIComponent(options.scene)); var scene = this.$util.getUrlParams(decodeURIComponent(options.scene));
// console.log(" - ",scene) // console.log(" - ",scene)
this.default_mer_id = scene.mer_id || 0; mer_id = scene.mer_id || 0;
this.mer_search.mer_id = scene.mer_id || 0;
} }
this.default_mer_id = mer_id || 0;
this.mer_search.mer_id = mer_id || 0;
// //
if (!this.isLogin) { if (!this.isLogin) {
// //
@ -185,6 +205,22 @@ export default {
if(options.spread) spread(options.spread, this.isLogin) if(options.spread) spread(options.spread, this.isLogin)
}, },
onReachBottom: function () {}, onReachBottom: function () {},
watch: {
//
'pay_info.money': {
handler() {
this.computeUseIntegral();
},
immediate: true
},
// 使
'integral_use': {
handler() {
this.computeUseIntegral();
},
immediate: true
}
},
methods: { methods: {
// //
onLoadFun() { onLoadFun() {
@ -207,6 +243,8 @@ export default {
getUserInfo().then(res => { getUserInfo().then(res => {
_this.now_money = res.data.now_money _this.now_money = res.data.now_money
}); });
//
_this.shareholdersIntegralInfo();
}, },
// - // -
merShowPopup(){ merShowPopup(){
@ -248,7 +286,8 @@ export default {
let _this = this; let _this = this;
let payInfo = Object.assign({},_this.pay_info); let payInfo = Object.assign({},_this.pay_info);
payInfo.mer_id = _this.mer_info.mer_id; payInfo.mer_id = _this.mer_info.mer_id;
console.log('支付类型',payInfo.pay_type) payInfo.integral_use = _this.integral_use || 0;
console.log('支付类型', payInfo)
if (payInfo.pay_type == 'weixin') { if (payInfo.pay_type == 'weixin') {
// #ifdef H5 // #ifdef H5
payInfo.pay_type = _this.$wechat.isWeixin() ? 'weixin' : 'h5' payInfo.pay_type = _this.$wechat.isWeixin() ? 'weixin' : 'h5'
@ -264,15 +303,16 @@ export default {
title: '订单处理中...', title: '订单处理中...',
mask: true mask: true
}); });
onlinePayment(payInfo) onlinePayment(payInfo).then(res => {
.then(res => { if (res.status == 200) {
let backUrl = `/pages/users/online_payment/payment/index?mer_id=${_this.mer_search.mer_id}`;
let backTab = 5;
let status = res.data.status, let status = res.data.status,
orderId = res.data.result.order_id, orderId = res.data.result.order_id,
callback_key = res.data.result.pay_key, callback_key = res.data.result.pay_key,
jsConfig = res.data.result.config, jsConfig = res.data.result.config;
goPages = '/pages/order_pay_status/index?order_id=' + orderId + '&msg=' + res.message; // let goPages = '/pages/order_pay_status/index?order_id=' + orderId + '&msg=' + res.message;
_this.orderPay = true; let goPages = backUrl;
uni.hideLoading();
switch (status) { switch (status) {
case 'ORDER_EXIST': case 'ORDER_EXIST':
case 'EXTEND_ORDER': case 'EXTEND_ORDER':
@ -281,7 +321,7 @@ export default {
return _this.$util.Tips({ return _this.$util.Tips({
title: res.message title: res.message
}, { }, {
tab: 5, tab: backTab,
url: goPages url: goPages
}); });
break; break;
@ -290,7 +330,7 @@ export default {
title: res.message, title: res.message,
icon: 'success' icon: 'success'
}, { }, {
tab: 5, tab: backTab,
url: goPages url: goPages
}); });
break; break;
@ -313,14 +353,14 @@ export default {
title: res.message, title: res.message,
icon: 'success' icon: 'success'
}, { }, {
tab: 4, tab: backTab,
url: goPages url: goPages
}); });
}).catch(res => { }).catch(res => {
if (res.errMsg == 'chooseWXPay:cancel') return _this.$util.Tips({ if (res.errMsg == 'chooseWXPay:cancel') return _this.$util.Tips({
title: '取消支付' title: '取消支付'
}, { }, {
tab: 5, tab: backTab,
url: goPages + '&status=0' url: goPages + '&status=0'
}); });
}) })
@ -336,32 +376,31 @@ export default {
provider: 'wxpay', provider: 'wxpay',
orderInfo: jsConfig, orderInfo: jsConfig,
success: (e) => { success: (e) => {
let url = '/pages/order_pay_status/index?order_id=' + orderId + // let url = '/pages/order_pay_status/index?order_id=' + orderId + '&msg=';
'&msg=支付成功';
return _this.$util.Tips({ return _this.$util.Tips({
title: '支付成功', title: '支付成功',
icon: 'success' icon: 'success'
}, { }, {
tab: 4, tab: backTab,
url: url url: backUrl
}); });
}, },
fail: (e) => { fail: (e) => {
let url = '/pages/order_pay_status/index?order_id=' + orderId + '&msg=取消支付'; // let url = '/pages/order_pay_status/index?order_id=' + orderId + '&msg=';
return _this.$util.Tips({ return _this.$util.Tips({
title: '取消支付', title: '取消支付',
}, { }, {
tab: 4, tab: backTab,
url: url url: backUrl
}); });
}, },
complete: () => { complete: () => {
let url = '/pages/order_pay_status/index?order_id=' + orderId + '&msg=取消支付'; // let url = '/pages/order_pay_status/index?order_id=' + orderId + '&msg=';
return _this.$util.Tips({ return _this.$util.Tips({
title: '', title: '',
}, { }, {
tab: 4, tab: backTab,
url: url url: backUrl
}); });
}, },
}); });
@ -386,18 +425,18 @@ export default {
title: '支付成功', title: '支付成功',
icon: 'success' icon: 'success'
}, { }, {
tab: 5, tab: backTab,
url: goPages url: goPages
}); });
}, },
fail: function(e) { fail: function(e) {
let pages = '/pages/order_pay_status/index?order_id=' + // let pages = '/pages/order_pay_status/index?order_id=' + orderId + '&msg='
orderId + '&msg=取消支付'
return _this.$util.Tips({ return _this.$util.Tips({
title: '取消支付' title: '取消支付'
}, { }, {
tab: 5, tab: backTab,
url: pages + '&status=0' // url: pages + '&status=0'
url: backUrl
}); });
}, },
}) })
@ -408,15 +447,15 @@ export default {
return _this.$util.Tips({ return _this.$util.Tips({
title: res.msg title: res.msg
}, { }, {
tab: 5, tab: backTab,
url: goPages + '&status=1' url: goPages + '&status=1'
}); });
break; break;
// #ifdef H5 // #ifdef H5
case 'h5': case 'h5':
let host = window.location.protocol + "//" + window.location.host; let host = window.location.protocol + "//" + window.location.host;
let url = `${host}/pages/order_pay_status/index?order_id=${orderId}&msg=${res.message}` // let url = `${host}/pages/order_pay_status/index?order_id=${orderId}&msg=${res.message}`
let eUrl = encodeURIComponent(url) let eUrl = encodeURIComponent(backUrl)
let jsurl = jsConfig.mweb_url || jsConfig.h5_url let jsurl = jsConfig.mweb_url || jsConfig.h5_url
let locations = `${jsurl}&redirect_url=${eUrl}` let locations = `${jsurl}&redirect_url=${eUrl}`
setTimeout(() => { setTimeout(() => {
@ -434,46 +473,44 @@ export default {
title: '支付成功', title: '支付成功',
icon: 'success' icon: 'success'
}, { }, {
tab: 5, tab: backTab,
url: goPages url: goPages
}); });
}, },
fail: (e) => { fail: (e) => {
let pages = '/pages/order_pay_status/index?order_id=' + // let pages = '/pages/order_pay_status/index?order_id=' + orderId + '&msg='
orderId + '&msg=支付失败'
return _this.$util.Tips({ return _this.$util.Tips({
title: '支付失败' title: '支付失败'
}, { }, {
tab: 5, tab: backTab,
url: pages url: backUrl
}); });
}, },
complete: () => { complete: () => {
uni.hideLoading(); uni.hideLoading();
let pages = '/pages/order_pay_status/index?order_id=' + // let pages = '/pages/order_pay_status/index?order_id=' + orderId + '&msg='
orderId + '&msg=取消支付'
return _this.$util.Tips({ return _this.$util.Tips({
title: '' title: ''
}, { }, {
tab: 5, tab: backTab,
url: pages url: backUrl
}); });
}, },
}); });
break; break;
// #endif // #endif
default: default:
let pages = '/pages/order_pay_status/index?order_id=' + // let pages = '/pages/order_pay_status/index?order_id=' + orderId + '&msg='
orderId + '&msg=取消支付'
return _this.$util.Tips({ return _this.$util.Tips({
title: '取消支付' title: '取消支付'
}, { }, {
tab: 5, tab: backTab,
url: pages + '&status=0' // url: pages + '&status=0'
url: backUrl
}); });
} }
}) }
.catch(err => { }).catch(err => {
uni.hideLoading(); uni.hideLoading();
this.$util.Tips({ this.$util.Tips({
title: err title: err
@ -491,7 +528,27 @@ export default {
this.openAuto() this.openAuto()
} }
}, },
// -
shareholdersIntegralInfo(){
let _this = this;
merShareholdersIntegralStatistics({mer_id: _this.mer_search.mer_id}).then(res => {
_this.integral_surplus = res.data.sum_used_surplus || 0;
}).catch(err => {
this.$util.Tips({title: err});
});
},
// - 使
computeUseIntegral(){
let money = this.pay_info.money || 0;
let integralUse = this.integral_use || 0;
let integralSurplus = this.integral_surplus || 0;
// 使
let useIntegral = Number(integralUse) > Number(money) ? Number(money) : Number(integralUse);
// 使
useIntegral = Number(useIntegral) > Number(integralSurplus) ? Number(integralSurplus) : Number(useIntegral);
this.$set(this, 'integral_use', useIntegral);
}
}, },
// #ifdef MP // #ifdef MP
// //
@ -653,6 +710,65 @@ export default {
} }
} }
} }
//
.integral{
width: 100%;
.box-content{
width: 100%;
background-color: #ffffff;
padding: 20rpx;
border-radius: 15rpx;
.use-info{
width: 100%;
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: flex-start;
height: 70rpx;
padding-bottom: 20rpx;
border-bottom: 2rpx solid #fafafa;
.icon-pc-jifen{
background-color: #f4b00d;
color: #ffffff;
height: 40rpx;
width: 40rpx;
line-height: 40rpx;
text-align: center;
font-size: 28rpx;
}
.title{
font-size: 28rpx;
font-weight: bold;
width: 150rpx;
text-align: center;
}
.use-input{
width: calc(100% - 40rpx - 150rpx);
height: 45rpx;
line-height: 45rpx;
}
}
.hold-info{
width: 100%;
height: 70rpx;
padding-top: 20rpx;
display: inline-flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
flex-wrap: nowrap;
.left{
color: #aeaeae;
font-size: 26rpx;
}
.right{
color: #f4564f;
font-size: 26rpx;
}
}
}
}
// //
.pay-type{ .pay-type{