parent
2afae4f007
commit
644b458969
|
@ -59,7 +59,7 @@
|
||||||
"quickapp" : {},
|
"quickapp" : {},
|
||||||
/* 小程序特有相关 */
|
/* 小程序特有相关 */
|
||||||
"mp-weixin" : {
|
"mp-weixin" : {
|
||||||
"appid" : "wx63c280fe3248a3e7",
|
"appid" : "wx62056c0d5e8db250",
|
||||||
"setting" : {
|
"setting" : {
|
||||||
"urlCheck" : true,
|
"urlCheck" : true,
|
||||||
"minified" : true,
|
"minified" : true,
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
:datatime="invalidTime / 1000" :is-col="true" :bgColor="bgColor" />
|
:datatime="invalidTime / 1000" :is-col="true" :bgColor="bgColor" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="payment">
|
<view class="payment" v-if="channelCode.length > 0">
|
||||||
<view class="title">
|
<view class="title">
|
||||||
支付方式
|
支付方式
|
||||||
</view>
|
</view>
|
||||||
|
@ -98,8 +98,9 @@
|
||||||
this.orderId = options.order_id
|
this.orderId = options.order_id
|
||||||
}
|
}
|
||||||
if (options.returnUrl) {
|
if (options.returnUrl) {
|
||||||
this.returnUrl = options.returnUrl
|
this.returnUrl = decodeURIComponent(options.returnUrl)
|
||||||
}
|
}
|
||||||
|
debugger
|
||||||
this.getCashierOrder()
|
this.getCashierOrder()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -157,7 +158,8 @@
|
||||||
displayMode: 'url', // TODO 芋艿:后续可以优化
|
displayMode: 'url', // TODO 芋艿:后续可以优化
|
||||||
returnUrl: this.getPayReturnUrl(),
|
returnUrl: this.getPayReturnUrl(),
|
||||||
channelExtras: {
|
channelExtras: {
|
||||||
openid: "ockUAwIZ-0OeMZl9ogcZ4ILrGba0"
|
// openid: "ockUAwIZ-0OeMZl9ogcZ4ILrGba0" // wx_pub 微信公众号支付的 openid
|
||||||
|
openid: "oLefc4g5GjKWHJjLjMSXB3wX0fD0" // wx_lite 微信小程序支付的 openid
|
||||||
}
|
}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
this.handleSubmitOrderResult(res.data);
|
this.handleSubmitOrderResult(res.data);
|
||||||
|
@ -379,50 +381,41 @@
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 发起微信小程序支付
|
||||||
|
*/
|
||||||
handleSubmitOrderResultForWxLite(displayContent) {
|
handleSubmitOrderResultForWxLite(displayContent) {
|
||||||
const payConfig = JSON.parse(displayContent);
|
const payConfig = JSON.parse(displayContent);
|
||||||
const that = this;
|
|
||||||
console.log(payConfig, '=================')
|
|
||||||
console.log(payConfig.timeStamp, '=================')
|
|
||||||
uni.requestPayment({
|
uni.requestPayment({
|
||||||
timeStamp: payConfig.timeStamp,
|
timeStamp: payConfig.timeStamp,
|
||||||
nonceStr: payConfig.nonceStr,
|
nonceStr: payConfig.nonceStr,
|
||||||
package: payConfig.packageValue,
|
package: payConfig.packageValue,
|
||||||
signType: payConfig.signType,
|
signType: payConfig.signType,
|
||||||
paySign: payConfig.paySign,
|
paySign: payConfig.paySign,
|
||||||
success: function(res) {
|
success: res => {
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
return that.$util.Tips({
|
debugger
|
||||||
|
return this.$util.Tips({
|
||||||
title: '支付成功',
|
title: '支付成功',
|
||||||
icon: 'success'
|
icon: 'success'
|
||||||
}, {
|
}, () => {
|
||||||
tab: 5,
|
this.goReturnUrl('success');
|
||||||
url: goPages
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
fail: function(e) {
|
fail: e => {
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
return that.$util.Tips({
|
// 关闭支付的情况
|
||||||
title: '取消支付'
|
|
||||||
}, {
|
|
||||||
tab: 5,
|
|
||||||
url: goPages + '&status=2'
|
|
||||||
});
|
|
||||||
},
|
|
||||||
complete: function(e) {
|
|
||||||
uni.hideLoading();
|
|
||||||
// 关闭当前页面跳转至订单状态
|
|
||||||
if (e.errMsg === 'requestPayment:cancel'
|
if (e.errMsg === 'requestPayment:cancel'
|
||||||
|| e.errMsg === 'requestPayment:fail cancel') {
|
|| e.errMsg === 'requestPayment:fail cancel') {
|
||||||
return that.$util.Tips({
|
return this.$util.Tips({
|
||||||
title: '取消支付'
|
title: '取消支付'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return that.$util.Tips({
|
return this.$util.Tips({
|
||||||
title: e.errMsg,
|
title: e.errMsg,
|
||||||
icon: 'error'
|
icon: 'error'
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -434,10 +427,16 @@
|
||||||
// #ifndef MP
|
// #ifndef MP
|
||||||
this.cartArr = this.cartArr.filter(item => item.channelCode !== 'wx_lite')
|
this.cartArr = this.cartArr.filter(item => item.channelCode !== 'wx_lite')
|
||||||
// #endif
|
// #endif
|
||||||
|
// #ifdef MP
|
||||||
|
this.cartArr = this.cartArr.filter(item => item.channelCode !== 'wx_pub')
|
||||||
|
// #endif
|
||||||
|
|
||||||
// 1.2 如果不是公众号环境,则移除微信公众号支付
|
// 1.2 如果不是公众号环境,则移除微信公众号支付
|
||||||
|
// #ifdef H5
|
||||||
if (!this.$wechat.isWeixin()) {
|
if (!this.$wechat.isWeixin()) {
|
||||||
this.cartArr = this.cartArr.filter(item => item.channelCode !== 'wx_pub')
|
this.cartArr = this.cartArr.filter(item => item.channelCode !== 'wx_pub')
|
||||||
}
|
}
|
||||||
|
// #endif
|
||||||
|
|
||||||
// 2. 读取配置,移除被禁用的支付渠道
|
// 2. 读取配置,移除被禁用的支付渠道
|
||||||
PayChannelApi.getEnableChannelCodeList(appId).then(res => {
|
PayChannelApi.getEnableChannelCodeList(appId).then(res => {
|
||||||
|
|
|
@ -243,6 +243,14 @@
|
||||||
this.setTabList()
|
this.setTabList()
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
|
// wx.login({
|
||||||
|
// success (res) {
|
||||||
|
// if (res.code) {
|
||||||
|
// console.log(res.code, '======== code 编号 =======')
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
// 获取系统信息
|
// 获取系统信息
|
||||||
uni.getSystemInfo({
|
uni.getSystemInfo({
|
||||||
|
|
|
@ -425,7 +425,7 @@
|
||||||
* 打开支付组件
|
* 打开支付组件
|
||||||
*/
|
*/
|
||||||
goPay() {
|
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({
|
uni.navigateTo({
|
||||||
url: `/pages/goods/cashier/index?order_id=${this.orderInfo.payOrderId}&returnUrl=${returnUrl}`
|
url: `/pages/goods/cashier/index?order_id=${this.orderInfo.payOrderId}&returnUrl=${returnUrl}`
|
||||||
})
|
})
|
||||||
|
|
|
@ -337,7 +337,7 @@
|
||||||
...this.getSettlementReqVO(),
|
...this.getSettlementReqVO(),
|
||||||
mark: this.mark,
|
mark: this.mark,
|
||||||
}).then(res => {
|
}).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({
|
uni.navigateTo({
|
||||||
url: `/pages/goods/cashier/index?order_id=${res.data.payOrderId}&returnUrl=${returnUrl}`
|
url: `/pages/goods/cashier/index?order_id=${res.data.payOrderId}&returnUrl=${returnUrl}`
|
||||||
});
|
});
|
||||||
|
|
|
@ -217,7 +217,7 @@
|
||||||
* 打开支付组件
|
* 打开支付组件
|
||||||
*/
|
*/
|
||||||
goPay(id, payOrderId) {
|
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({
|
uni.navigateTo({
|
||||||
url: `/pages/goods/cashier/index?order_id=${payOrderId}&returnUrl=${returnUrl}`
|
url: `/pages/goods/cashier/index?order_id=${payOrderId}&returnUrl=${returnUrl}`
|
||||||
})
|
})
|
||||||
|
|
|
@ -10,6 +10,18 @@ import {
|
||||||
} from '../libs/login';
|
} from '../libs/login';
|
||||||
import store from '../store';
|
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 多租户
|
// TODO 补个 header 多租户
|
||||||
if (url.indexOf('app-api') >= 0) {
|
if (url.indexOf('app-api') >= 0) {
|
||||||
header = {
|
header = {
|
||||||
|
@ -44,8 +58,10 @@ function baseRequest(url, method, data, {
|
||||||
if (store.state.app.token) header[TOKENNAME] = store.state.app.token;
|
if (store.state.app.token) header[TOKENNAME] = store.state.app.token;
|
||||||
return new Promise((reslove, reject) => {
|
return new Promise((reslove, reject) => {
|
||||||
uni.request({
|
uni.request({
|
||||||
url: url.indexOf('app-api') < 0 ? Url + '/api/front/' + url
|
// url: url.indexOf('app-api') < 0 ? Url + '/api/front/' + url
|
||||||
: 'http://127.0.0.1:48080/' + url, // TODO 芋艿:搞个 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',
|
method: method || 'GET',
|
||||||
header: header,
|
header: header,
|
||||||
data: data || {},
|
data: data || {},
|
||||||
|
|
Loading…
Reference in New Issue