提交 62fea6fa 编写于 作者: G gongfuxiang

支付优化,虚拟币支付

上级 dd0f396e
......@@ -253,56 +253,66 @@
},
// 支付方法
pay_handle(order_id, payment_id, payment_list = []) {
pay_handle(order_id, payment_id = 0, payment_list = []) {
// 没有指定支付方式则使用属性传过来的值
if((payment_list || null) != null && payment_list.length > 0) {
this.setData({
payment_list: payment_list
});
}
this.payment_list.forEach((item) => {
if (item.id == payment_id) {
if (item.payment === 'WalletPay') {
var self = this;
uni.showModal({
title: self.$t('common.warm_tips'),
content: self.$t('payment.payment.011cj4'),
confirmText: self.$t('common.confirm'),
cancelText: self.$t('common.not_yet'),
success(res) {
if (res.confirm) {
self.pay_handle_event(order_id, payment_id);
} else {
self.order_item_pay_fail_handle(null, order_id, self.$t('paytips.paytips.6mpsl7'));
}
},
});
} else {
this.pay_handle_event(order_id, payment_id);
}
// 没有支付方式
if((payment_id || 0) == 0) {
this.pay_handle_event(order_id, payment_id);
} else {
// 循环匹配支付方式
this.payment_list.forEach((item) => {
if (item.id == payment_id) {
if (item.payment === 'WalletPay') {
var self = this;
uni.showModal({
title: self.$t('common.warm_tips'),
content: self.$t('payment.payment.011cj4'),
confirmText: self.$t('common.confirm'),
cancelText: self.$t('common.not_yet'),
success(res) {
if (res.confirm) {
self.pay_handle_event(order_id, payment_id);
} else {
self.order_item_pay_fail_handle(null, order_id, self.$t('paytips.paytips.6mpsl7'));
}
},
});
} else {
this.pay_handle_event(order_id, payment_id);
}
}
}
});
});
}
},
// 支付处理
pay_handle_event(order_id, payment_id) {
// #ifdef H5
// 微信环境判断是否已有web_openid、不存在则不继续执行跳转到插件进行授权
if (!app.globalData.is_user_weixin_web_openid(order_id, payment_id || this.payment_id)) {
return false;
}
// #endif
// 支付方式
var payment = null;
for (var i in this.payment_list) {
if (this.payment_list[i]['id'] == (payment_id || this.payment_id)) {
payment = this.payment_list[i];
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)) {
return false;
}
}
if (payment == null) {
app.globalData.showToast(this.$t('payment.payment.7ihx9u'));
return false;
}
// #endif
// 支付方式
for (var i in this.payment_list) {
if (this.payment_list[i]['id'] == (payment_id || this.payment_id)) {
payment = this.payment_list[i];
}
}
if (payment == null) {
app.globalData.showToast(this.$t('payment.payment.7ihx9u'));
return false;
}
}
// 请求数据
var post_data = {
[this.propPayDataKey]: order_id,
......@@ -312,11 +322,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返回地址、移除重定向地址
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'];
// 存在支付标识、指定支付方式使用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
// 请求支付接口
......
......@@ -201,7 +201,7 @@
</view>
<!-- 支付选择 -->
<view v-if="((total_price > 0 || plugins_coin_payment_id != 0) && common_order_is_booking != 1 && payment_list.length > 0) || ((plugins_coin_data || null) != null && (plugins_coin_data.accounts_list || null) != null && plugins_coin_data.accounts_list.length > 0)" class="payment-list border-radius-main bg-white oh padding-main spacing-mb">
<view v-if="(total_price > 0 && common_order_is_booking != 1 && payment_list.length > 0) || ((plugins_coin_data || null) != null && (plugins_coin_data.accounts_list || null) != null && plugins_coin_data.accounts_list.length > 0)" class="payment-list border-radius-main bg-white oh padding-main spacing-mb">
<!-- 虚拟币支付 -->
<block v-if="(plugins_coin_data || null) != null && (plugins_coin_data.accounts_list || null) != null && plugins_coin_data.accounts_list.length > 0">
<block v-for="(item, index) in plugins_coin_data.accounts_list" :key="index">
......@@ -223,7 +223,7 @@
</block>
</block>
<!-- 支付方式 -->
<view v-if="(total_price > 0 || plugins_coin_payment_id != 0) && common_order_is_booking != 1 && payment_list.length > 0" class="br-t-f9">
<view v-if="total_price > 0 && common_order_is_booking != 1 && payment_list.length > 0" class="br-t-f9">
<view v-for="(item, index) in payment_list" :key="index">
<view class="item flex-row jc-sb align-c" :data-value="item.id" :data-index="index" @tap="payment_event">
<view class="item-content pr flex-1 flex-width">
......@@ -821,8 +821,8 @@
data['buy_datetime_value'] = datetime.value || '';
}
// 是否需要选择支付方式
if (this.total_price > 0 && this.common_order_is_booking != 1) {
// 是否需要选择支付方式、并且未选择虚拟币支付方式
if (this.total_price > 0 && this.common_order_is_booking != 1 && (this.plugins_coin_payment_id || null) == null) {
if ((data.payment_id || null) == null) {
app.globalData.showToast(this.$t('buy.buy.71kidy'));
return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册