From 2e800655947439e8d71f05fddb3ad49770eec9fd Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期二, 16 九月 2025 13:40:30 +0800
Subject: [PATCH] Merge branch 'dev-1.4.1'
---
packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeStep2.vue | 233 +++++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 157 insertions(+), 76 deletions(-)
diff --git a/packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeStep2.vue b/packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeStep2.vue
index 77a5c5c..a5508c1 100644
--- a/packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeStep2.vue
+++ b/packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeStep2.vue
@@ -6,68 +6,88 @@
label-position="top"
class="order-bill-recharge phone"
>
- <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.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.phone"
- :remark="form.remark"
- >
- <template #action>
- <div class="account-card-action" @click="handleAddUserAccount">鏂板</div>
- </template>
- </AccountCard>
- <AccountAddCard v-else @click="handleAddUserAccount" />
- </NutFormItem>
+ <NutRadio
+ :label="item.id"
+ shape="button"
+ v-for="item in userAccountAllList"
+ :key="item.id"
+ >{{ addStarForPhone(item.content) }}</NutRadio
+ >
+ </NutRadioGroup>
+ <AccountCardV2
+ v-if="userAccountAllList.length > 0"
+ :content="StringUtils.phoneNumberAddSpace(form.phone)"
+ :remark="form.remark"
+ :showEditBtn="!!form.currentUserAccountId"
+ @add="handleAddUserAccount"
+ @edit="emit('editUserAccount', form.currentUserAccountId)"
+ >
+ </AccountCardV2>
+ <AccountAddCardV2
+ content="鍘绘坊鍔犲厖鍊煎彿鐮�"
+ remark="娣诲姞鍙风爜灏嗕繚瀛樺湪鐢熸椿缂磋垂杩涜绠$悊"
+ tip="娣诲姞姝g‘鍙风爜"
+ v-else
+ @add="handleAddUserAccount"
+ />
+ </NutFormItem>
+ </Chunk>
- <NutFormItem 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, lifePayPhoneRate) }}鍏�
+ <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 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, lifePayPhoneRate) }}鍏�
+ </div>
+ </div>
+ <div class="discountTag" v-if="lifePayPhoneRate > 0">{{ lifePayPhoneRate }}鎶�</div>
+ <img :src="IconSelect" class="discount-icon" />
</div>
- <div class="discountTag">{{ lifePayPhoneRate }}鎶�</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 class="recharge-button-text">绔嬪嵆鍏呭��</div>
</div>
</nut-button>
- <RechargeTipsView :tips="tips" />
+ <RechargeTipsView :lifePayOrderType="LifeRechargeConstants.LifePayOrderTypeEnum.璇濊垂璁㈠崟" />
</div>
<ConfirmDialog v-model:visible="confirmDialogVisible" @ok="goPay">
<template #info>
@@ -77,6 +97,7 @@
<ConfirmDialogInfoItem label="瀹炰粯閲戦" :content="`锟�${realParValue}`" danger />
</template>
</ConfirmDialog>
+ <NutToast :msg="state.msg" v-model:visible="state.show" type="warn" cover :duration="3000" />
</NutForm>
</template>
@@ -88,10 +109,11 @@
Radio as NutRadio,
Input as NutInput,
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, provide } from 'vue';
-import { FormValidator } from '../../utils';
+import { reactive, ref, computed, toRef } from 'vue';
+import { FormValidator, initLifePayType, addStarForPhone, StringUtils } from '../../utils';
import {
useLifeRechargeContext,
BlLifeRecharge,
@@ -102,20 +124,21 @@
import ConfirmDialog from '../../components/Dialog/ConfirmDialog.vue';
import ConfirmDialogInfoItem from '../../components/Dialog/ConfirmDialogInfoItem.vue';
import { useGetRate, useGetPhoneParValue, useSetUserAccountBySelect } from '../../hooks';
-import { CustomerServiceTips } from '../../constants';
-import AccountAddCard from '../../components/Card/AccountAddCard.vue';
-import AccountCard from '../../components/Card/AccountCard.vue';
+import AccountAddCardV2 from '../../components/Card/AccountAddCardV2.vue';
+import AccountCardV2 from '../../components/Card/AccountCardV2.vue';
import { usePhoneBillRechargeContext, PhoneUserAccountExtraProperties } from './context';
+import SelectPayTypeFormItem from '../../components/SelectPayTypeFormItem/SelectPayTypeFormItem.vue';
+import { useSelectPayType, useGetPayStatusByOrderNo } from '../../hooks/selectPayType';
+import { RechargeProps } from './types';
+import Chunk from '../../components/Layout/Chunk.vue';
+import IconSelect from '../../assets/recharge/icon-select.png';
+import { useCheckCanRecharge } from '../../hooks/rate';
defineOptions({
name: 'PhoneBillRechargeStep2',
});
-type Props = {
- isDev?: boolean;
-};
-
-const props = withDefaults(defineProps<Props>(), {
+const props = withDefaults(defineProps<RechargeProps>(), {
isDev: false,
});
@@ -128,6 +151,7 @@
name: '',
currentUserAccountId: '',
remark: '',
+ lifePayType: initLifePayType(props.isInWeChat, props.isInAlipay),
});
const { userAccountAllList, handleUserAccountChange } = useSetUserAccountBySelect({
@@ -140,12 +164,31 @@
form.phone = currentUserAccount.content;
form.ispCode = currentUserAccountExtraProperties.ispCode;
form.name = currentUserAccountExtraProperties.name;
-
form.remark = currentUserAccount.remark;
-
changeIspCode(form.ispCode as any);
},
+ async getDefaultUserAccount(userAccountList) {
+ await ensureLifePayRateChannelAllList();
+ const defaultUserAccount = userAccountList.find((x) => {
+ const currentUserAccountExtraProperties = JSON.parse(
+ x.extraProperties
+ ) as PhoneUserAccountExtraProperties;
+ return isCanRecharge(currentUserAccountExtraProperties.ispCode);
+ });
+ return defaultUserAccount;
+ },
});
+
+function _handleUserAccountChange(userAccountId: string) {
+ const currentUserAccount = userAccountAllList.value.find((x) => x.id === userAccountId);
+ const currentUserAccountExtraProperties = JSON.parse(
+ currentUserAccount.extraProperties
+ ) as PhoneUserAccountExtraProperties;
+ if (!checkCanRecharge(currentUserAccountExtraProperties.ispCode)) {
+ // return;
+ }
+ handleUserAccountChange(userAccountId);
+}
function handleAddUserAccount() {
goTo('step1');
@@ -153,6 +196,9 @@
const emit = defineEmits<{
(e: 'goPay', orderNo: string): void;
+ (e: 'paySuccess', orderNo: string): void;
+ (e: 'missName', userAccountId: string): void;
+ (e: 'editUserAccount', userAccountId: string): void;
}>();
const { lifePayPhoneRate } = useGetRate();
@@ -183,27 +229,25 @@
{ required: true, message: '璇烽�夋嫨鍏呭�奸噾棰�', validator: FormValidator.validatorNumberNotNull },
],
currentUserAccountId: [{ required: true, message: '璇烽�夋嫨鍏呭�兼墜鏈哄彿' }],
+ lifePayType: [{ required: true, message: '璇烽�夋嫨鏀粯鏂瑰紡' }],
});
const formRef = ref<any>(null);
function handleSubmit() {
if (!formRef.value) return;
+ console.log('form: ', form, formRef.value);
formRef.value.validate().then(({ valid, errors }: any) => {
+ console.log('errors: ', errors);
if (valid) {
+ if (!form.name) {
+ emit('missName', form.currentUserAccountId);
+ return;
+ }
recharge();
}
});
}
-
-const tips = [
- '骞冲彴鎻愪緵鎱㈠厖鏈嶅姟锛岃鍗曟彁浜ゅ悗锛岃瘽璐瑰皢浜�0 - 24灏忔椂鍐呭埌璐︺�傝嫢鏈兘鎸夋椂鍒拌处锛岀郴缁熷皢鑷姩鍙戣捣閫�娆俱��',
- '鍏呭�兼湡闂达紝鑻ュ悓涓�鍙风爜娆鹃」鏈埌璐︼紝璇峰嬁鍦ㄥ叾浠栧钩鍙伴噸澶嶅厖鍊硷紱涓诲壇鍗′笉鍙悓鏃跺厖鍊笺�傚洜涓婅堪鎿嶄綔瀵艰嚧鐨勮祫閲戞崯澶憋紝鐢辩敤鎴疯嚜琛屾壙鎷呫��',
- '鏈钩鍙拌瘽璐瑰厖鍊兼湇鍔′笉閫傜敤浜庡凡鍋滄満鍙风爜銆傜數淇″彿鐮佽嫢鏈夋瑺璐癸紝涔熸棤娉曞畬鎴愬厖鍊笺�傜數淇″凡瀹屾垚缁存姢鐨勫尯鍩熷寘鎷細骞夸笢銆佹睙鑻忋�佹箹鍖椼�佸洓宸濄�佹睙瑗裤�佹渤鍖椼�佹渤鍗椼�佺寤恒�佽窘瀹併�傚叾瀹冨尯鍩熸鍦ㄥ垎鎵规杩涜缁存姢涓紝鍦ㄦ鏈熼棿鍙兘浼氬嚭鐜板厖鍊间笉鎴愬姛骞惰嚜鍔ㄩ��娆剧殑鎯呭喌锛岃鎮ㄨ皡瑙c��',
- '濡傛帴鍒伴檶鐢熸潵鐢碉紝瀵规柟浠ョ即璐规垨璇搷浣滅瓑鐞嗙敱瑕佹眰澶勭悊娆鹃」锛屽姟蹇呯珛鍗虫媺榛戯紝璋ㄩ槻璇堥獥銆�',
- '鍏呭�煎彂绁ㄧ敱杩愯惀鍟嗘彁渚涳紝鎮ㄥ彲鐧诲綍缃戜笂钀ヤ笟鍘呬笅杞界數瀛愬彂绁ㄣ��',
- CustomerServiceTips,
-];
const confirmDialogVisible = ref(false);
@@ -211,20 +255,57 @@
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('');
+
+const { isCanRecharge, checkCanRecharge, ensureLifePayRateChannelAllList } = useCheckCanRecharge({
+ msg: toRef(state, 'msg'),
+ show: toRef(state, 'show'),
+});
+
async function goPay() {
try {
+ if (!checkCanRecharge(form.ispCode)) {
+ return;
+ }
let params: LifePhoneDataCreateLifePayOrderInput = {
userId: blLifeRecharge.accountModel.userId,
channelId: blLifeRecharge.accountModel.channlesNum,
productData: {
ispCode: form.ispCode,
- parValue: props.isDev ? 0.1 : form.parValue,
+ parValue: form.parValue,
phone: form.phone,
- name: form.ispCode === BlLifeRecharge.constants.IspCode.dianxin ? form.name : '',
+ name: form.name,
},
};
let res = await blLifeRecharge.services.createLifePayPhoneOrder(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(
+ () =>
+ form.lifePayType === LifeRechargeConstants.LifePayTypeEnum.WxPay &&
+ props.isFocus &&
+ !!currentOrderNo.value
+ ),
+ onPaySuccess: (orderNo) => {
+ emit('paySuccess', orderNo);
+ currentOrderNo.value = '';
+ },
+});
</script>
--
Gitblit v1.9.1