parent
2afae4f007
commit
644b458969
|
@ -59,7 +59,7 @@
|
|||
"quickapp" : {},
|
||||
/* 小程序特有相关 */
|
||||
"mp-weixin" : {
|
||||
"appid" : "wx63c280fe3248a3e7",
|
||||
"appid" : "wx62056c0d5e8db250",
|
||||
"setting" : {
|
||||
"urlCheck" : true,
|
||||
"minified" : true,
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -243,6 +243,14 @@
|
|||
this.setTabList()
|
||||
},
|
||||
onLoad() {
|
||||
// wx.login({
|
||||
// success (res) {
|
||||
// if (res.code) {
|
||||
// console.log(res.code, '======== code 编号 =======')
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
|
||||
var that = this;
|
||||
// 获取系统信息
|
||||
uni.getSystemInfo({
|
||||
|
|
|
@ -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}`
|
||||
})
|
||||
|
|
|
@ -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}`
|
||||
});
|
||||
|
|
|
@ -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}`
|
||||
})
|
||||
|
|
|
@ -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 || {},
|
||||
|
|
Loading…
Reference in New Issue