apps/taro/src/subpackages/recharge/electricBillRecharge/InnerPage.vue
@@ -1,20 +1,23 @@ <template> <ContentScrollView :paddingH="false"> <electricBillRecharge @goPay="goPay" /> <electricBillRecharge @goPay="goPay" :isDev="isDev" /> </ContentScrollView> </template> <script setup lang="ts"> import { electricBillRecharge } from '@life-payment/components'; import { BlLifeRecharge } from '@life-payment/core-vue'; import Taro from '@tarojs/taro'; defineOptions({ name: 'InnerPage', }); function goPay() { const isDev = process.env.NODE_ENV === 'development'; function goPay(orderNo: string) { Taro.navigateTo({ url: RouterPath.selectPayType, url: `${RouterPath.selectPayType}?orderNo=${orderNo}&lifePayOrderType=${BlLifeRecharge.constants.LifePayOrderTypeEnum.电费订单}`, }); } </script> apps/taro/src/subpackages/recharge/selectPayType/InnerPage.vue
@@ -10,7 +10,8 @@ </template> <script setup lang="ts"> import { SelectPayTypeView, LifeRechargeConstants } from '@life-payment/components'; import { SelectPayTypeView } from '@life-payment/components'; import { LifeRechargeConstants } from '@life-payment/core-vue'; import Taro from '@tarojs/taro'; defineOptions({ @@ -25,8 +26,14 @@ orderNo: string, lifePayOrderType: LifeRechargeConstants.LifePayOrderTypeEnum ) { if (lifePayOrderType === LifeRechargeConstants.LifePayOrderTypeEnum.话费订单) { Taro.navigateTo({ url: `${RouterPath.rechargeResult}?orderNo=${orderNo}&lifePayOrderType=${lifePayOrderType}`, }); } else if (lifePayOrderType === LifeRechargeConstants.LifePayOrderTypeEnum.电费订单) { Taro.navigateTo({ url: `${RouterPath.rechargeElectricResult}?orderNo=${orderNo}&lifePayOrderType=${lifePayOrderType}`, }); } } </script> packages/components/src/components/Input/ChooseInputWithPicker.vue
@@ -1,13 +1,20 @@ <template> <ChooseInput :modelValue="inputValue" @click="handleOpen()"></ChooseInput> <ChooseInput :modelValue="inputValue" @click="handleOpen()" v-bind="$attrs"></ChooseInput> <Popup v-model:visible="popupVisible" position="bottom"> <Picker :modelValue="[modelValue]" :columns="options" @cancel="popupVisible = false" @confirm="handleConfirm" ></Picker> </Popup> </template> <script setup lang="ts"> import ChooseInput from './ChooseInput.vue'; import { Popup, Picker } from '@nutui/nutui-taro'; import { convertOptions, ValueEnum } from 'senin-mini/utils'; import { Portal } from 'senin-mini/components'; import { computed, h } from 'vue'; import { computed, ref } from 'vue'; defineOptions({ name: 'ChooseInputWithPicker', @@ -37,37 +44,14 @@ () => options.value?.find((x) => x.value === props.modelValue)?.text ?? '' ); function handleOpen() { const _modelValue = [props.modelValue]; Portal.add((key) => { return h( Portal.Container, { keyNumber: key, delayOpen: true }, { default: ({ open, onClose }) => h( Popup, { visible: open.value, 'onUpdate:visible': (value) => !value && onClose(), position: 'bottom', }, { default: () => h(Picker, { modelValue: _modelValue, columns: options.value, onCancel: onClose, onConfirm: ({ selectedValue, selectedOptions }) => { console.log('selectedValue: ', selectedValue, selectedOptions); const popupVisible = ref(false); function handleConfirm({ selectedValue, selectedOptions }) { emit('update:modelValue', selectedOptions[0].value); onClose(); }, }), popupVisible.value = false; } ), } ); }); function handleOpen() { popupVisible.value = true; } </script> packages/components/src/views/SelectPayTypeView/SelectPayTypeView.vue
@@ -4,7 +4,7 @@ <img class="select-pay-type-view-item-icon" :src="IconAliPay" /> <div class="select-pay-type-view-item-text">支付宝支付</div> </div> <div class="select-pay-type-view-item"> <div class="select-pay-type-view-item" @click="handleWeixinPay"> <img class="select-pay-type-view-item-icon" :src="IconWeixin" /> <div class="select-pay-type-view-item-text">微信支付</div> </div> @@ -51,6 +51,15 @@ } catch (error) {} } async function handleWeixinPay() { try { let res = await setLifePayOrderPayType(blLifeRecharge.constants.LifePayTypeEnum.WxPay); if (res) { location.href = res; } } catch (error) {} } async function setLifePayOrderPayType(lifePayType: LifeRechargeConstants.LifePayTypeEnum) { try { let params: SetLifePayOrderPayTypeInput = { 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">