| | |
| | | <template> |
| | | <NutForm |
| | | :model-value="form" |
| | | ref="formRef" |
| | | :rules="rules" |
| | | label-position="top" |
| | | class="order-bill-recharge electric" |
| | | > |
| | | <FormItem label="所在城市" class="bole-form-item" prop="province" required> |
| | | <ChooseInputWithPicker |
| | | v-model="form.province" |
| | | placeholder="请选择城市" |
| | | :value-enum="electricParValueList" |
| | | enum-label-key="areaName" |
| | | enum-value-key="areaName" |
| | | /> |
| | | </FormItem> |
| | | <!-- <FormItem label="电网类型" class="bole-form-item" prop="electricType" required> |
| | | <ChooseInputWithPicker |
| | | v-model="form.electricType" |
| | | placeholder="请选择电网类型" |
| | | :value-enum="blLifeRecharge.constants.ElectricTypeText" |
| | | /> |
| | | </FormItem> --> |
| | | <FormItem label="电费类型" class="bole-form-item" prop="electricAccountType" required> |
| | | <ChooseInputWithPicker |
| | | v-model="form.electricAccountType" |
| | | placeholder="请选择电费类型" |
| | | :value-enum="blLifeRecharge.constants.ElectricAccountTypeText" |
| | | /> |
| | | </FormItem> |
| | | <FormItem label="电网户号" class="bole-form-item" prop="electricAccount" required> |
| | | <NutInput |
| | | v-model.trim="form.electricAccount" |
| | | class="bole-input-text" |
| | | placeholder="请输入13位数字编号" |
| | | type="text" |
| | | /> |
| | | </FormItem> |
| | | <FormItem |
| | | v-if="form.electricType === blLifeRecharge.constants.ElectricType.nanwang" |
| | | label="身份证后六位" |
| | | class="bole-form-item" |
| | | prop="sixID" |
| | | required |
| | | > |
| | | <NutInput |
| | | v-model.trim="form.sixID" |
| | | class="bole-input-text" |
| | | placeholder="请输入身份证后六位" |
| | | type="text" |
| | | /> |
| | | </FormItem> |
| | | <FormItem |
| | | v-if="!!form.province" |
| | | 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" |
| | | class="parValue-item" |
| | | > |
| | | <div class="parValue-item-inner"> |
| | | <div class="amount-wrapper"> |
| | | <div class="amount">{{ item }}</div> |
| | | <div class="unit">元</div> |
| | | </div> |
| | | <div class="price-wrapper"> |
| | | <div class="price-text">折后</div> |
| | | <div class="price"> |
| | | {{ blLifeRecharge.getRechargeParValue(item, lifePayElectricRate) }}元 |
| | | </div> |
| | | </div> |
| | | <div class="discountTag">{{ lifePayElectricRate * 100 }}折</div> |
| | | </div> |
| | | </NutRadio> |
| | | </NutRadioGroup> |
| | | </FormItem> |
| | | <div class="common-content"> |
| | | <nut-button class="recharge-button" type="primary" @click="handleSubmit"> |
| | | <div class="recharge-button-inner"> |
| | | <div>¥{{ form.parValue }}</div> |
| | | <div class="recharge-button-text">立即充值</div> |
| | | </div> |
| | | </nut-button> |
| | | <RechargeTipsView :tips="tips" /> |
| | | </div> |
| | | <ConfirmDialog v-model:visible="confirmDialogVisible" @ok="goPay"> |
| | | <template #tips> |
| | | 该产品为慢充模式,0-72小时内到账,介意请勿付款!充值前请仔细阅读充值须知! |
| | | </template> |
| | | <template #info> |
| | | <ConfirmDialogInfoItem label="电网类型" content="国家电网" /> |
| | | <ConfirmDialogInfoItem label="电费类型" content="住宅" /> |
| | | <ConfirmDialogInfoItem label="充值金额" :content="`¥${form.parValue.toFixed(2)}`" danger /> |
| | | <ConfirmDialogInfoItem label="优惠金额" :content="`¥${discountParValue.toFixed(2)}`" /> |
| | | <ConfirmDialogInfoItem label="实付金额" :content="`¥${realParValue}`" danger /> |
| | | </template> |
| | | <template #warning> |
| | | 同一电费账户在充值期间,未到账前切勿在其他任何平台再次充值。因此造成的资金损失须用户自行承担!!! |
| | | </template> |
| | | </ConfirmDialog> |
| | | </NutForm> |
| | | <ElectricBillRechargeStep1 v-if="current === 'step1'" /> |
| | | <ElectricBillRechargeStep2 |
| | | v-else-if="current === 'step2'" |
| | | v-bind="props" |
| | | @go-pay="emit('goPay', $event)" |
| | | @paySuccess="emit('paySuccess', $event)" |
| | | @missName="emit('missName', $event)" |
| | | @editUserAccount="emit('editUserAccount', $event)" |
| | | /> |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | import { |
| | | Form as NutForm, |
| | | FormItem, |
| | | 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, 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'; |
| | | import { computed, provide, watch } from 'vue'; |
| | | import { useStepper } from 'senin-mini/hooks'; |
| | | import { ElectricBillRechargeContextKey } from './context'; |
| | | import ElectricBillRechargeStep1 from './ElectricBillRechargeStep1.vue'; |
| | | import ElectricBillRechargeStep2 from './ElectricBillRechargeStep2.vue'; |
| | | import { RechargeProps } from '../PhoneBillRecharge/types'; |
| | | |
| | | defineOptions({ |
| | | name: 'electricBillRecharge', |
| | | }); |
| | | |
| | | type Props = { |
| | | isDev?: boolean; |
| | | }; |
| | | |
| | | const props = withDefaults(defineProps<Props>(), { |
| | | const props = withDefaults(defineProps<RechargeProps>(), { |
| | | isDev: false, |
| | | }); |
| | | |
| | | const stepperInfo = useStepper(['step1', 'step2'], 'step2'); |
| | | const current = computed(() => stepperInfo.current.value); |
| | | |
| | | const emit = defineEmits<{ |
| | | (e: 'goPay', orderNo: string): void; |
| | | (e: 'paySuccess', orderNo: string): void; |
| | | (e: 'missName', userAccountId: string): void; |
| | | (e: 'editUserAccount', userAccountId: string): void; |
| | | (e: 'currentChange', current: 'step1' | 'step2'): void; |
| | | }>(); |
| | | |
| | | const form = reactive({ |
| | | parValue: 0, |
| | | electricAccount: '', |
| | | electricType: '', |
| | | electricAccountType: '', |
| | | province: '', |
| | | sixID: '', |
| | | }); |
| | | |
| | | const { lifePayElectricRate } = useGetRate(); |
| | | const { electricParValueList } = useGetElectricParValue(); |
| | | |
| | | 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; |
| | | current, |
| | | (newVal) => { |
| | | emit('currentChange', newVal); |
| | | }, |
| | | { |
| | | immediate: true, |
| | | } |
| | | ); |
| | | |
| | | const realParValue = computed(() => |
| | | blLifeRecharge.getRechargeParValue(form.parValue, lifePayElectricRate.value) |
| | | ); |
| | | const discountParValue = computed(() => form.parValue - Number(realParValue.value)); |
| | | |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | | |
| | | const rules = reactive<FormRules>({ |
| | | province: [{ required: true, message: '请选择所在城市' }], |
| | | electricAccountType: [{ required: true, message: '请选择电费类型' }], |
| | | electricAccount: [{ required: true, message: '请输入电网户号' }], |
| | | sixID: [{ required: true, message: '请输入身份证后六位' }], |
| | | parValue: [ |
| | | { required: true, message: '请选择充值金额', validator: FormValidator.validatorNumberNotNull }, |
| | | ], |
| | | provide(ElectricBillRechargeContextKey, { |
| | | ...stepperInfo, |
| | | }); |
| | | |
| | | const formRef = ref<any>(null); |
| | | |
| | | function handleSubmit() { |
| | | if (!formRef.value) return; |
| | | formRef.value.validate().then(({ valid, errors }: any) => { |
| | | if (valid) { |
| | | recharge(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | const tips = [ |
| | | '平台提供慢充服务,订单提交后,电费将于0 - 72 小时内到账,若未能按时到账,系统将自动发起退款。', |
| | | '充值期间,若同一账户的充值款未到账,请勿在其他平台重复充值,因上述操作导致的资金损失,由用户自行承担。', |
| | | '为确保充值顺利进行,目前平台不支持对欠款金额超过1000元的账户进行充值,且每次充值金额必须高于欠费总额。', |
| | | '如接到陌生来电,对方以缴费或误操作等理由要求处理款项,务必立即拉黑,谨防诈骗。', |
| | | '下单时,请您务必准确填写完整的省市及户号信息。充值完成后,发票由运营商提供,您可登录网上营业厅下载对应的电子发票。', |
| | | ]; |
| | | |
| | | const confirmDialogVisible = ref(false); |
| | | |
| | | function recharge() { |
| | | confirmDialogVisible.value = true; |
| | | } |
| | | |
| | | 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> |