修改:商品兑换支持在线支付补齐差价

This commit is contained in:
wuhui_zzw 2024-01-18 11:24:41 +08:00
parent d7927434d4
commit d51656a335
6 changed files with 403 additions and 54 deletions

View File

@ -549,7 +549,7 @@
{
"path": "online_payment/site/index",
"style": {
"navigationBarTitleText": "兑换管理"
"navigationBarTitleText": "酒道馆管理"
}
},
{

View File

@ -50,7 +50,7 @@
</view>
<scroll-view class="section-bd" scroll-x="true">
<view v-for="item in memberCoupons" :key="item.coupon_id" class="item"
:class="{gray: item.svipIssue}"
:class="{gray: item.svipIssue}"
:style="'background-image: url('+domain+'/static/images/svip_coupon.png)'">
<view class="coupon-count">
<view class="money">
@ -213,7 +213,7 @@
}
},
watch: {
},
computed: mapGetters(['isLogin','uid']),
onLoad(options) {
@ -231,7 +231,7 @@
if(options.spread) spread(options.spread, this.isLogin)
},
onShow(){
},
onReachBottom() {
this.groomList();
@ -260,7 +260,7 @@
if(['/pages/goods_cate/goods_cate','/pages/order_addcart/order_addcart','/pages/user/index','/pages/plant_grass/index'].indexOf(url) == -1){
uni.navigateTo({
url:url
})
})
}else{
uni.switchTab({
url:url
@ -429,7 +429,7 @@
that.payClose();
uni.navigateTo({
url: '/pages/order_pay_back/index?keyCode='+callback_key+'&url='+jsConfig+'&type=11',
})
})
return;
break;
// #ifndef MP
@ -598,7 +598,7 @@
uni.navigateTo({
url: `/pages/goods_details/index?id=${id}`
});
},
},
groomList() {
if (this.finished || this.loading) {
return;
@ -613,7 +613,7 @@
this.loading = false;
this.page += 1;
}).catch(err => {
});
},
},

View File

@ -97,7 +97,7 @@
</view>
</navigator>
<view class="right-btn">
<view class="iconfont icon-erweima1" v-if="isLogin" @click="showQrCode()"></view>
<!--<view class="iconfont icon-erweima1" v-if="isLogin" @click="showQrCode()"></view>-->
<view class="iconfont icon-shezhi" v-if="isLogin" @click="goSetting()"></view>
<view class="btn" @click="authTo('/pages/chat/customer_list/index?type=0')" hover-class="none">
<view class="iconfont icon-xiaoxi"></view>

View File

