From 03047a382e6f0f1945be32e28fd65e6b31817dfa Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期一, 24 二月 2025 17:52:47 +0800
Subject: [PATCH] fix: 对接
---
packages/components/src/views/PhoneBillRecharge/PhoneBillRecharge.vue | 99 ++++++++++++++++++++++++++++---------------------
1 files changed, 56 insertions(+), 43 deletions(-)
diff --git a/packages/components/src/views/PhoneBillRecharge/PhoneBillRecharge.vue b/packages/components/src/views/PhoneBillRecharge/PhoneBillRecharge.vue
index 484d4ba..eaa5392 100644
--- a/packages/components/src/views/PhoneBillRecharge/PhoneBillRecharge.vue
+++ b/packages/components/src/views/PhoneBillRecharge/PhoneBillRecharge.vue
@@ -1,47 +1,47 @@
<template>
- <Form
+ <NutForm
:model-value="form"
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">
+ <NutFormItem label="閫夋嫨杩愯惀鍟�:" class="bole-form-item" prop="ispCode" required>
+ <NutRadioGroup v-model="form.ispCode" direction="horizontal" @change="changeIspCode">
<BlRadio
:label="key"
v-for="(val, key) in BlLifeRecharge.constants.IspCodeText"
:key="key"
>{{ val }}</BlRadio
>
- </RadioGroup>
- </FormItem>
- <FormItem label="鍏呭�兼墜鏈哄彿" class="bole-form-item" prop="phone" required>
- <Input
+ </NutRadioGroup>
+ </NutFormItem>
+ <NutFormItem label="鍏呭�兼墜鏈哄彿" class="bole-form-item" prop="phone" required>
+ <NutInput
v-model.trim="form.phone"
class="bole-input-text"
placeholder="璇峰~鍐欐偍闇�瑕佸厖鍊肩殑鎵嬫満鍙风爜"
type="text"
/>
- </FormItem>
- <FormItem
+ </NutFormItem>
+ <NutFormItem
label="濮撳悕"
class="bole-form-item"
prop="name"
required
v-if="form.ispCode === BlLifeRecharge.constants.IspCode.dianxin"
>
- <Input
+ <NutInput
v-model.trim="form.name"
class="bole-input-text"
placeholder="璇峰~鍐欐偍鐨勫鍚�"
type="text"
/>
- </FormItem>
- <FormItem label="閫夋嫨鍏呭�奸噾棰�" class="bole-form-item" prop="parValue" required>
- <RadioGroup v-model="form.parValue" direction="horizontal" class="parValue-radio-group">
- <Radio
- :label="item"
+ </NutFormItem>
+ <NutFormItem label="閫夋嫨鍏呭�奸噾棰�" class="bole-form-item" prop="parValue" required>
+ <NutRadioGroup v-model="form.parValue" direction="horizontal" class="parValue-radio-group">
+ <NutRadio
+ :label="Number(item)"
:key="item"
shape="button"
v-for="item in parValueList"
@@ -60,9 +60,9 @@
</div>
<div class="discountTag">{{ lifePayPhoneRate * 100 }}鎶�</div>
</div>
- </Radio>
- </RadioGroup>
- </FormItem>
+ </NutRadio>
+ </NutRadioGroup>
+ </NutFormItem>
<div class="common-content">
<nut-button class="recharge-button" type="primary" @click="handleSubmit">
<div class="recharge-button-inner">
@@ -80,20 +80,28 @@
<ConfirmDialogInfoItem label="瀹炰粯閲戦" :content="`锟�${realParValue}`" danger />
</template>
</ConfirmDialog>
- </Form>
+ </NutForm>
</template>
<script setup lang="ts">
-import { Form, FormItem, RadioGroup, Radio, Input, Button as NutButton } from '@nutui/nutui-taro';
+import {
+ Form as NutForm,
+ FormItem as NutFormItem,
+ RadioGroup as NutRadioGroup,
+ Radio as NutRadio,
+ Input as NutInput,
+ Button as NutButton,
+} from '@nutui/nutui-taro';
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';
@@ -103,29 +111,38 @@
name: 'PhoneBillRecharge',
});
+type Props = {
+ isDev?: boolean;
+};
+
+const props = withDefaults(defineProps<Props>(), {
+ isDev: false,
+});
+
const form = reactive({
- ispCode: BlLifeRecharge.constants.IspCode.yidong,
+ ispCode: '',
phone: '',
parValue: 0,
name: '',
});
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 +189,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