From e0cb82c8dbf83fabc0cab548abc873926366fb75 Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期三, 21 五月 2025 17:29:15 +0800 Subject: [PATCH] fix: 修改ui --- packages/components/src/views/GasBillRecharge/GasBillRechargeStep3.vue | 249 +++++++++++++++++++++++++++++-------------------- 1 files changed, 149 insertions(+), 100 deletions(-) diff --git a/packages/components/src/views/GasBillRecharge/GasBillRechargeStep3.vue b/packages/components/src/views/GasBillRecharge/GasBillRechargeStep3.vue index cc6068c..be78bf7 100644 --- a/packages/components/src/views/GasBillRecharge/GasBillRechargeStep3.vue +++ b/packages/components/src/views/GasBillRecharge/GasBillRechargeStep3.vue @@ -6,70 +6,88 @@ label-position="top" class="order-bill-recharge electric" > - <NutFormItem class="bole-form-item" prop="currentUserAccountId"> - <NutRadioGroup - v-model="form.currentUserAccountId" - direction="horizontal" - class="par-account-list" - v-if="userAccountAllList.length > 0" - @change="handleUserAccountChange" - > - <NutRadio :label="item.id" shape="button" v-for="item in userAccountAllList" :key="item.id" - >{{ item.city }}-{{ item.content }}</NutRadio + <Chunk borderRadiusSmall :hasPaddingBottom="false"> + <NutFormItem class="bole-form-item user-account-form-item" prop="currentUserAccountId"> + <NutRadioGroup + v-model="form.currentUserAccountId" + direction="horizontal" + class="par-account-list" + v-if="userAccountAllList.length > 0" + @change="handleUserAccountChange" > - </NutRadioGroup> - <AccountCard - v-if="userAccountAllList.length > 0" - title="鍏呭�兼埛鍙�" - :content="`${form.city} ${form.gasAccount}`" - :remark="form.remark" - > - <template #action> - <div class="account-card-action" @click="handleAddUserAccount">鏂板</div> - </template> - </AccountCard> - <AccountAddCard text="鏂板鎴峰彿" v-else @click="handleAddUserAccount" /> - </NutFormItem> + <NutRadio + :label="item.id" + shape="button" + v-for="item in userAccountAllList" + :key="item.id" + >{{ item.city }}-{{ item.content }}</NutRadio + > + </NutRadioGroup> + <AccountCardV2 + v-if="userAccountAllList.length > 0" + :content="`${form.areaList?.[1] ?? ''} ${form.gasAccount}`" + :remark="form.remark" + :showEditBtn="!!form.currentUserAccountId" + @add="handleAddUserAccount" + @edit="emit('editUserAccount', form.currentUserAccountId)" + > + </AccountCardV2> + <AccountAddCardV2 + content="鍘绘坊鍔犲厖鍊兼埛鍙�" + remark="娣诲姞鎴峰彿灏嗕繚瀛樺湪鐢熸椿缂磋垂杩涜绠$悊" + tip="娣诲姞姝g‘鎴峰彿" + v-else + @click="handleAddUserAccount" + /> + </NutFormItem> + </Chunk> - <NutFormItem - 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, lifePayGasRate) }}鍏� + <Chunk borderRadiusSmall :hasPaddingBottom="false" title="閫夋嫨鍏呭�奸噾棰�"> + <NutFormItem 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 gasValueList" + 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, lifePayGasRate) }}鍏� + </div> + </div> + <div class="discountTag" v-if="lifePayGasRate > 0">{{ lifePayGasRate }}鎶�</div> + <img :src="IconSelect" class="discount-icon" /> </div> - <div class="discountTag">{{ lifePayGasRate }}鎶�</div> - </div> - </NutRadio> --> - </NutRadioGroup> - </NutFormItem> + </NutRadio> + </NutRadioGroup> + </NutFormItem> + </Chunk> + + <SelectPayTypeFormItem + v-model="form.lifePayType" + :showWeixinPay="showWeixinPay" + :showAliPay="showAliPay" + ></SelectPayTypeFormItem> <div class="common-content"> - <nut-button class="recharge-button" type="primary" @click="handleSubmit"> + <nut-button + class="recharge-button recharge-button-linear" + type="primary" + @click="handleSubmit" + > <div class="recharge-button-inner"> - <!-- <div>锟{ realParValue }}</div> --> + <div>锟{ realParValue }}</div> <div class="recharge-button-text">绔嬪嵆鍏呭��</div> </div> </nut-button> - <RechargeTipsView :tips="tips"> + <RechargeTipsView :lifePayOrderType="LifeRechargeConstants.LifePayOrderTypeEnum.鐕冩皵璁㈠崟"> <template #tips-top> 鍚屼竴鐢佃垂璐︽埛鍦ㄥ厖鍊兼湡闂村垏鍕垮湪澶氬钩鍙伴噸澶嶅厖鍊硷紝涓嬪崟鍓嶈浠旂粏闃呰涓嬫柟椤荤煡鍐呭銆傝嫢鎺ュ埌闄岀敓鏉ョ數锛屽垏鍕胯交淇★紒锛侊紒 </template> @@ -82,7 +100,7 @@ <template #info> <ConfirmDialogInfoItem label="鐕冩皵绫诲瀷" - :content="blLifeRecharge.constants.GasOrgCodeEnumText[form.gasOrgType]" + :content="currentGasParValueItem?.gasOrgName ?? ''" /> <ConfirmDialogInfoItem :label-width="96" label="鎴峰彿" :content="form.gasAccount" /> <ConfirmDialogInfoItem label="鍏呭�奸噾棰�" :content="`锟�${form.parValue.toFixed(2)}`" danger /> @@ -93,6 +111,7 @@ 鍚屼竴鐕冩皵璐硅处鎴峰湪鍏呭�兼湡闂达紝鏈埌璐﹀墠鍒囧嬁鍦ㄥ叾浠栦换浣曞钩鍙板啀娆″厖鍊笺�傚洜姝ら�犳垚鐨勮祫閲戞崯澶遍』鐢ㄦ埛鑷鎵挎媴锛侊紒锛� </template> </ConfirmDialog> + <NutToast :msg="state.msg" v-model:visible="state.show" type="warn" cover /> </NutForm> </template> @@ -103,9 +122,10 @@ RadioGroup as NutRadioGroup, Radio as NutRadio, Button as NutButton, + Toast as NutToast, } from '@nutui/nutui-taro'; import { FormRules } from '@nutui/nutui-taro/dist/types/__VUE/form/types'; -import { reactive, ref, computed } from 'vue'; +import { reactive, ref, computed, toRef } from 'vue'; import { useLifeRechargeContext, LifeElectricDataCreateLifePayOrderInput, @@ -114,28 +134,31 @@ } from '@life-payment/core-vue'; import { useGetRate, useGetGasParValue, useSetUserAccountBySelect } from '../../hooks'; import { useGasBillRechargeContext, GasUserAccountExtraProperties } from './context'; -import { FormValidator } from '../../utils'; -import { CustomerServiceTips } from '../../constants'; -import AccountAddCard from '../../components/Card/AccountAddCard.vue'; -import AccountCard from '../../components/Card/AccountCard.vue'; +import { FormValidator, initLifePayType } from '../../utils'; +import AccountAddCardV2 from '../../components/Card/AccountAddCardV2.vue'; +import AccountCardV2 from '../../components/Card/AccountCardV2.vue'; import RechargeTipsView from '../../components/RechargeTipsView/RechargeTipsView.vue'; import ConfirmDialog from '../../components/Dialog/ConfirmDialog.vue'; import ConfirmDialogInfoItem from '../../components/Dialog/ConfirmDialogInfoItem.vue'; +import SelectPayTypeFormItem from '../../components/SelectPayTypeFormItem/SelectPayTypeFormItem.vue'; +import { useSelectPayType, useGetPayStatusByOrderNo } from '../../hooks/selectPayType'; +import { RechargeProps } from '../PhoneBillRecharge/types'; +import Chunk from '../../components/Layout/Chunk.vue'; +import IconSelect from '../../assets/recharge/icon-select.png'; defineOptions({ name: 'GasBillRechargeStep3', }); -type Props = { - isDev?: boolean; -}; - -const props = withDefaults(defineProps<Props>(), { +const props = withDefaults(defineProps<RechargeProps>(), { isDev: false, }); const emit = defineEmits<{ (e: 'goPay', orderNo: string): void; + (e: 'paySuccess', orderNo: string): void; + (e: 'missName', userAccountId: string): void; + (e: 'editUserAccount', userAccountId: string): void; }>(); const { goTo } = useGasBillRechargeContext(); @@ -143,15 +166,19 @@ const { blLifeRecharge } = useLifeRechargeContext(); const { lifePayGasRate } = useGetRate(); +const { gasParValueList } = useGetGasParValue(); const form = reactive({ parValue: 0, - province: '', - city: '', + // province: '', + // city: '', gasOrgType: '', gasAccount: '', currentUserAccountId: '', remark: '', + areaList: [] as string[], + lifePayType: initLifePayType(props.isInWeChat, props.isInAlipay), + name: '', }); const { userAccountAllList, handleUserAccountChange } = useSetUserAccountBySelect({ @@ -160,30 +187,32 @@ const currentUserAccountExtraProperties = JSON.parse( currentUserAccount.extraProperties ) as GasUserAccountExtraProperties; - // form.currentUserAccountId = currentUserAccount.id; - // form.electricAccount = currentUserAccount.content; - // form.province = currentUserAccount.province; - // form.city = currentUserAccount.city; + form.currentUserAccountId = currentUserAccount.id; + form.gasAccount = currentUserAccount.content; + form.areaList = [currentUserAccount.province, currentUserAccount.city]; + form.gasOrgType = currentUserAccount.operators; - // form.electricType = currentUserAccountExtraProperties.electricType; - // form.electricAccountType = currentUserAccountExtraProperties.electricAccountType; - // form.sixID = currentUserAccountExtraProperties.sixID; - // form.remark = currentUserAccount.remark; - // const electricParValueItem = electricParValueList.value.find( - // (x) => x.cityName === form.province - // ); - // if ( - // electricParValueItem && - // electricParValueItem.parValue.every((x) => Number(x) !== form.parValue) - // ) { - // form.parValue = 0; - // } + form.remark = currentUserAccount.remark; + form.name = currentUserAccountExtraProperties.name ?? ''; + const gasParValueItem = gasParValueList.value.find((x) => x.gasOrgCode === form.gasOrgType); + if (gasParValueItem && gasParValueItem.parValue.every((x) => Number(x) !== form.parValue)) { + form.parValue = 0; + } }, }); function handleAddUserAccount() { goTo('step1'); } + +const currentGasParValueItem = computed(() => + gasParValueList.value.find((x) => x.gasOrgCode === form.gasOrgType) +); + +const gasValueList = computed(() => { + const gasValueList = currentGasParValueItem.value?.parValue ?? []; + return blLifeRecharge.filterParValueList(gasValueList); +}); const realParValue = computed(() => blLifeRecharge.getRechargeParValue(form.parValue, lifePayGasRate.value) @@ -195,6 +224,7 @@ { required: true, message: '璇烽�夋嫨鍏呭�奸噾棰�', validator: FormValidator.validatorNumberNotNull }, ], currentUserAccountId: [{ required: true, message: '璇烽�夋嫨鍏呭�兼埛鍙�' }], + lifePayType: [{ required: true, message: '璇烽�夋嫨鏀粯鏂瑰紡' }], }); const formRef = ref<any>(null); @@ -203,21 +233,14 @@ if (!formRef.value) return; formRef.value.validate().then(({ valid, errors }: any) => { if (valid) { + if (!form.name) { + emit('missName', form.currentUserAccountId); + return; + } recharge(); } }); } - -const tips = [ - '骞冲彴鎻愪緵鎱㈠厖鏈嶅姟锛岃鍗曟彁浜ゅ悗锛岀噧姘斿皢浜�0 - 72 灏忔椂鍐呭埌璐︼紝鑻ユ湭鑳芥寜鏃跺埌璐︼紝绯荤粺灏嗚嚜鍔ㄥ彂璧烽��娆俱��', - '鐩墠骞冲彴浠呮敮鎸佷腑鍥界噧姘斿拰鍖椾含鐕冩皵鍏呭�兼湇鍔°��', - '涓浗鐕冩皵鍏呭�兼埛鍙峰繀椤诲湪鈥滃9鍝佹収鈥滱PP鐕冩皵缂磋垂鐣岄潰鏌ヨ鍒拌处鎴蜂俊鎭紝鎴峰彿涓�11寮�澶存垨鑰�5寮�澶寸殑10浣嶆暟瀛椼��', - '鍖椾含鐕冩皵涓嶆敮鎸佹瑺璐瑰厖鍊硷紝浠呮敮鎸佹櫤鑳借〃鐨勬埛鍙凤紝鎴峰彿鏄�9寮�澶�11浣嶇殑璐︽埛杩涜鍏呭�笺��', - '鍏呭�兼湡闂达紝鑻ュ悓涓�璐︽埛鐨勫厖鍊兼鏈埌璐︼紝璇峰嬁鍦ㄥ叾浠栧钩鍙伴噸澶嶅厖鍊硷紝鍥犱笂杩版搷浣滃鑷寸殑璧勯噾鎹熷け锛岀敱鐢ㄦ埛鑷鎵挎媴銆�', - '濡傛帴鍒伴檶鐢熸潵鐢碉紝瀵规柟浠ョ即璐规垨璇搷浣滅瓑鐞嗙敱瑕佹眰澶勭悊娆鹃」锛屽姟蹇呯珛鍗虫媺榛戯紝璋ㄩ槻璇堥獥銆�', - '涓嬪崟鏃讹紝璇锋偍鍔″繀鍑嗙‘濉啓瀹屾暣鐨勭渷甯傚強鎴峰彿淇℃伅銆傚厖鍊煎畬鎴愬悗锛屽彂绁ㄧ敱杩愯惀鍟嗘彁渚涳紝鎮ㄥ彲鐧诲綍缃戜笂钀ヤ笟鍘呬笅杞藉搴旂殑鐢靛瓙鍙戠エ銆�', - CustomerServiceTips, -]; const confirmDialogVisible = ref(false); @@ -225,20 +248,46 @@ confirmDialogVisible.value = true; } +const { state, invokeAliPay, invokeWeixinPay } = useSelectPayType({ + getOpenId: toRef(props, 'getOpenId'), + isInWeChat: toRef(props, 'isInWeChat'), + isH5: toRef(props, 'isH5'), + appId: toRef(props, 'appId'), +}); + +const currentOrderNo = ref(''); + async function goPay() { try { let params: LifeGasDataCreateLifePayOrderInput = { userId: blLifeRecharge.accountModel.userId, + channelId: blLifeRecharge.accountModel.channlesNum, productData: { - parValue: props.isDev ? 0.1 : form.parValue, + parValue: form.parValue, gasOrgType: form.gasOrgType, gasAccount: form.gasAccount, - province: form.province, - city: form.city, + province: form.areaList?.[0] ?? '', + city: form.areaList?.[1] ?? '', + // name: form.name, }, }; let res = await blLifeRecharge.services.createLifePayGasOrder(params); - emit('goPay', res.orderNo); + // emit('goPay', res.orderNo); + if (form.lifePayType === LifeRechargeConstants.LifePayTypeEnum.WxPay) { + await invokeWeixinPay(res.orderNo); + } else { + await invokeAliPay(res.orderNo); + } + currentOrderNo.value = res.orderNo; } catch (error) {} } + +useGetPayStatusByOrderNo({ + orderNo: currentOrderNo, + enabled: computed(() => props.isFocus && !!currentOrderNo.value), + onPaySuccess: (orderNo) => { + emit('paySuccess', orderNo); + currentOrderNo.value = ''; + }, +}); </script> -- Gitblit v1.9.1