fix: 跳转参数
This commit is contained in:
parent
845d797d09
commit
c2e738767c
|
|
@ -256,9 +256,6 @@
|
|||
console.log('获取手机号', res.data.phone)
|
||||
|
||||
this.getCart();
|
||||
}).catch(e => {
|
||||
console.log(e)
|
||||
this.getCart();
|
||||
})
|
||||
},
|
||||
|
||||
|
|
@ -368,16 +365,18 @@
|
|||
from.products = JSON.parse(from.products);
|
||||
|
||||
// 创建订单
|
||||
createFoodOrder(from).then(res => {
|
||||
const { pay_price, order_sn, type, openid} = res['data'];
|
||||
console.log(pay_price, order_sn, type, openid)
|
||||
this.$Payment.H5_Payment({
|
||||
pay_price,
|
||||
order_sn,
|
||||
type,
|
||||
openid,
|
||||
return_url:`/pages/restaurant/order/order-details/details?order_sn=${order_sn}`
|
||||
});
|
||||
createFoodOrder(from).then(res => {
|
||||
console.log(res.adta)
|
||||
|
||||
|
||||
let redirect_url = '/pages/restaurant/order/order-details/details';
|
||||
uni.hideLoading();
|
||||
this.$Payment.H5TOWX_Payment({
|
||||
datas: res['data'],
|
||||
return_url:`/pages/restaurant/order/order-details/details?order_sn=${res.data.order_sn}`
|
||||
});
|
||||
|
||||
|
||||
// let redirect_url = '/pages/restaurant/order/order-details/details';
|
||||
// uni.hideLoading();
|
||||
// // 调起支付
|
||||
|
|
|
|||
|
|
@ -219,8 +219,6 @@
|
|||
}).then(res => {
|
||||
this.SETPHONE(res['data'])
|
||||
this.getCart();
|
||||
}).catch(e => {
|
||||
this.getCart();
|
||||
})
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -119,8 +119,9 @@ class Request {
|
|||
config['url'] = `${this['BaseUR']}${config['url']}`
|
||||
};
|
||||
config['complete'] = (infor) => {
|
||||
this.responseintercept(infor);
|
||||
if (infor['statusCode'] == 200) {
|
||||
this.responseintercept(infor);
|
||||
console.log(infor, 'wwwwwwwwww')
|
||||
if (infor.data['status'] == 200 || infor.statusCode == 200) {
|
||||
// arraybuffer格式返回是不带code的
|
||||
// 判断是否是arraybuffer
|
||||
if (this['responseType'] == 'arraybuffer') {
|
||||
|
|
@ -128,7 +129,7 @@ class Request {
|
|||
resolve(infor['data']);
|
||||
return
|
||||
}
|
||||
if (infor['data']['code'] != 200 && infor['data']['code'] != 7777) {
|
||||
if (infor['data']['status'] != 200 && infor['data']['code'] != 7777) {
|
||||
uni.showToast({
|
||||
title: infor['data']['msg'],
|
||||
icon: 'none'
|
||||
|
|
@ -166,10 +167,8 @@ class Request {
|
|||
// }
|
||||
// });
|
||||
uni.request(Requestconfig);
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
// 请求拦截
|
||||
Requestintercept(config) {
|
||||
// 请求时需要携带用定位
|
||||
|
|
@ -234,7 +233,8 @@ class Request {
|
|||
if (isSafari && process.env.NODE_ENV !== 'development') return;
|
||||
console.log(infor['statusCode'],'是否测试环境11221');
|
||||
// 响应拦截逻辑开始
|
||||
if (infor['statusCode'] != 200) {
|
||||
// if (infor['statusCode'] != 200) {
|
||||
if (infor.data['status'] != 200) {
|
||||
// HTPP网络请求状态错误直接提示
|
||||
uni.showToast({
|
||||
title: `${infor['data']['msg']}---${infor['url']}`,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,124 @@ import {
|
|||
} from '@/request/pay/index.js';
|
||||
class Payment {
|
||||
static order_sn = 0
|
||||
/**
|
||||
* @param {String} pay_price 支付金额
|
||||
* @param {String} order_sn 订单号
|
||||
* @param {String} type 支付类型
|
||||
* @param {String} return_url 支付时H5内部跳转路径
|
||||
* @param {String} redirect 是否关闭调起支付的页面
|
||||
* 该方法没有支付失败和成功回调函数必须由微信支付完成之后跳转至指定页面去查询订单状态然后根据订单状态再跳转值业务页面
|
||||
*/
|
||||
H5TOWX_Payment(data) {
|
||||
uni.showLoading({
|
||||
title: '支付中...'
|
||||
});
|
||||
|
||||
const {
|
||||
datas,
|
||||
return_url,
|
||||
redirect=false,
|
||||
PAY_TYPE='1',
|
||||
success = () => {},
|
||||
file = () => {}
|
||||
} = data;
|
||||
|
||||
// if (!pay_price) throw new Error('缺少支付金额');
|
||||
// if (!order_sn) throw new Error('缺少订单号');
|
||||
// if (!type) throw new Error('缺少支付类型');
|
||||
|
||||
// 下单信息
|
||||
const OrderData = datas;
|
||||
|
||||
// 判断是微信支付还是支付宝支付
|
||||
if(PAY_TYPE == '1'){
|
||||
// 微信内嵌WEBVIEW方式进入H5页面
|
||||
if(getApp()['globalData']['parameters']?.isWechat){
|
||||
OrderData['WechatRetreat'] = true;
|
||||
// 先跳转至微信支付页面
|
||||
try{
|
||||
// wx.miniProgram.navigateTo({
|
||||
// url: `/pages/wxpay/h5pay/h5pay?data=${encodeURIComponent(JSON.stringify(OrderData))}`
|
||||
// });
|
||||
wx.miniProgram.navigateTo({
|
||||
url: `/pages/extension/shop/wxPay/wxPay?data=${encodeURIComponent(JSON.stringify(OrderData))}`
|
||||
}); // Jin
|
||||
|
||||
// 延迟两秒后H5内部跳转
|
||||
setTimeout(()=>{
|
||||
uni.hideLoading();
|
||||
if(return_url){
|
||||
// 是否需要关闭调起支付的页面
|
||||
if(redirect){
|
||||
uni.redirectTo({
|
||||
url:return_url
|
||||
});
|
||||
}else{
|
||||
uni.navigateTo({
|
||||
url:return_url
|
||||
})
|
||||
}
|
||||
}
|
||||
},2000)
|
||||
}catch(e){
|
||||
uni.hideLoading();
|
||||
//TODO handle the exception
|
||||
uni.showToast({
|
||||
title:'支付错误',
|
||||
icon:'none'
|
||||
})
|
||||
}
|
||||
|
||||
}else{
|
||||
OrderData['WechatRetreat'] = false;
|
||||
openMiniProgram({
|
||||
path: `pages/wxpay/h5pay/h5pay?data=${encodeURIComponent(JSON.stringify(OrderData))}`,
|
||||
id: 'gh_faaea9b90759',
|
||||
// type: 'release',
|
||||
type: 'preview'
|
||||
})
|
||||
// 其他方式进入H5页面(APP)
|
||||
// 反之使用跳转连接进入
|
||||
// makeMinUrlAPI({
|
||||
// path :'/pages/wxpay/h5pay/h5pay',
|
||||
// query:`data=${encodeURIComponent(JSON.stringify(OrderData))}`,
|
||||
// // uu_id:17551,
|
||||
// // release 正式版
|
||||
// // trial 测试版
|
||||
// // develop 开发板
|
||||
// env_version:'develop',
|
||||
// }).then(res=>{
|
||||
// // console.log(res);
|
||||
// console.log(res['data']['openlink'],'openlink');
|
||||
// // return
|
||||
// location.href = res['data']['openlink'];
|
||||
// // 延迟两秒后H5内部跳转
|
||||
setTimeout(()=>{
|
||||
uni.hideLoading();
|
||||
if(return_url){
|
||||
// 是否需要关闭调起支付的页面
|
||||
if(redirect){
|
||||
uni.redirectTo({
|
||||
url:return_url
|
||||
});
|
||||
}else{
|
||||
uni.navigateTo({
|
||||
url:return_url
|
||||
})
|
||||
}
|
||||
}
|
||||
},2000)
|
||||
// })
|
||||
}
|
||||
}else{
|
||||
OrderData['WechatRetreat'] = true;
|
||||
window.location.href=`https://ds.alipay.com/?scheme=${encodeURIComponent(`alipays://platformapi/startapp?appId=2021003130603407&page=pages/wxpay/h5pay/h5pay?data=${encodeURIComponent(JSON.stringify(OrderData))}`)}`
|
||||
// window.location.href = `https://ds.alipay.com/?scheme=alipays://platformapi/startapp?appId=2021003130603407&page=pages/wxpay/h5pay/h5pay?data=${encodeURIComponent(JSON.stringify(OrderData))}`;
|
||||
// 支付宝支付
|
||||
// this.WX_Pay(data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {String} pay_price 支付金额
|
||||
* @param {String} order_sn 订单号
|
||||
|
|
|
|||
|
|
@ -317,14 +317,6 @@ const restaurantmixins = {
|
|||
if (!res.data.used_coin) {
|
||||
this.use_coin = false
|
||||
}
|
||||
}).catch(res => {
|
||||
this.computedTotal = res.data;
|
||||
if (!res.data.used_broker) {
|
||||
this.use_broker = false
|
||||
};
|
||||
if (!res.data.used_coin) {
|
||||
this.use_coin = false
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue