From a50b90b16851b0ad2d9be9a12f28349e3bea4871 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期一, 24 二月 2025 13:41:22 +0800
Subject: [PATCH] fix: 对接

---
 packages/components/src/views/electricBillRecharge/electricBillRecharge.vue |   80 ++++++++++++++++++++++++++++++++--------
 1 files changed, 64 insertions(+), 16 deletions(-)

diff --git a/packages/components/src/views/electricBillRecharge/electricBillRecharge.vue b/packages/components/src/views/electricBillRecharge/electricBillRecharge.vue
index 752316a..7c08c14 100644
--- a/packages/components/src/views/electricBillRecharge/electricBillRecharge.vue
+++ b/packages/components/src/views/electricBillRecharge/electricBillRecharge.vue
@@ -10,16 +10,18 @@
       <ChooseInputWithPicker
         v-model="form.province"
         placeholder="璇烽�夋嫨鍩庡競"
-        :value-enum="IspCodeText"
+        :value-enum="electricParValueList"
+        enum-label-key="areaName"
+        enum-value-key="areaName"
       />
     </FormItem>
-    <FormItem label="鐢电綉绫诲瀷" class="bole-form-item" prop="electricType" required>
+    <!-- <FormItem label="鐢电綉绫诲瀷" class="bole-form-item" prop="electricType" required>
       <ChooseInputWithPicker
         v-model="form.electricType"
         placeholder="璇烽�夋嫨鐢电綉绫诲瀷"
         :value-enum="blLifeRecharge.constants.ElectricTypeText"
       />
-    </FormItem>
+    </FormItem> -->
     <FormItem label="鐢佃垂绫诲瀷" class="bole-form-item" prop="electricAccountType" required>
       <ChooseInputWithPicker
         v-model="form.electricAccountType"
@@ -52,7 +54,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"
@@ -75,9 +77,9 @@
       </RadioGroup>
     </FormItem>
     <div class="common-content">
-      <nut-button class="recharge-button" type="primary" @click="recharge">
+      <nut-button class="recharge-button" type="primary" @click="handleSubmit">
         <div class="recharge-button-inner">
-          <div>锟{ realParValue }}</div>
+          <div>锟{ form.parValue }}</div>
           <div class="recharge-button-text">绔嬪嵆鍏呭��</div>
         </div>
       </nut-button>
@@ -104,26 +106,37 @@
 <script setup lang="ts">
 import { Form, FormItem, RadioGroup, Radio, Input, 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 { IspCodeText, IspCode } from '../../constants';
-import { useLifeRechargeContext } from '@life-payment/core-vue';
+import { reactive, ref, computed, watch } from 'vue';
+import {
+  useLifeRechargeContext,
+  BlLifeRecharge,
+  LifeElectricDataCreateLifePayOrderInput,
+} 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';
 import ChooseInputWithPicker from '../../components/Input/ChooseInputWithPicker.vue';
 import { useGetRate, useGetElectricParValue } from '../../hooks';
+import { FormValidator } from '../../utils';
 
 defineOptions({
   name: 'electricBillRecharge',
 });
 
+type Props = {
+  isDev?: boolean;
+};
+
+const props = withDefaults(defineProps<Props>(), {
+  isDev: false,
+});
+
 const emit = defineEmits<{
-  (e: 'goPay'): void;
+  (e: 'goPay', orderNo: string): void;
 }>();
 
 const form = reactive({
-  ispCode: IspCode.yidong,
-  parValue: 100,
+  parValue: 0,
   electricAccount: '',
   electricType: '',
   electricAccountType: '',
@@ -134,7 +147,19 @@
 const { lifePayElectricRate } = useGetRate();
 const { electricParValueList } = useGetElectricParValue();
 
-const parValueList = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1500, 2000, 3000];
+const parValueList = computed(
+  () => electricParValueList.value.find((x) => x.areaName === form.province)?.parValue ?? []
+);
+
+watch(
+  () => form.province,
+  (provinceName) => {
+    const electricParValue = electricParValueList.value.find(
+      (item) => item.areaName === provinceName
+    );
+    form.electricType = electricParValue.electricType;
+  }
+);
 
 const realParValue = computed(() =>
   blLifeRecharge.getRechargeParValue(form.parValue, lifePayElectricRate.value)
@@ -143,7 +168,14 @@
 
 const { blLifeRecharge } = useLifeRechargeContext();
 
-const rules = reactive<FormRules>({});
+const rules = reactive<FormRules>({
+  electricAccountType: [{ required: true, message: '璇烽�夋嫨鐢佃垂绫诲瀷' }],
+  electricAccount: [{ required: true, message: '璇疯緭鍏ョ數缃戞埛鍙�' }],
+  sixID: [{ required: true, message: '璇疯緭鍏ヨ韩浠借瘉鍚庡叚浣�' }],
+  parValue: [
+    { required: true, message: '璇烽�夋嫨鍏呭�奸噾棰�', validator: FormValidator.validatorNumberNotNull },
+  ],
+});
 
 const formRef = ref<any>(null);
 
@@ -151,6 +183,7 @@
   if (!formRef.value) return;
   formRef.value.validate().then(({ valid, errors }: any) => {
     if (valid) {
+      recharge();
     }
   });
 }
@@ -169,8 +202,23 @@
   confirmDialogVisible.value = true;
 }
 
-function goPay() {
-  emit('goPay');
+async function goPay() {
+  try {
+    let params: LifeElectricDataCreateLifePayOrderInput = {
+      userId: blLifeRecharge.accountModel.userId,
+      productData: {
+        parValue: props.isDev ? 0.1 : form.parValue,
+        electricType: form.electricType,
+        electricAccountType: form.electricAccountType,
+        electricAccount: form.electricAccount,
+        province: form.province,
+        city: '',
+        sixID: form.sixID,
+      },
+    };
+    let res = await blLifeRecharge.services.createLifePayElectricOrder(params);
+    emit('goPay', res.orderNo);
+  } catch (error) {}
 }
 </script>
 <style lang="scss">

--
Gitblit v1.9.1