支付优化

master
gongfuxiang 2024-08-15 16:32:50 +08:00
parent 670790681a
commit 2c99f71fbb
8 changed files with 126 additions and 91 deletions

View File

@ -1777,7 +1777,7 @@
url = this.page_url_protocol(url);
// #endif
// #ifdef H5
var url = window.location.href;
url = window.location.href;
// #endif
if (is_whole == false) {
var temp = url.split('?');
@ -1813,7 +1813,7 @@
},
// webopenid
is_user_weixin_web_openid(order_ids, payment_id = 0) {
is_user_weixin_web_openid(order_ids, payment_id = 0, page = null) {
// web_openid
if (this.is_weixin_env()) {
var web_openid = this.get_user_cache_info('weixin_web_openid') || null;
@ -1848,7 +1848,7 @@
order_ids: typeof order_ids == 'array' ? order_ids.join(',') : order_ids,
payment_id: payment_id,
});
var page_url = this.get_page_url();
var page_url = (page || null) == null ? this.get_page_url() : this.page_url_protocol(page);
page_url += page_url.indexOf('?') == -1 ? '?' : '&';
page_url += 'is_weixin_auth_web_openid=1';
var request_url = encodeURIComponent(base64.encode(page_url));

View File

@ -64,27 +64,27 @@
import base64 from '@/common/js/lib/base64.js';
import componentPopup from '@/components/popup/popup';
export default {
name: 'pay',
data() {
return {
theme_view: app.globalData.get_theme_value_view(),
//
payment_list: [],
//
is_show_payment_popup: false,
popup_view_pay_qrcode_is_show: false,
//
popup_view_pay_timer: null,
popup_view_pay_data: null,
// id
payment_id: 0,
submit_disabled_status: true,
order_id: 0,
popup_view_pay_html_is_show: false,
// url
open_pay_url_timer: null,
open_pay_url_status: true,
};
name: 'pay',
data() {
return {
theme_view: app.globalData.get_theme_value_view(),
//
payment_list: [],
//
is_show_payment_popup: false,
popup_view_pay_qrcode_is_show: false,
//
popup_view_pay_timer: null,
popup_view_pay_data: null,
// id
payment_id: 0,
submit_disabled_status: true,
order_id: 0,
popup_view_pay_html_is_show: false,
// url
open_pay_url_timer: null,
open_pay_url_status: true,
};
},
props: {
propCurrencySymbol: {
@ -175,12 +175,12 @@
components: {
componentPopup,
},
watch: {
//
propPaymentList(value, old_value) {
this.setData({
payment_list: value,
});
watch: {
//
propPaymentList(value, old_value) {
this.setData({
payment_list: value,
});
},
//
propIsShowPayment(new_val, old_val) {
@ -202,7 +202,7 @@
this.setData({
payment_id: Number(this.propPaymentId) == 0 ? this.propDefaultPaymentId : Number(this.propPaymentId),
});
}
}
this.setData({
is_show_payment_popup: new_val,
@ -214,7 +214,7 @@
//
created: function () {
this.setData({
payment_list: this.propPaymentList,
payment_list: this.propPaymentList,
payment_id: Number(this.propPaymentId) == 0 ? this.propDefaultPaymentId : Number(this.propPaymentId),
});
},
@ -261,11 +261,11 @@
this.setData({
payment_list: payment_list
});
}
//
if((payment_id || 0) == 0) {
this.pay_handle_event(order_id, payment_id);
} else {
}
//
if((payment_id || 0) == 0) {
this.pay_handle_event(order_id, payment_id);
} else {
//
this.payment_list.forEach((item) => {
if (item.id == payment_id) {
@ -288,18 +288,18 @@
this.pay_handle_event(order_id, payment_id);
}
}
});
});
}
},
//
pay_handle_event(order_id, payment_id = 0) {
//
var payment = null;
pay_handle_event(order_id, payment_id = 0) {
//
var payment = null;
if((payment_id || 0) != 0) {
// #ifdef H5
// web_openid
if (!app.globalData.is_user_weixin_web_openid(order_id, payment_id || this.payment_id)) {
if (!app.globalData.is_user_weixin_web_openid(order_id, payment_id || this.payment_id, this.propToAppointPage)) {
return false;
}
// #endif
@ -312,8 +312,8 @@
if (payment == null) {
app.globalData.showToast(this.$t('payment.payment.7ihx9u'));
return false;
}
}
}
}
//
var post_data = {
@ -324,13 +324,13 @@
// #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
// 使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
//
@ -729,9 +729,11 @@
let back_data = {
data: data,
order_id: order_id,
temp_pay_index: this.propTempPayIndex,
payment_id: this.payment_id,
is_to_page: is_to_page,
};
this.$emit('pay-success', back_data, this.propTempPayIndex, Number(this.propPaymentId) == 0 ? this.propDefaultPaymentId : Number(this.propPaymentId));
this.$emit('pay-success', back_data);
if (is_to_page) {
this.to_success_page_event();
}

View File

@ -889,10 +889,6 @@
},
});
} else {
//
this.setData({
to_appoint_page: this.to_appoint_page + '?order_ids=' + res.data.order_ids.join(','),
});
this.$refs.payment.pay_handle(res.data.order_ids.join(','), res.data.payment_id, this.payment_list);
}
},

View File

@ -39,6 +39,7 @@
<component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
</scroll-view>
<component-payment
ref="payment"
:propPayUrl="pay_url"
:propQrcodeUrl="qrcode_url"
propPayDataKey="id"
@ -249,6 +250,20 @@
this.setData({
data_bottom_line_status: this.data_page > 1 && this.data_page > this.data_page_total,
});
//
var key = app.globalData.data.cache_page_pay_key;
var pay_data = uni.getStorageSync(key) || null;
if (pay_data != null && (pay_data.order_ids || null) != null && (pay_data.payment_id || null) != null) {
uni.removeStorageSync(key);
this.setData({
temp_pay_value: pay_data.order_ids,
payment_id: pay_data.payment_id,
});
if ((this.$refs.payment || null) != null) {
this.$refs.payment.pay_handle(pay_data.order_ids, pay_data.payment_id, this.payment_list);
}
}
} else {
this.setData({
data_list_loding_status: 0,
@ -310,12 +325,16 @@
},
//
order_item_pay_success_handle(data, index) {
//
order_item_pay_success_handle(data) {
var order_ids_arr = data.order_id.toString().split(',');
var temp_data_list = this.data_list;
temp_data_list[index]['pay_price'] = temp_data_list[index]['price'];
temp_data_list[index]['status'] = 1;
temp_data_list[index]['status_name'] = this.$t('order.order.s8g966');
for (var i in temp_data_list) {
if (order_ids_arr.indexOf(temp_data_list[i]['id'].toString()) != -1) {
temp_data_list[i]['pay_price'] = temp_data_list[i]['price'];
temp_data_list[i]['status'] = 1;
temp_data_list[i]['status_name'] = this.$t('order.order.s8g966');
}
}
this.setData({
data_list: temp_data_list,
});

View File

@ -70,6 +70,7 @@
<!-- 支付组件 -->
<component-payment
ref="payment"
:propCurrencySymbol="payment_currency_symbol"
:propPayUrl="pay_url"
:propQrcodeUrl="qrcode_url"
@ -282,18 +283,18 @@ export default {
data_bottom_line_status: this.data_page > 1 && this.data_page > this.data_page_total,
});
// url
if ((this.params.order_ids || null) !== null) {
var order_ids_arr = this.params.order_ids.split(',');
var temp_data_list = this.data_list;
for (var i in temp_data_list) {
if (order_ids_arr.indexOf(temp_data_list[i]['order_id']) != -1) {
temp_data_list[i]['is_under_line'] = 1;
}
}
//
var key = app.globalData.data.cache_page_pay_key;
var pay_data = uni.getStorageSync(key) || null;
if (pay_data != null && (pay_data.order_ids || null) != null && (pay_data.payment_id || null) != null) {
uni.removeStorageSync(key);
this.setData({
data_list: temp_data_list,
temp_pay_value: pay_data.order_ids,
payment_id: pay_data.payment_id,
});
if ((this.$refs.payment || null) != null) {
this.$refs.payment.pay_handle(pay_data.order_ids, pay_data.payment_id, this.original_payment_list);
}
}
} else {
this.setData({
@ -372,11 +373,11 @@ export default {
//
//
order_item_pay_success_handle(data, index, order_ids) {
var order_ids_arr = data.order_id.split(',');
order_item_pay_success_handle(data) {
var order_ids_arr = data.order_id.toString().split(',');
var temp_data_list = this.data_list;
for (var i in temp_data_list) {
if (order_ids_arr.indexOf(temp_data_list[i]['order_id']) != -1) {
if (order_ids_arr.indexOf(temp_data_list[i]['order_id'].toString()) != -1) {
temp_data_list[i]['operate_data']['is_pay'] = 0;
temp_data_list[i]['operate_data']['is_cancel'] = 0;
temp_data_list[i]['status'] = 2;

View File

@ -270,8 +270,8 @@
form: new_data,
});
},
//
//
more_event() {
this.setData({
is_more: !this.is_more,

View File

@ -39,6 +39,7 @@
<!-- 支付弹窗 -->
<component-payment
ref="payment"
:propPayUrl="pay_url"
:propQrcodeUrl="qrcode_url"
propPayDataKey="recharge_id"
@ -242,6 +243,20 @@
this.setData({
data_bottom_line_status: this.data_page > 1 && this.data_page > this.data_page_total,
});
//
var key = app.globalData.data.cache_page_pay_key;
var pay_data = uni.getStorageSync(key) || null;
if (pay_data != null && (pay_data.order_ids || null) != null && (pay_data.payment_id || null) != null) {
uni.removeStorageSync(key);
this.setData({
temp_pay_value: pay_data.order_ids,
payment_id: pay_data.payment_id,
});
if ((this.$refs.payment || null) != null) {
this.$refs.payment.pay_handle(pay_data.order_ids, pay_data.payment_id, this.payment_list);
}
}
} else {
this.setData({
data_list_loding_status: 0,
@ -292,15 +307,21 @@
});
},
//
order_item_pay_success_handle(data, index) {
//
order_item_pay_success_handle(data) {
var order_ids_arr = data.order_id.toString().split(',');
var temp_data_list = this.data_list;
temp_data_list[index]['pay_money'] = temp_data_list[index]['money'];
temp_data_list[index]['status'] = 1;
temp_data_list[index]['status_name'] = this.$t('order.order.s8g966');
for (var i in temp_data_list) {
if (order_ids_arr.indexOf(temp_data_list[i]['id'].toString()) != -1) {
temp_data_list[i]['pay_money'] = temp_data_list[i]['money'];
temp_data_list[i]['status'] = 1;
temp_data_list[i]['status_name'] = this.$t('order.order.s8g966');
}
}
this.setData({
data_list: temp_data_list,
});
//
this.$emit('pay-success');
},

View File

@ -102,6 +102,7 @@
<!-- 支付组件 -->
<component-payment
ref="payment"
:propCurrencySymbol="payment_currency_symbol"
:propPayUrl="pay_url"
:propQrcodeUrl="qrcode_url"
@ -336,18 +337,14 @@
data_bottom_line_status: this.data_page > 1 && this.data_page > this.data_page_total,
});
// url
if ((this.params.order_ids || null) !== null) {
var order_ids_arr = this.params.order_ids.split(',');
var temp_data_list = this.data_list;
for (var i in temp_data_list) {
if (order_ids_arr.indexOf(temp_data_list[i]['id']) != -1) {
temp_data_list[i]['is_under_line'] = 1;
}
//
var key = app.globalData.data.cache_page_pay_key;
var pay_data = uni.getStorageSync(key) || null;
if (pay_data != null && (pay_data.order_ids || null) != null && (pay_data.payment_id || null) != null) {
uni.removeStorageSync(key);
if ((this.$refs.payment || null) != null) {
this.$refs.payment.pay_handle(pay_data.order_ids, pay_data.payment_id, this.original_payment_list);
}
this.setData({
data_list: temp_data_list,
});
}
} else {
this.setData({
@ -426,13 +423,12 @@
//
//
order_item_pay_success_handle(data, index, order_ids) {
var order_ids_arr = data.order_id.split(',');
order_item_pay_success_handle(data) {
var order_ids_arr = data.order_id.toString().split(',');
var temp_data_list = this.data_list;
//
console.log(order_ids_arr)
for (var i in temp_data_list) {
if (order_ids_arr.indexOf(temp_data_list[i]['id']) != -1) {
if (order_ids_arr.indexOf(temp_data_list[i]['id'].toString()) != -1) {
temp_data_list[i]['operate_data']['is_pay'] = 0;
temp_data_list[i]['operate_data']['is_cancel'] = 0;
switch (parseInt(temp_data_list[i]['order_model'])) {