| | |
| | | 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"> |
| | | <BlRadio :label="key" v-for="(val, key) in IspCodeText" :key="key">{{ val }}</BlRadio> |
| | | <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> |
| | |
| | | v-model.trim="form.phone" |
| | | class="bole-input-text" |
| | | placeholder="请填写您需要充值的手机号码" |
| | | type="text" |
| | | /> |
| | | </FormItem> |
| | | <FormItem |
| | | label="姓名" |
| | | class="bole-form-item" |
| | | prop="name" |
| | | required |
| | | v-if="form.ispCode === BlLifeRecharge.constants.IspCode.dianxin" |
| | | > |
| | | <Input |
| | | v-model.trim="form.name" |
| | | class="bole-input-text" |
| | | placeholder="请填写您的姓名" |
| | | type="text" |
| | | /> |
| | | </FormItem> |
| | |
| | | </div> |
| | | <div class="price-wrapper"> |
| | | <div class="price-text">折后</div> |
| | | <div class="price">{{ blLifeRecharge.getRechargeParValue(item, rate) }}元</div> |
| | | <div class="price"> |
| | | {{ blLifeRecharge.getRechargeParValue(item, lifePayPhoneRate) }}元 |
| | | </div> |
| | | </div> |
| | | <div class="discountTag">{{ rate * 100 }}折</div> |
| | | <div class="discountTag">{{ lifePayPhoneRate * 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>¥{{ form.parValue }}</div> |
| | | <div class="recharge-button-text">立即充值</div> |
| | |
| | | </div> |
| | | <ConfirmDialog v-model:visible="confirmDialogVisible" @ok="goPay"> |
| | | <template #info> |
| | | <ConfirmDialogInfoItem label="充值账号" content="18858418480" /> |
| | | <ConfirmDialogInfoItem label="充值金额" :content="`¥${form.parValue}`" danger /> |
| | | <ConfirmDialogInfoItem label="优惠金额" :content="`¥${discountParValue}`" /> |
| | | <ConfirmDialogInfoItem label="充值账号" :content="form.phone" /> |
| | | <ConfirmDialogInfoItem label="充值金额" :content="`¥${form.parValue.toFixed(2)}`" danger /> |
| | | <ConfirmDialogInfoItem label="优惠金额" :content="`¥${discountParValue.toFixed(2)}`" /> |
| | | <ConfirmDialogInfoItem label="实付金额" :content="`¥${realParValue}`" danger /> |
| | | </template> |
| | | </ConfirmDialog> |
| | |
| | | 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 { |
| | | useLifeRechargeContext, |
| | | BlLifeRecharge, |
| | | LifePhoneDataCreateLifePayOrderInput, |
| | | FormValidator, |
| | | } from '../../utils'; |
| | | import RechargeTipsView from '../../components/RechargeTipsView/RechargeTipsView.vue'; |
| | | import ConfirmDialog from '../../components/Dialog/ConfirmDialog.vue'; |
| | | import ConfirmDialogInfoItem from '../../components/Dialog/ConfirmDialogInfoItem.vue'; |
| | | import { useGetRate, useGetPhoneParValue } from '../../hooks'; |
| | | |
| | | defineOptions({ |
| | | name: 'PhoneBillRecharge', |
| | | }); |
| | | |
| | | const emit = defineEmits<{ |
| | | (e: 'goPay'): void; |
| | | }>(); |
| | | |
| | | const form = reactive({ |
| | | ispCode: IspCode.yidong, |
| | | ispCode: BlLifeRecharge.constants.IspCode.yidong, |
| | | phone: '', |
| | | parValue: 100, |
| | | parValue: 0, |
| | | name: '', |
| | | }); |
| | | |
| | | const rate = 0.96; |
| | | const emit = defineEmits<{ |
| | | ( |
| | | e: 'goPay', |
| | | form: { |
| | | ispCode: typeof BlLifeRecharge.constants.IspCode; |
| | | phone: string; |
| | | parValue: number; |
| | | name: string; |
| | | } |
| | | ): void; |
| | | }>(); |
| | | |
| | | const { lifePayPhoneRate } = useGetRate(); |
| | | const { phoneParValueList } = useGetPhoneParValue(); |
| | | |
| | | const parValueList = [50, 100, 200]; |
| | | |
| | | const realParValue = computed(() => blLifeRecharge.getRechargeParValue(form.parValue, rate)); |
| | | const realParValue = computed(() => |
| | | blLifeRecharge.getRechargeParValue(form.parValue, lifePayPhoneRate.value) |
| | | ); |
| | | const discountParValue = computed(() => form.parValue - Number(realParValue.value)); |
| | | |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | | |
| | | const rules = reactive<FormRules>({}); |
| | | const rules = reactive<FormRules>({ |
| | | ispCode: [{ required: true, message: '请选择运营商' }], |
| | | phone: [ |
| | | { required: true, message: '请输入充值手机号' }, |
| | | { validator: FormValidator.validatorPhoneNumber, message: '请输入正确的手机号' }, |
| | | ], |
| | | name: [{ 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; |
| | | } |
| | | |
| | | async function createLifePayPhoneOrder() { |
| | | try { |
| | | let params: LifePhoneDataCreateLifePayOrderInput = { |
| | | userId: blLifeRecharge.userId, |
| | | // lifePayType: 10, |
| | | productData: { |
| | | ispCode: form.ispCode, |
| | | parValue: 0.1, |
| | | phone: '18858418480', |
| | | name: form.ispCode === BlLifeRecharge.constants.IspCode.dianxin ? form.name : '', |
| | | }, |
| | | }; |
| | | let res = await blLifeRecharge.services.createLifePayPhoneOrder(params); |
| | | } catch (error) {} |
| | | } |
| | | |
| | | function goPay() { |
| | | emit('goPay'); |
| | | } |