| | |
| | | <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" |
| | |
| | | <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" |
| | |
| | | </div> |
| | | <div class="price-wrapper"> |
| | | <div class="price-text">折后</div> |
| | | <div class="price">{{ blLifeRecharge.getRechargeParValue(item, rate) }}元</div> |
| | | <div class="price"> |
| | | {{ blLifeRecharge.getRechargeParValue(item, lifePayElectricRate) }}元 |
| | | </div> |
| | | </div> |
| | | <div class="discountTag">{{ rate * 100 }}折</div> |
| | | <div class="discountTag">{{ lifePayElectricRate * 100 }}折</div> |
| | | </div> |
| | | </Radio> |
| | | </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> |
| | |
| | | <template #info> |
| | | <ConfirmDialogInfoItem label="电网类型" content="国家电网" /> |
| | | <ConfirmDialogInfoItem label="电费类型" content="住宅" /> |
| | | <ConfirmDialogInfoItem label="充值金额" :content="`¥${form.parValue}`" danger /> |
| | | <ConfirmDialogInfoItem label="优惠金额" :content="`¥${discountParValue}`" /> |
| | | <ConfirmDialogInfoItem label="充值金额" :content="`¥${form.parValue.toFixed(2)}`" danger /> |
| | | <ConfirmDialogInfoItem label="优惠金额" :content="`¥${discountParValue.toFixed(2)}`" /> |
| | | <ConfirmDialogInfoItem label="实付金额" :content="`¥${realParValue}`" danger /> |
| | | </template> |
| | | <template #warning> |
| | |
| | | <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 BlRadio from '../../components/Radio/Radio.vue'; |
| | | import { IspCodeText, IspCode } from '../../constants'; |
| | | import { useLifeRechargeContext } from '../../utils'; |
| | | 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: '', |
| | |
| | | sixID: '', |
| | | }); |
| | | |
| | | const rate = 0.96; |
| | | 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 ?? [] |
| | | ); |
| | | |
| | | const realParValue = computed(() => blLifeRecharge.getRechargeParValue(form.parValue, rate)); |
| | | 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) |
| | | ); |
| | | const discountParValue = computed(() => form.parValue - Number(realParValue.value)); |
| | | |
| | | 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); |
| | | |
| | |
| | | if (!formRef.value) return; |
| | | formRef.value.validate().then(({ valid, errors }: any) => { |
| | | if (valid) { |
| | | recharge(); |
| | | } |
| | | }); |
| | | } |
| | |
| | | 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> |