优化首页

This commit is contained in:
gyq
2025-05-19 09:56:28 +08:00
parent 246b3e560c
commit d53f5e0279
11 changed files with 3010 additions and 1061 deletions

View File

@@ -301,8 +301,10 @@
cancelText: self.$t('common.not_yet'),
success(res) {
if (res.confirm) {
console.log('1111111111111111');
self.pay_handle_event(order_id, payment_id);
} else {
console.log('22222222222222');
self.order_item_pay_fail_handle(null, order_id, self.$t('paytips.paytips.6mpsl7'));
}
},
@@ -317,6 +319,8 @@
// 支付处理
pay_handle_event(order_id, payment_id = 0) {
console.log('pay_handle_event===', order_id);
// 没有指定支付方式则不匹配支付标识
var payment = null;
if ((payment_id || 0) != 0) {
@@ -338,128 +342,138 @@
}
}
// 请求数据
var post_data = {
[this.propPayDataKey]: order_id,
payment_id: payment_id || this.payment_id,
};
// h5自定义重定向地址
// #ifdef H5
var redirect_url = app.globalData.page_url_protocol(this.propToAppointPage || app.globalData.get_page_url(false));
post_data['redirect_url'] = encodeURIComponent(base64.encode(redirect_url));
// 存在支付标识、指定支付方式使用respond_url返回地址、移除重定向地址
if (payment != null) {
var respond_arr = ['PayPal', 'UniPayment'];
if (respond_arr.indexOf(payment.payment) != -1) {
post_data['respond_url'] = post_data['redirect_url'];
delete post_data['redirect_url'];
}
}
// #endif
// 请求支付接口
uni.showLoading({
title: this.$t('payment.payment.e1f54e'),
mask: true,
});
if (this.propPayUrl) {
uni.request({
url: this.propPayUrl,
method: 'POST',
data: {
...post_data,
wechat_open_id: localStorage.getItem('web_openid'),
},
dataType: 'json',
success: (res) => {
uni.hideLoading();
var data = res.data.data;
this.setData({
pay_response_data: data || {},
});
if (res.data.code == 0) {
// 是否直接支付成功
if ((data.is_success || 0) == 1) {
// 数据设置
this.order_item_pay_success_handle(data, order_id, false);
app.globalData.showToast(this.$t('paytips.paytips.679rxu'), 'success');
setTimeout(() => {
this.to_success_page_event();
}, 2000);
} else {
// 支付方式类型
let payment_type = Number(data.is_payment_type || 0);
switch (payment_type) {
// 正常线上支付
case 0:
// #ifdef APP
this.app_pay_handle(this, data, order_id);
// #endif
// #ifdef MP-TOUTIAO
// 头条是否非普通版本支持
if (parseInt(data.data.pay_type || 0) == 1) {
this.toutiao_transaction_pay_handle(this, data, order_id);
} else {
this.mp_pay_handle(this, data, order_id);
}
// #endif
// #ifdef MP-WEIXIN || MP-ALIPAY || MP-BAIDU
this.mp_pay_handle(this, data, order_id);
// #endif
// #ifdef MP-KUAISHOU
this.kuaishou_pay_handle(this, data, order_id);
// #endif
// #ifdef MP-QQ
this.qq_pay_handle(this, data, order_id);
// #endif
// #ifdef H5
this.h5_pay_handle(this, data, order_id);
// #endif
break;
// 线下支付
case 1:
// 现金支付
let self = this;
uni.showModal({
content: res.data.msg,
showCancel: false,
confirmText: self.$t('common.confirm'),
success(res) {
if (res.confirm) {
self.to_other(order_id);
} else {
self.order_item_pay_fail_handle(data, order_id, self.$t('paytips.paytips.6mpsl7'));
}
},
});
break;
// 钱包支付
case 2:
this.order_item_pay_success_handle(data, order_id);
break;
// 默认
default:
app.globalData.showToast(this.$t('payment.payment.vhx5dv'));
}
}
} else {
// 是否返回html代码展示、则提示错误
if (res.data.code == -6666 && (data || null) != null) {
this.setData({
popup_view_pay_data: data,
popup_view_pay_html_is_show: true,
});
} else {
this.order_item_pay_fail_handle(data, order_id, res.data.msg);
}
}
},
fail: (res) => {
uni.hideLoading();
app.globalData.showToast(this.$t('common.internet_error_tips'));
},
// 从一开始就判断支付方式,如果是无忧支付直接进入支付状态判断页面
console.log('payment===', payment);
if (payment.payment == 'IEPayPoli') {
console.log('直接进入无忧支付,开始跳转');
uni.setStorageSync('wuyouPay', '');
uni.redirectTo({
url: `/pages/buy/wu_you_status?payment_id=${payment.id}&order_id=${order_id}`,
});
} else {
app.globalData.showToast(this.$t('payment.payment.597s8b'));
// 请求数据
var post_data = {
[this.propPayDataKey]: order_id,
payment_id: payment_id || this.payment_id,
};
// h5自定义重定向地址
// #ifdef H5
var redirect_url = app.globalData.page_url_protocol(this.propToAppointPage || app.globalData.get_page_url(false));
post_data['redirect_url'] = encodeURIComponent(base64.encode(redirect_url));
// 存在支付标识、指定支付方式使用respond_url返回地址、移除重定向地址
if (payment != null) {
var respond_arr = ['PayPal', 'UniPayment'];
if (respond_arr.indexOf(payment.payment) != -1) {
post_data['respond_url'] = post_data['redirect_url'];
delete post_data['redirect_url'];
}
}
// #endif
// 请求支付接口
uni.showLoading({
title: this.$t('payment.payment.e1f54e'),
mask: true,
});
if (this.propPayUrl) {
uni.request({
url: this.propPayUrl,
method: 'POST',
data: {
...post_data,
wechat_open_id: localStorage.getItem('web_openid') || '',
},
dataType: 'json',
success: (res) => {
uni.hideLoading();
var data = res.data.data;
this.setData({
pay_response_data: data || {},
});
if (res.data.code == 0) {
// 是否直接支付成功
if ((data.is_success || 0) == 1) {
// 数据设置
this.order_item_pay_success_handle(data, order_id, false);
app.globalData.showToast(this.$t('paytips.paytips.679rxu'), 'success');
setTimeout(() => {
this.to_success_page_event();
}, 2000);
} else {
// 支付方式类型
let payment_type = Number(data.is_payment_type || 0);
switch (payment_type) {
// 正常线上支付
case 0:
// #ifdef APP
this.app_pay_handle(this, data, order_id);
// #endif
// #ifdef MP-TOUTIAO
// 头条是否非普通版本支持
if (parseInt(data.data.pay_type || 0) == 1) {
this.toutiao_transaction_pay_handle(this, data, order_id);
} else {
this.mp_pay_handle(this, data, order_id);
}
// #endif
// #ifdef MP-WEIXIN || MP-ALIPAY || MP-BAIDU
this.mp_pay_handle(this, data, order_id);
// #endif
// #ifdef MP-KUAISHOU
this.kuaishou_pay_handle(this, data, order_id);
// #endif
// #ifdef MP-QQ
this.qq_pay_handle(this, data, order_id);
// #endif
// #ifdef H5
this.h5_pay_handle(this, data, order_id);
// #endif
break;
// 线下支付
case 1:
// 现金支付
let self = this;
uni.showModal({
content: res.data.msg,
showCancel: false,
confirmText: self.$t('common.confirm'),
success(res) {
if (res.confirm) {
self.to_other(order_id);
} else {
self.order_item_pay_fail_handle(data, order_id, self.$t('paytips.paytips.6mpsl7'));
}
},
});
break;
// 钱包支付
case 2:
this.order_item_pay_success_handle(data, order_id);
break;
// 默认
default:
app.globalData.showToast(this.$t('payment.payment.vhx5dv'));
}
}
} else {
// 是否返回html代码展示、则提示错误
if (res.data.code == -6666 && (data || null) != null) {
this.setData({
popup_view_pay_data: data,
popup_view_pay_html_is_show: true,
});
} else {
this.order_item_pay_fail_handle(data, order_id, res.data.msg);
}
}
},
fail: (res) => {
uni.hideLoading();
app.globalData.showToast(this.$t('common.internet_error_tips'));
},
});
} else {
app.globalData.showToast(this.$t('payment.payment.597s8b'));
}
}
},
// APP支付
@@ -668,6 +682,7 @@
},
// h5支付处理
h5_pay_handle(self, data, order_id) {
console.log('h5_pay_handle===', order_id);
// 字符串则为跳转地址直接进入
if (typeof data.data == 'string') {
window.location.href = data.data;
@@ -729,6 +744,18 @@
// onBridgeReady();
// }
}
// 无忧支付
if (data.payment.payment == 'IEPayPoli') {
console.log('无忧支付order_id===', order_id);
console.log('无忧支付===', data);
uni.setStorageSync('wuyouPay', '');
uni.redirectTo({
url: `/pages/buy/wu_you_status?payment_id=${data.payment.id}&order_id=${order_id}`,
});
return;
}
// 二维码展示
if ((data.data.qrcode_url || null) != null && (data.data.name || null) != null && (data.data.order_no || null) != null) {
status = true;