【收银台】

1. 完成微信小程序的支付
pull/1/MERGE
YunaiV 2023-07-08 12:43:29 +08:00
parent 2afae4f007
commit 644b458969
7 changed files with 54 additions and 31 deletions

View File

@ -59,7 +59,7 @@
"quickapp" : {},
/* */
"mp-weixin" : {
"appid" : "wx63c280fe3248a3e7",
"appid" : "wx62056c0d5e8db250",
"setting" : {
"urlCheck" : true,
"minified" : true,

View File

@ -11,7 +11,7 @@
:datatime="invalidTime / 1000" :is-col="true" :bgColor="bgColor" />
</view>
</view>
<view class="payment">
<view class="payment" v-if="channelCode.length > 0">
<view class="title">
支付方式
</view>
@ -98,8 +98,9 @@
this.orderId = options.order_id
}
if (options.returnUrl) {
this.returnUrl = options.returnUrl
this.returnUrl = decodeURIComponent(options.returnUrl)
}
debugger
this.getCashierOrder()
},
methods: {
@ -157,7 +158,8 @@
displayMode: 'url', // TODO
returnUrl: this.getPayReturnUrl(),
channelExtras: {
openid: "ockUAwIZ-0OeMZl9ogcZ4ILrGba0"
// openid: "ockUAwIZ-0OeMZl9ogcZ4ILrGba0" // wx_pub openid
openid: "oLefc4g5GjKWHJjLjMSXB3wX0fD0" // wx_lite openid
}
}).then(res => {
this.handleSubmitOrderResult(res.data);
@ -379,50 +381,41 @@
})
})
},
/**
* 发起微信小程序支付
*/
handleSubmitOrderResultForWxLite(displayContent) {
const payConfig = JSON.parse(displayContent);
const that = this;
console.log(payConfig, '=================')
console.log(payConfig.timeStamp, '=================')
uni.requestPayment({
timeStamp: payConfig.timeStamp,
nonceStr: payConfig.nonceStr,
package: payConfig.packageValue,
signType: payConfig.signType,
paySign: payConfig.paySign,
success: function(res) {
success: res => {
uni.hideLoading();
return that.$util.Tips({
debugger
return this.$util.Tips({
title: '支付成功',
icon: 'success'
}, {
tab: 5,
url: goPages
}, () => {
this.goReturnUrl('success');
});
},
fail: function(e) {
fail: e => {
uni.hideLoading();
return that.$util.Tips({
title: '取消支付'
}, {
tab: 5,
url: goPages + '&status=2'
});
},
complete: function(e) {
uni.hideLoading();
//
//
if (e.errMsg === 'requestPayment:cancel'
|| e.errMsg === 'requestPayment:fail cancel') {
return that.$util.Tips({
return this.$util.Tips({
title: '取消支付'
});
}
return that.$util.Tips({
return this.$util.Tips({
title: e.errMsg,
icon: 'error'
});
},
}
})
},
@ -434,10 +427,16 @@
// #ifndef MP
this.cartArr = this.cartArr.filter(item => item.channelCode !== 'wx_lite')
// #endif
// #ifdef MP
this.cartArr = this.cartArr.filter(item => item.channelCode !== 'wx_pub')
// #endif
// 1.2
// #ifdef H5
if (!this.$wechat.isWeixin()) {
this.cartArr = this.cartArr.filter(item => item.channelCode !== 'wx_pub')
}
// #endif
// 2.
PayChannelApi.getEnableChannelCodeList(appId).then(res => {

View File

@ -243,6 +243,14 @@
this.setTabList()
},
onLoad() {
// wx.login({
// success (res) {
// if (res.code) {
// console.log(res.code, '======== code =======')
// }
// }
// })
var that = this;
//
uni.getSystemInfo({

View File

@ -425,7 +425,7 @@
* 打开支付组件
*/
goPay() {
const returnUrl = '/pages/order_pay_status/index?order_id=' + this.orderInfo.id;
const returnUrl = encodeURIComponent('/pages/order_pay_status/index?order_id=' + this.orderInfo.id);
uni.navigateTo({
url: `/pages/goods/cashier/index?order_id=${this.orderInfo.payOrderId}&returnUrl=${returnUrl}`
})

View File

@ -337,7 +337,7 @@
...this.getSettlementReqVO(),
mark: this.mark,
}).then(res => {
const returnUrl = '/pages/order_pay_status/index?order_id=' + res.data.id;
const returnUrl = encodeURIComponent('/pages/order_pay_status/index?order_id=' + res.data.id);
uni.navigateTo({
url: `/pages/goods/cashier/index?order_id=${res.data.payOrderId}&returnUrl=${returnUrl}`
});

View File

@ -217,7 +217,7 @@
* 打开支付组件
*/
goPay(id, payOrderId) {
const returnUrl = '/pages/order_pay_status/index?order_id=' + id;
const returnUrl = encodeURIComponent('/pages/order_pay_status/index?order_id=' + id);
uni.navigateTo({
url: `/pages/goods/cashier/index?order_id=${payOrderId}&returnUrl=${returnUrl}`
})

View File

@ -10,6 +10,18 @@ import {
} from '../libs/login';
import store from '../store';
// TODO 芋艿:临时解决 uniapp 在小程序undefined 会被 tostring 的问题
function deleteUndefinedProperties(obj) {
for (let key in obj) {
if (obj.hasOwnProperty(key)) {
if (typeof obj[key] === 'object' && obj[key] !== null) {
deleteUndefinedProperties(obj[key]); // 递归调用,处理嵌套的对象
} else if (obj[key] === undefined) {
delete obj[key];
}
}
}
}
/**
* 发送请求
@ -32,6 +44,8 @@ function baseRequest(url, method, data, {
}
}
deleteUndefinedProperties(data)
// TODO 补个 header 多租户
if (url.indexOf('app-api') >= 0) {
header = {
@ -44,8 +58,10 @@ function baseRequest(url, method, data, {
if (store.state.app.token) header[TOKENNAME] = store.state.app.token;
return new Promise((reslove, reject) => {
uni.request({
url: url.indexOf('app-api') < 0 ? Url + '/api/front/' + url
: 'http://127.0.0.1:48080/' + url, // TODO 芋艿:搞个 url 的配置
// url: url.indexOf('app-api') < 0 ? Url + '/api/front/' + url
// : 'http://127.0.0.1:48080/' + url, // TODO 芋艿:搞个 url 的配置
url: url.indexOf('app-api') < 0 ? Url + '/api/front/' + url
: 'http://yunai.natapp1.cc/' + url, // TODO 芋艿:搞个 url 的配置
method: method || 'GET',
header: header,
data: data || {},