From bca210a1b92ccbb89a84b652a8911bf0873e2b84 Mon Sep 17 00:00:00 2001 From: gongfuxiang Date: Fri, 12 Jul 2024 22:29:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=85=E5=80=BC=E6=94=AF=E4=BB=98=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E6=9C=AA=E9=80=89=E4=B8=AD=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/payment/payment.vue | 82 +++++++++++----------- pages/plugins/wallet/recharge/recharge.vue | 13 ++-- 2 files changed, 49 insertions(+), 46 deletions(-) diff --git a/components/payment/payment.vue b/components/payment/payment.vue index 58a73941..12aa63fe 100644 --- a/components/payment/payment.vue +++ b/components/payment/payment.vue @@ -64,7 +64,28 @@ import base64 from '@/common/js/lib/base64.js'; import componentPopup from '@/components/popup/popup'; export default { - name: 'pay', + 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: { type: String, @@ -154,12 +175,18 @@ components: { componentPopup, }, - watch: { + watch: { + // 支付方式是否改变 + propPaymentList(value, old_value) { + this.setData({ + payment_list: value, + }); + }, // 是否显示支付方式 - propIsShowPayment(newVal, oldVal) { - if (newVal !== oldVal) { + propIsShowPayment(new_val, old_val) { + if (new_val !== old_val) { let bool = true; - if (this.payment_list.length === 1) { + if (this.payment_list.length == 1) { bool = false; this.setData({ payment_id: this.payment_list[0].id, @@ -167,55 +194,30 @@ } else { let self = this; self.payment_list.forEach((item) => { - let new_payment_id = Number(self.propPaymentId) === 0 ? self.propDefaultPaymentId : Number(self.propPaymentId); + let new_payment_id = Number(self.propPaymentId) == 0 ? self.propDefaultPaymentId : Number(self.propPaymentId); if (item.id == new_payment_id) { bool = false; } }); this.setData({ - payment_id: Number(this.propPaymentId) === 0 ? this.propDefaultPaymentId : Number(this.propPaymentId), + payment_id: Number(this.propPaymentId) == 0 ? this.propDefaultPaymentId : Number(this.propPaymentId), }); - } + } + this.setData({ - is_show_payment_popup: newVal, + is_show_payment_popup: new_val, submit_disabled_status: bool, }); } - }, - // 支付方式是否改变 - propPaymentList(value, old_value) { - this.setData({ - payment_list: value, - }); - }, + } }, // 页面被展示 created: function () { this.setData({ - payment_list: this.payment_list + payment_list: this.propPaymentList, + payment_id: Number(this.propPaymentId) == 0 ? this.propDefaultPaymentId : Number(this.propPaymentId), }); }, - 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: Number(this.propPaymentId) === 0 ? this.propDefaultPaymentId : Number(this.propPaymentId), - 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, - }; - }, methods: { // 支付弹窗关闭 payment_popup_event_close(e) { @@ -267,7 +269,7 @@ // 循环匹配支付方式 this.payment_list.forEach((item) => { if (item.id == payment_id) { - if (item.payment === 'WalletPay') { + if (item.payment == 'WalletPay') { var self = this; uni.showModal({ title: self.$t('common.warm_tips'), @@ -729,7 +731,7 @@ order_id: order_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, this.propTempPayIndex, Number(this.propPaymentId) == 0 ? this.propDefaultPaymentId : Number(this.propPaymentId)); if (is_to_page) { this.to_success_page_event(); } diff --git a/pages/plugins/wallet/recharge/recharge.vue b/pages/plugins/wallet/recharge/recharge.vue index bd4c4a3b..68fc4db1 100644 --- a/pages/plugins/wallet/recharge/recharge.vue +++ b/pages/plugins/wallet/recharge/recharge.vue @@ -157,7 +157,7 @@ }, get_data() { uni.request({ - url: app.globalData.get_request_url('rechargeconfigdata', 'user', 'wallet'), + url: app.globalData.get_request_url('rechargeconfigdata', 'recharge', 'wallet'), method: 'POST', data: {}, dataType: 'json', @@ -167,7 +167,6 @@ var data = res.data.data; this.setData({ preset_data: data.preset_data || [], - payment_id: data.default_payment_id || 0, recharge_desc: data.recharge_desc || '', user_wallet: data.user_wallet || null, data_list_loding_msg: '', @@ -237,12 +236,14 @@ }); uni.hideLoading(); if (res.data.code == 0) { - uni.setStorageSync(app.globalData.data.cache_page_pay_key, { type: 1 }); + uni.setStorageSync(app.globalData.data.cache_page_pay_key, { type: 1 }); + var data = res.data.data; this.setData({ + pay_price: data.money, + temp_pay_value: data.recharge_id, + payment_id: data.default_payment_id || 0, + payment_list: data.payment_list, is_show_payment_popup: true, - pay_price: res.data.data.money, - temp_pay_value: res.data.data.recharge_id, - payment_list: res.data.data.payment_list, }); } else { if (app.globalData.is_login_check(res.data)) {