1.支付优化

master
sws 2023-09-27 11:20:01 +08:00
parent ea6f8056b3
commit 5693f05d62
5 changed files with 31 additions and 30 deletions

31
App.vue
View File

@ -1877,18 +1877,29 @@
});
},
// url
updateQueryStringParameter(uri, key, value) {
if (!value) {
return uri;
}
var re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
var separator = uri.indexOf('?') !== -1 ? '&' : '?';
if (uri.match(re)) {
return uri.replace(re, '$1' + key + '=' + value + '$2');
// url
// query:[{key:'',value:''}]
updateQueryStringParameter(query = []) {
// #ifdef H5
let url = window.location.href;
//
if (query.length < 1) {
//url
window.history.replaceState({ path: url }, '', url);
} else {
return uri + separator + key + '=' + value;
query.forEach((item) => {
let re = new RegExp('([?&])' + item.key + '=.*?(&|$)', 'i');
let separator = url.indexOf('?') !== -1 ? '&' : '?';
if (url.match(re)) {
url = url.replace(re, '$1' + item.key + '=' + item.value + '$2');
} else {
url += separator + item.key + '=' + item.value;
}
});
//url
window.history.replaceState({ path: url }, '', url);
}
// #endif
},
},
//

View File

@ -65,12 +65,12 @@
<component-payment
:prop-pay-url="pay_url"
:prop-qrcode-url="qrcode_url"
prop-pay-data-key="recharge_id"
prop-pay-data-key="id"
:prop-payment-list="payment_list"
:prop-temp-pay-value="temp_pay_value"
:prop-temp-pay-index="temp_pay_index"
:prop-pay-price="pay_price"
:prop-to-page="to_page"
:propIsRedirectTo="true"
:prop-to-fail-page="to_fail_page"
:prop-is-show-payment="is_show_payment_popup"
@close-payment-poupon="payment_popup_event_close"
@ -102,11 +102,6 @@
temp_pay_index: 0,
is_show_payment_popup: false,
pay_price: 0,
//
to_page: {
title: '进入我的会员列表',
page: 'pages/plugins/membershiplevelvip/user/user',
},
//
to_fail_page: 'pages/plugins/membershiplevelvip/order/order',
};
@ -241,7 +236,6 @@
temp_pay_value: res.data.data.id,
pay_price: res.data.data.price,
});
console.log(res.data);
if (res.data.code == 0) {
uni.setStorageSync(app.globalData.data.cache_page_pay_key, {
order_ids: res.data.data.id,

View File

@ -159,9 +159,7 @@
this.setData({
current: e.currentTarget.dataset.index || 0,
});
var newurl = app.globalData.updateQueryStringParameter(window.location.href.split('?')[0], 'type', e.currentTarget.dataset.index + '');
//url
window.history.replaceState({ path: newurl }, '', newurl);
app.globalData.updateQueryStringParameter([{ key: 'type', value: e.currentTarget.dataset.index }]);
},
//
scroll_lower(e) {

View File

@ -17,7 +17,6 @@
:prop-temp-pay-value="temp_pay_value"
:prop-pay-price="pay_price"
:propIsRedirectTo="true"
:prop-is-show-payment="is_show_payment_popup"
@close-payment-poupon="payment_popup_event_close"
></component-payment>
</view>
@ -149,7 +148,7 @@
},
});
},
order_item_pay_success_handle() {
payment_popup_event_close() {
this.setData({
is_show_payment_popup: false,
});

View File

@ -142,13 +142,14 @@
var ck = app.globalData.data.cache_page_pay_key;
var pay_data = uni.getStorageSync(ck) || null;
if (pay_data) {
if (pay_data !== null) {
uni.removeStorageSync(ck);
this.setData({
current: pay_data.type || 0,
});
var newurl = app.globalData.updateQueryStringParameter(window.location.href.split('?')[0], 'type', pay_data.type + '');
//url
window.history.replaceState({ path: newurl }, '', newurl);
setTimeout(() => {
app.globalData.updateQueryStringParameter([{ key: 'type', value: pay_data.type }]);
}, 200);
}
this.init();
},
@ -242,9 +243,7 @@
this.setData({
current: e.currentTarget.dataset.index || 0,
});
var newurl = app.globalData.updateQueryStringParameter(window.location.href.split('?')[0], 'type', e.currentTarget.dataset.index + '');
//url
window.history.replaceState({ path: newurl }, '', newurl);
app.globalData.updateQueryStringParameter([{ key: 'type', value: e.currentTarget.dataset.index }]);
},
//
scroll_lower(e) {