fix: 跳转参数

This commit is contained in:
whitechiina 2025-03-31 16:32:07 +08:00
parent 845d797d09
commit c2e738767c
5 changed files with 136 additions and 29 deletions

View File

@ -255,9 +255,6 @@
this.SETPHONE(res['data'].phone) this.SETPHONE(res['data'].phone)
console.log('获取手机号', res.data.phone) console.log('获取手机号', res.data.phone)
this.getCart();
}).catch(e => {
console.log(e)
this.getCart(); this.getCart();
}) })
}, },
@ -369,15 +366,17 @@
// //
createFoodOrder(from).then(res => { createFoodOrder(from).then(res => {
const { pay_price, order_sn, type, openid} = res['data']; console.log(res.adta)
console.log(pay_price, order_sn, type, openid)
this.$Payment.H5_Payment({
pay_price, let redirect_url = '/pages/restaurant/order/order-details/details';
order_sn, uni.hideLoading();
type, this.$Payment.H5TOWX_Payment({
openid, datas: res['data'],
return_url:`/pages/restaurant/order/order-details/details?order_sn=${order_sn}` return_url:`/pages/restaurant/order/order-details/details?order_sn=${res.data.order_sn}`
}); });
// let redirect_url = '/pages/restaurant/order/order-details/details'; // let redirect_url = '/pages/restaurant/order/order-details/details';
// uni.hideLoading(); // uni.hideLoading();
// // // //

View File

@ -219,8 +219,6 @@
}).then(res => { }).then(res => {
this.SETPHONE(res['data']) this.SETPHONE(res['data'])
this.getCart(); this.getCart();
}).catch(e => {
this.getCart();
}) })
}, },

View File

@ -120,7 +120,8 @@ class Request {
}; };
config['complete'] = (infor) => { config['complete'] = (infor) => {
this.responseintercept(infor); this.responseintercept(infor);
if (infor['statusCode'] == 200) { console.log(infor, 'wwwwwwwwww')
if (infor.data['status'] == 200 || infor.statusCode == 200) {
// arraybuffer格式返回是不带code的 // arraybuffer格式返回是不带code的
// 判断是否是arraybuffer // 判断是否是arraybuffer
if (this['responseType'] == 'arraybuffer') { if (this['responseType'] == 'arraybuffer') {
@ -128,7 +129,7 @@ class Request {
resolve(infor['data']); resolve(infor['data']);
return return
} }
if (infor['data']['code'] != 200 && infor['data']['code'] != 7777) { if (infor['data']['status'] != 200 && infor['data']['code'] != 7777) {
uni.showToast({ uni.showToast({
title: infor['data']['msg'], title: infor['data']['msg'],
icon: 'none' icon: 'none'
@ -166,10 +167,8 @@ class Request {
// } // }
// }); // });
uni.request(Requestconfig); uni.request(Requestconfig);
}) })
} }
// 请求拦截 // 请求拦截
Requestintercept(config) { Requestintercept(config) {
// 请求时需要携带用定位 // 请求时需要携带用定位
@ -234,7 +233,8 @@ class Request {
if (isSafari && process.env.NODE_ENV !== 'development') return; if (isSafari && process.env.NODE_ENV !== 'development') return;
console.log(infor['statusCode'],'是否测试环境11221'); console.log(infor['statusCode'],'是否测试环境11221');
// 响应拦截逻辑开始 // 响应拦截逻辑开始
if (infor['statusCode'] != 200) { // if (infor['statusCode'] != 200) {
if (infor.data['status'] != 200) {
// HTPP网络请求状态错误直接提示 // HTPP网络请求状态错误直接提示
uni.showToast({ uni.showToast({
title: `${infor['data']['msg']}---${infor['url']}`, title: `${infor['data']['msg']}---${infor['url']}`,

View File

@ -6,6 +6,124 @@ import {
} from '@/request/pay/index.js'; } from '@/request/pay/index.js';
class Payment { class Payment {
static order_sn = 0 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} pay_price 支付金额
* @param {String} order_sn 订单号 * @param {String} order_sn 订单号

View File

@ -317,14 +317,6 @@ const restaurantmixins = {
if (!res.data.used_coin) { if (!res.data.used_coin) {
this.use_coin = false 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
}
}) })
}, },