From 3ee683d6b002f098e5b7fed11b54615126d82a3c Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期一, 24 二月 2025 10:57:26 +0800 Subject: [PATCH] fix: 对接 --- packages/components/src/views/PhoneBillRecharge/PhoneBillRecharge.vue | 54 ++++++++++++++++++++++++++++++------------------------ 1 files changed, 30 insertions(+), 24 deletions(-) diff --git a/packages/components/src/views/PhoneBillRecharge/PhoneBillRecharge.vue b/packages/components/src/views/PhoneBillRecharge/PhoneBillRecharge.vue index 484d4ba..ba06048 100644 --- a/packages/components/src/views/PhoneBillRecharge/PhoneBillRecharge.vue +++ b/packages/components/src/views/PhoneBillRecharge/PhoneBillRecharge.vue @@ -4,10 +4,10 @@ ref="formRef" :rules="rules" label-position="top" - class="phone-bill-recharge" + class="order-bill-recharge phone" > <FormItem label="閫夋嫨杩愯惀鍟�:" class="bole-form-item" prop="ispCode" required> - <RadioGroup v-model="form.ispCode" direction="horizontal"> + <RadioGroup v-model="form.ispCode" direction="horizontal" @change="changeIspCode"> <BlRadio :label="key" v-for="(val, key) in BlLifeRecharge.constants.IspCodeText" @@ -41,7 +41,7 @@ <FormItem label="閫夋嫨鍏呭�奸噾棰�" class="bole-form-item" prop="parValue" required> <RadioGroup v-model="form.parValue" direction="horizontal" class="parValue-radio-group"> <Radio - :label="item" + :label="Number(item)" :key="item" shape="button" v-for="item in parValueList" @@ -88,12 +88,13 @@ import { FormRules } from '@nutui/nutui-taro/dist/types/__VUE/form/types'; import { reactive, ref, computed } from 'vue'; import BlRadio from '../../components/Radio/Radio.vue'; +import { FormValidator } from '../../utils'; import { useLifeRechargeContext, BlLifeRecharge, LifePhoneDataCreateLifePayOrderInput, - FormValidator, -} from '../../utils'; + LifeRechargeConstants, +} from '@life-payment/core-vue'; import RechargeTipsView from '../../components/RechargeTipsView/RechargeTipsView.vue'; import ConfirmDialog from '../../components/Dialog/ConfirmDialog.vue'; import ConfirmDialogInfoItem from '../../components/Dialog/ConfirmDialogInfoItem.vue'; @@ -101,6 +102,14 @@ defineOptions({ name: 'PhoneBillRecharge', +}); + +type Props = { + isDev?: boolean; +}; + +const props = withDefaults(defineProps<Props>(), { + isDev: false, }); const form = reactive({ @@ -111,21 +120,22 @@ }); const emit = defineEmits<{ - ( - e: 'goPay', - form: { - ispCode: typeof BlLifeRecharge.constants.IspCode; - phone: string; - parValue: number; - name: string; - } - ): void; + (e: 'goPay', orderNo: string): void; }>(); const { lifePayPhoneRate } = useGetRate(); const { phoneParValueList } = useGetPhoneParValue(); -const parValueList = [50, 100, 200]; +const parValueList = computed( + () => phoneParValueList.value.find((x) => x.ispCode === form.ispCode)?.parValue ?? [] +); + +function changeIspCode(val: LifeRechargeConstants.IspCode) { + const phoneParValueItem = phoneParValueList.value.find((x) => x.ispCode === val); + if (phoneParValueItem.parValue.every((x) => Number(x) !== form.parValue)) { + form.parValue = 0; + } +} const realParValue = computed(() => blLifeRecharge.getRechargeParValue(form.parValue, lifePayPhoneRate.value) @@ -172,23 +182,19 @@ confirmDialogVisible.value = true; } -async function createLifePayPhoneOrder() { +async function goPay() { try { let params: LifePhoneDataCreateLifePayOrderInput = { - userId: blLifeRecharge.userId, - // lifePayType: 10, + userId: blLifeRecharge.accountModel.userId, productData: { ispCode: form.ispCode, - parValue: 0.1, - phone: '18858418480', + parValue: props.isDev ? 0.1 : form.parValue, + phone: form.phone, name: form.ispCode === BlLifeRecharge.constants.IspCode.dianxin ? form.name : '', }, }; let res = await blLifeRecharge.services.createLifePayPhoneOrder(params); + emit('goPay', res.orderNo); } catch (error) {} -} - -function goPay() { - emit('goPay'); } </script> -- Gitblit v1.9.1