@ -20,14 +20,14 @@
</view>
</view>
</view>
<view class="top">
<!--<view class="top">
<view class="left">
<view class="name">消费者{{ (consume_info.nickname || consume_info.real_name || consume_info.uid) || '请选择消费者' }}</view>
<view class="change-btn" @click="showConsumePopup" v-if="consume_search.default_consume_id <= 0">
{{ consume_info.uid > 0 ? '切换' : '选择' }}
</view>
</view>
</view>
</view>-->
<!-- 买单金额 -->
<view class="money">
<view class="top-bg-line"></view>
@ -35,7 +35,8 @@
<view class="title">提货商品总价值</view>
<view class="input-box">
<view class="unit">¥</view>
<input class="money-input" v-model.number="pay_info.total_money" type='number' step="0.01" placeholder="0.00" />
<input class="money-input" v-if="default_total_money > 0" :value="pay_info.total_money" readonly disabled type='number' />
<input class="money-input" v-else v-model.number="pay_info.total_money" type='number' step="0.01" placeholder="0.00" />
</view>
<view class="info-box">
<view class="info-title">剩余酒卡额度</view>
@ -54,11 +55,40 @@
<view class="info-value">{{ pay_info.diff_money }}</view>
</view>
<view class="info-box" v-if="pay_info.diff_money_pay > 0">
<view class="info-title">应补现金</view>
<view class="info-title">实际支付差价</view>
<view class="info-value">{{ pay_info.diff_money_pay }}</view>
</view>
</view>
</view>
<!--支付方式-->
<view class="pay-type" v-if="pay_info.diff_money_pay > 0">
<view class="box-title">支付方式</view>
<view class="box-content">
<radio-group name="pay_type" @change="changePayType">
<view class="pay-label" v-for="(item,index) in pay_list" :key="index" v-if="item.payStatus==1">
<label>
<view class="pay-item">
<view class="left">
<view :class="['iconfont','animated',item.icon]"></view>
<view class="pay-item-info">
<view class="pay-name">{{ item.name }}</view>
<view class='tip'>
{{item.title}}
<block v-if="item.value == 'balance'">
{{now_money}}
</block>
</view>
</view>
</view>
<view class="right">
<radio :value="item.value" :checked="item.value == pay_info.pay_type ? true : false" />
</view>
</view>
</label>
</view>
</radio-group>
</view>
</view>
<!--提交按钮-->
<view class="pay-btn" v-if="pay_info.total_money > 0 && point_info.id > 0 && staff_info.uid > 0" @click="confirmPayment">确认兑换</view>
<view class="pay-btn not-btn" v-else>确认兑换</view>
@ -138,6 +168,7 @@ import {mapGetters} from "vuex";
import authorize from '@/components/Authorize';
import emptyPage from '@/components/emptyPage.vue';
import spread from "@/libs/spread";
import {getUserInfo} from "@/api/user";
const app = getApp();
export default {
@ -163,6 +194,7 @@ export default {
staff_info: {},
staff_list: {},
default_staff_id: 0,
default_total_money: 0,
//
consume_info: {},
consume_list: {},
@ -172,22 +204,69 @@ export default {
},
//
pay_info: {
//
total_money: 0.00,
use_integral: 0.00,
diff_money: 0.00,
diff_money_pay: 0.00,
//
pay_type: 'weixin',
// #ifdef H5
return_url: 'http://' + window.location.host + '/pages/users/order_list/index',
// #endif
},
//
pay_list: [
{
"name": "微信支付",
"icon": "icon-weixin2",
value: 'weixin',
title: '微信快捷支付',
payStatus: 1,
},
{
name: "支付宝支付",
icon: "icon-icon34",
// #ifdef H5 || APP-PLUS
value: 'alipay',
// #endif
// #ifdef MP
value: 'alipayQr',
// #endif
title: '支付宝支付',
payStatus: this.$store.getters.globalData.alipay_open
},
{
"name": "余额支付",
"icon": "icon-icon-test",
value: 'balance',
title: '可用余额:',
payStatus: this.$store.getters.globalData.yue_pay_status,
},
{
"name": "线下支付",
"icon": "icon-yinhangqia",
value: 'offline',
title: '线下支付',
payStatus: 2,
},
],
now_money: 0,
};
},
computed: {
...mapGetters(['isLogin', 'userInfo', 'viewColor'])
...mapGetters(['isLogin', 'uid', 'userInfo', 'viewColor'])
},
onLoad(options) {
if(options.scene){
// console.log('',options.scene)
// suid=staff_idpid=point_idtmy=total_money
var scene = this.$util.getUrlParams(decodeURIComponent(options.scene));
this.point_search.default_point_id = scene.point_id || 0;
console.log("接收参数",scene)
this.point_search.default_point_id = scene.pid || 0;
this.consume_search.default_consume_id = scene.consume_uid || 0;
this.default_staff_id = scene.staff_uid || 0;
this.default_staff_id = scene.suid || 0;
this.default_total_money = Number(scene.tmy) || 0;
//
if(Number(this.consume_search.default_consume_id) > 0){
this.default_staff_id = this.userInfo.uid || 0;
@ -211,7 +290,7 @@ export default {
'pay_info.total_money': {
handler(val) {
let totalMoney = this.pay_info.total_money.toFixed(2);
console.log('总价值', totalMoney)
// console.log('', totalMoney)
//
if(Number(totalMoney) > Number(this.pointUserInfo.available)){
this.$util.Tips({
@ -221,6 +300,7 @@ export default {
return false;
}
// 使
// console.log('',Number(this.pointUserInfo.available_integral))
if(Number(totalMoney) > Number(this.pointUserInfo.available_integral)){
//
this.pay_info.use_integral = Number(this.pointUserInfo.available_integral);
@ -261,6 +341,10 @@ export default {
//
let pointId = _this.point_info.id || 0;
if(pointId <= 0) _this.showPointPopup();
//
getUserInfo().then(res => {
_this.now_money = res.data.now_money
});
},
//
getUserInfo(){
@ -271,6 +355,8 @@ export default {
pointUserInfo(params)
.then(res => {
_this.pointUserInfo = res.data || {};
//
_this.pay_info.total_money = Number(_this.default_total_money) || 0;
})
.catch(err => {
this.$util.Tips({
@ -354,9 +440,10 @@ export default {
},
// -
showConsumePopup(){
if(Object.keys(this.consume_list).length <= 0) this.getConsumeList();
// todo
// if(Object.keys(this.consume_list).length <= 0) this.getConsumeList();
//
if(Number(this.consume_search.default_consume_id) <= 0) this.$refs.selectedConsume.open('center');
// if(Number(this.consume_search.default_consume_id) <= 0) this.$refs.selectedConsume.open('center');
},
// -
consumeClosePopup(){
@ -394,26 +481,246 @@ export default {
let payInfo = Object.assign({},_this.pay_info);
payInfo.point_id = this.point_info.id;
payInfo.staff_uid = this.staff_info.uid;
payInfo.consume_uid = this.consume_info.uid;
// payInfo.consume_uid = this.consume_info.uid;
//
console.log('支付类型',payInfo.pay_type)
if (payInfo.pay_type == 'weixin') {
// #ifdef H5
payInfo.pay_type = _this.$wechat.isWeixin() ? 'weixin' : 'h5'
// #endif
// #ifdef MP
payInfo.pay_type = 'routine'
// #endif
// #ifdef APP-PLUS
payInfo.pay_type = 'weixin'
// #endif
}
//
uni.showLoading({
title: '处理中...',
mask: true
});
confirmExchange(payInfo)
.then(res => {
uni.hideLoading();
this.$util.Tips({
title: '操作成功!',
icon: 'success'
},{tab:1,url:'/pages/user/index'});
})
.catch(err => {
uni.hideLoading();
this.$util.Tips({
title: err
});
});
confirmExchange(payInfo).then(res => {
uni.hideLoading();
if(payInfo.diff_money_pay > 0){
let status = res.data.status,
orderId = res.data.result.order_id,
callback_key = res.data.result.pay_key,
jsConfig = res.data.result.config,
goPages = '/pages/order_pay_status/index?order_id=' + orderId + '&msg=' + res.message;
_this.orderPay = true;
uni.hideLoading();
switch (status) {
case 'ORDER_EXIST':
case 'EXTEND_ORDER':
case 'PAY_ERROR':
case 'error':
return _this.$util.Tips({
title: res.message
}, {
tab: 5,
url: goPages
});
break;
case 'success':
return _this.$util.Tips({
title: res.message,
icon: 'success'
}, {
tab: 5,
url: goPages
});
break;
case 'alipay':
case "alipayQr":
uni.navigateTo({
url: '/pages/order_pay_back/index?keyCode=' + callback_key + '&url=' +
jsConfig
})
return;
break;
// #ifndef MP
case "wechat":
case "weixin":
case "weixinApp":
jsConfig.timeStamp = jsConfig.timestamp;
// #ifndef APP-PLUS
this.$wechat.pay(jsConfig).then(res => {
return _this.$util.Tips({
title: res.message,
icon: 'success'
}, {
tab: 4,
url: goPages
});
}).catch(res => {
if (res.errMsg == 'chooseWXPay:cancel') return _this.$util.Tips({
title: '取消支付'
}, {
tab: 5,
url: goPages + '&status=0'
});
})
// #endif
// #ifdef APP-PLUS
let mp_pay_name=''
if(uni.requestOrderPayment){
mp_pay_name='requestOrderPayment'
}else{
mp_pay_name='requestPayment'
}
uni[mp_pay_name]({
provider: 'wxpay',
orderInfo: jsConfig,
success: (e) => {
let url = '/pages/order_pay_status/index?order_id=' + orderId +
'&msg=支付成功';
return _this.$util.Tips({
title: '支付成功',
icon: 'success'
}, {
tab: 4,
url: url
});
},
fail: (e) => {
let url = '/pages/order_pay_status/index?order_id=' + orderId + '&msg=取消支付';
return _this.$util.Tips({
title: '取消支付',
}, {
tab: 4,
url: url
});
},
complete: () => {
let url = '/pages/order_pay_status/index?order_id=' + orderId + '&msg=取消支付';
return _this.$util.Tips({
title: '',
}, {
tab: 4,
url: url
});
},
});
// #endif
break;
// #endif
// #ifdef MP
case "routine":
jsConfig.timeStamp = jsConfig.timestamp;
_this.toPay = true;
let mp_pay_name=''
if(uni.requestOrderPayment){
mp_pay_name='requestOrderPayment'
}else{
mp_pay_name='requestPayment'
}
uni[mp_pay_name]({
...jsConfig,
success: function(res) {
uni.hideLoading();
return _this.$util.Tips({
title: '支付成功',
icon: 'success'
}, {
tab: 5,
url: goPages
});
},
fail: function(e) {
let pages = '/pages/order_pay_status/index?order_id=' +
orderId + '&msg=取消支付'
return _this.$util.Tips({
title: '取消支付'
}, {
tab: 5,
url: pages + '&status=0'
});
},
})
break;
// #endif
case "balance":
//
return _this.$util.Tips({
title: res.msg
}, {
tab: 5,
url: goPages + '&status=1'
});
break;
// #ifdef H5
case 'h5':
let host = window.location.protocol + "//" + window.location.host;
let url = `${host}/pages/order_pay_status/index?order_id=${orderId}&msg=${res.message}`
let eUrl = encodeURIComponent(url)
let jsurl = jsConfig.mweb_url || jsConfig.h5_url
let locations = `${jsurl}&redirect_url=${eUrl}`
setTimeout(() => {
location.href = locations;
}, 100);
break;
// #endif
// #ifdef APP-PLUS
case 'alipayApp':
uni.requestPayment({
provider: 'alipay',
orderInfo: jsConfig,
success: (e) => {
return _this.$util.Tips({
title: '支付成功',
icon: 'success'
}, {
tab: 5,
url: goPages
});
},
fail: (e) => {
let pages = '/pages/order_pay_status/index?order_id=' +
orderId + '&msg=支付失败'
return _this.$util.Tips({
title: '支付失败'
}, {
tab: 5,
url: pages
});
},
complete: () => {
uni.hideLoading();
let pages = '/pages/order_pay_status/index?order_id=' +
orderId + '&msg=取消支付'
return _this.$util.Tips({
title: ''
}, {
tab: 5,
url: pages
});
},
});
break;
// #endif
default:
let pages = '/pages/order_pay_status/index?order_id=' +
orderId + '&msg=取消支付'
return _this.$util.Tips({
title: '取消支付'
}, {
tab: 5,
url: pages + '&status=0'
});
}
}else{
this.$util.Tips({
title: '操作成功!',
icon: 'success'
},{tab:1,url:'/pages/user/index'});
}
}).catch(err => {
uni.hideLoading();
this.$util.Tips({
title: err
});
});
},
//
goMenuPage(url) {
@ -426,6 +733,11 @@ export default {
this.openAuto()
}
},
//
changePayType(e){
this.pay_info.pay_type = e.detail.value || e.target.value;
},
},
// #ifdef MP
//

View File

@ -37,7 +37,7 @@
<view class='tip'>
{{item.title}}
<block v-if="item.value == 'balance'">
{{userInfo.now_money}}
{{now_money}}
</block>
</view>
</view>
@ -91,6 +91,7 @@ import {mapGetters} from "vuex";
import authorize from '@/components/Authorize';
import emptyPage from '@/components/emptyPage.vue';
import spread from "@/libs/spread";
import {getUserInfo} from "@/api/user";
const app = getApp();
export default {
@ -153,6 +154,7 @@ export default {
payStatus: 2,
},
],
now_money: 0,
};
},
@ -191,6 +193,10 @@ export default {
//
let merId = _this.mer_info.mer_id || 0;
if(merId <= 0) _this.merShowPopup();
//
getUserInfo().then(res => {
_this.now_money = res.data.now_money
});
},
// -
merShowPopup(){

View File

@ -4,7 +4,7 @@
<view class='content-box'>
<!--选项卡-->
<view class="tabs">
<view :class="['tabs-item',{'tabs-item-active': (tab_active == 'list')}]" @click="init('list')">站点管理</view>
<view :class="['tabs-item',{'tabs-item-active': (tab_active == 'list')}]" @click="init('list')">酒道馆</view>
<view :class="['tabs-item',{'tabs-item-active': (tab_active == 'exchange_record')}]" @click="init('exchange_record')">兑换记录</view>
</view>
<!--站点管理-->
@ -14,7 +14,8 @@
<view class="title">{{item.title}}</view>
<view class="address">{{item.address}}</view>
</view>
<!--<view class="right" @click="showQrCode(item)">兑换码</view>-->
<view v-if="item.is_show == 1" class="right" @click="showQrCode(item)">兑换码</view>
<view v-else class="right not-btn">已停用</view>
</view>
</view>
<!--兑换记录-->
@ -42,7 +43,7 @@
<uni-popup ref="qrCodePopup" type="center">
<view class="qr-code-content">
<image class="image" :src="qrCode"></image>
<view class="close-qr-code" @click="$refs.qrCodePopup.open.close()">关闭</view>
<view class="close-qr-code" @click="closeQrCode()">关闭</view>
</view>
</uni-popup>
</view>
@ -138,23 +139,48 @@ export default {
//
showQrCode(item){
let _this = this;
let params = {
point_id: item.id
};
getSiteQrCode(params).then(res => {
if(res.status == 200){
_this.qrCode = res.data.qr_code || ''
_this.$refs.qrCodePopup.open('center');
//
uni.showModal({
title: '兑换商品金额', //
content: '',
editable: true,//
placeholderText: '请输入用户兑换商品的总金额',//
showCancel: true, //
cancelText: '取消', //
confirmText: '确定', //
success: (res) => {
console.log(res)
if (res.confirm && Number(res.content) > 0) {
let inputValue = Number(res.content);
let params = {
point_id: item.id,
total_money: inputValue,
};
getSiteQrCode(params).then(res => {
if (res.status == 200) {
_this.qrCode = res.data.qr_code || ''
_this.$refs.qrCodePopup.open('center');
}
}).catch(err => {
this.$util.Tips({
title: err
});
});
} else if (res.cancel) {
console.log('用户点击了取消');
}
}
}).catch(err => {
this.$util.Tips({
title: err
});
});
})
},
//
closeQrCode(){
this.$refs.qrCodePopup.close();
}
}
}
@ -238,6 +264,11 @@ export default {
width: 120rpx;
text-align: center;
}
.not-btn{
background-color: #909399!important;
border-color: #909399!important;
color: #fff!important;
}
}
.site-box:last-child{
border-bottom: 0!important;