zhengyiming
2025-03-20 192be5ad46233a4cd25880ba029997d47ad09bf6
fix: 三期需求
14个文件已修改
103 ■■■■ 已修改文件
apps/taro/src/hooks/user.ts 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/subpackages/recharge/electricBillRecharge/InnerPage.vue 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/subpackages/recharge/gasBillRecharge/InnerPage.vue 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/subpackages/recharge/phoneBillRecharge/InnerPage.vue 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/subpackages/recharge/selectPayType/InnerPage.vue 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/utils/common/message.tsx 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/hooks/selectPayType.ts 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/styles/rechargeGrid.scss 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/views/GasBillRecharge/GasBillRechargeStep3.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeStep2.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/views/PhoneBillRecharge/types.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/views/RechargeGrid/RechargeGrid.vue 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/views/SelectPayTypeView/SelectPayTypeView.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/views/electricBillRecharge/ElectricBillRechargeStep2.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/hooks/user.ts
@@ -83,6 +83,8 @@
  const { blLifeRecharge } = useLifeRechargeContext();
  const { getLifePayWxIndentity } = useLifePayWxIndentity();
  Taro.useReady(async () => {
    try {
      //@ts-ignore
@@ -93,13 +95,17 @@
      }
      if (!!code && !wxCode.value) {
        userStore.setWxCode(router.params.code ?? '');
        let res = await getLifePayWxIndentity();
        userStore.setWxOpenId(res.openId);
        getLifePayWxIndentity(code);
      }
    } catch (error) {}
  });
}
  async function getLifePayWxIndentity() {
export function useLifePayWxIndentity() {
  const { blLifeRecharge } = useLifeRechargeContext();
  const userStore = useUserStore();
  async function getLifePayWxIndentity(code: string) {
    try {
      let params: APIgetLifePayWxIndentityParams = {
        code: code,
@@ -107,9 +113,28 @@
      let res = await blLifeRecharge.services.getLifePayWxIndentity(params, {
        showLoading: false,
      });
      userStore.setWxOpenId(res.openId);
      return res;
    } catch (error) {}
  }
  return { getLifePayWxIndentity };
}
export function useEnsureOpenId() {
  const { wxCode, wxOpenId } = useUser();
  const { getLifePayWxIndentity } = useLifePayWxIndentity();
  async function ensureOpenId() {
    if (wxOpenId) {
      return wxOpenId.value;
    } else {
      let rea = await getLifePayWxIndentity(wxCode.value);
      return rea.openId;
    }
  }
  return { ensureOpenId };
}
export function useGoLogin() {
apps/taro/src/subpackages/recharge/electricBillRecharge/InnerPage.vue
@@ -4,7 +4,7 @@
      @goPay="goPay"
      :isDev="isDev"
      @paySuccess="handePaySuccess"
      :openId="wxOpenId"
      :getOpenId="ensureOpenId"
      :isInWeChat="isInWeChat"
      :isInAlipay="isInAlipay"
      :isH5="isWeb"
@@ -21,7 +21,7 @@
import { BlLifeRecharge } from '@life-payment/core-vue';
import Taro from '@tarojs/taro';
import { isInAlipay, isInWeChat, isH5, isWeb } from '@/utils/env';
import { useUser, useFocus } from '@/hooks';
import { useUser, useFocus, useEnsureOpenId } from '@/hooks';
import { WXPayAppId } from '@/constants';
defineOptions({
@@ -31,6 +31,7 @@
const isDev = process.env.NODE_ENV === 'development';
const { wxOpenId } = useUser();
const { ensureOpenId } = useEnsureOpenId();
const { isFocus } = useFocus();
function goPay(orderNo: string) {
apps/taro/src/subpackages/recharge/gasBillRecharge/InnerPage.vue
@@ -4,7 +4,7 @@
      @goPay="goPay"
      :isDev="isDev"
      @paySuccess="handePaySuccess"
      :openId="wxOpenId"
      :getOpenId="ensureOpenId"
      :isInWeChat="isInWeChat"
      :isInAlipay="isInAlipay"
      :isH5="isWeb"
@@ -21,7 +21,7 @@
import { BlLifeRecharge } from '@life-payment/core-vue';
import Taro from '@tarojs/taro';
import { isInAlipay, isInWeChat, isH5, isWeb } from '@/utils/env';
import { useUser, useFocus } from '@/hooks';
import { useUser, useFocus, useEnsureOpenId } from '@/hooks';
import { WXPayAppId } from '@/constants';
defineOptions({
@@ -31,6 +31,7 @@
const isDev = process.env.NODE_ENV === 'development';
const { wxOpenId } = useUser();
const { ensureOpenId } = useEnsureOpenId();
const { isFocus } = useFocus();
function goPay(orderNo: string) {
apps/taro/src/subpackages/recharge/phoneBillRecharge/InnerPage.vue
@@ -4,7 +4,7 @@
      @goPay="goPay"
      :isDev="isDev"
      @paySuccess="handePaySuccess"
      :openId="wxOpenId"
      :getOpenId="ensureOpenId"
      :isInWeChat="isInWeChat"
      :isInAlipay="isInAlipay"
      :isH5="isWeb"
@@ -21,7 +21,7 @@
import { BlLifeRecharge } from '@life-payment/core-vue';
import Taro from '@tarojs/taro';
import { isInAlipay, isInWeChat, isH5, isWeb } from '@/utils/env';
import { useUser, useFocus } from '@/hooks';
import { useUser, useFocus, useEnsureOpenId } from '@/hooks';
import { WXPayAppId } from '@/constants';
defineOptions({
@@ -31,6 +31,7 @@
const isDev = process.env.NODE_ENV === 'development';
const { wxOpenId } = useUser();
const { ensureOpenId } = useEnsureOpenId();
const { isFocus } = useFocus();
function goPay(orderNo: string) {
apps/taro/src/subpackages/recharge/selectPayType/InnerPage.vue
@@ -7,7 +7,7 @@
      @paySuccess="handePaySuccess"
      :showAliPay="!isInWeChat"
      :showWeixinPay="!isInAlipay"
      :openId="wxOpenId"
      :getOpenId="ensureOpenId"
      :isInWeChat="isInWeChat"
      :isH5="isWeb"
      :appId="WXPayAppId"
@@ -21,7 +21,7 @@
import { LifeRechargeConstants } from '@life-payment/core-vue';
import Taro from '@tarojs/taro';
import { isInAlipay, isInWeChat, isH5, isWeb } from '@/utils/env';
import { useUser, useFocus } from '@/hooks';
import { useUser, useFocus, useEnsureOpenId } from '@/hooks';
import { WXPayAppId } from '@/constants';
defineOptions({
@@ -33,6 +33,7 @@
const lifePayOrderType = Number(router.params?.lifePayOrderType ?? '');
const { wxOpenId } = useUser();
const { ensureOpenId } = useEnsureOpenId();
const { isFocus } = useFocus();
apps/taro/src/utils/common/message.tsx
@@ -49,6 +49,10 @@
                    onClose();
                    resolve(1);
                  }}
                  //@ts-ignore
                  onClickOverlay={() => {
                    onClose();
                  }}
                  confirmText={confirmText}
                ></Model>
              ),
@@ -125,6 +129,4 @@
      );
    });
  }
}
packages/components/src/hooks/selectPayType.ts
@@ -9,14 +9,14 @@
import Taro from '@tarojs/taro';
type UseSelectPayTypeOptions = {
  openId?: MaybeRef<string>;
  isInWeChat?: MaybeRef<boolean>;
  isH5?: MaybeRef<boolean>;
  appId?: MaybeRef<string>;
  getOpenId?: () => Promise<string>;
};
export function useSelectPayType(options: UseSelectPayTypeOptions = {}) {
  const { openId, isInWeChat, isH5, appId } = options;
  const { isInWeChat, isH5, appId, getOpenId } = options;
  const { blLifeRecharge } = useLifeRechargeContext();
@@ -98,10 +98,11 @@
  async function getPayOrderForJsAPI(orderNo: string) {
    try {
      const openId = await getOpenId();
      let params: GetPayOrderForJsAPIInput = {
        orderNo: orderNo,
        lifePayType: blLifeRecharge.constants.LifePayTypeEnum.WxPay,
        openId: unref(openId),
        openId: openId,
        attach: Date.now().toString(),
        payAppId: unref(appId),
      };
@@ -167,7 +168,7 @@
  const { blLifeRecharge } = useLifeRechargeContext();
  useQuery({
    queryKey: ['platformServicePayServices/getPayStatusByOrderNo', orderNo],
    queryKey: ['blLifeRecharge/getPayStatusByOrderNo', orderNo],
    queryFn: async () => {
      return await blLifeRecharge.services.getPayStatusByOrderNo(
        {
packages/components/src/styles/rechargeGrid.scss
@@ -5,6 +5,7 @@
  margin-top: 40px;
  .recharge-grid-item {
    position: relative;
    .nut-grid-item__text {
      font-size: 36rpx;
      color: boleGetCssVar('text-color', 'primary');
@@ -14,6 +15,24 @@
      width: 64px;
      height: 64px;
    }
    .discountTag {
      position: absolute;
      padding: 8px 16px;
      border-radius: 0px 0 20px 0;
      background: linear-gradient(
        186deg,
        rgba(255, 129, 45, 0.08) 14.82%,
        rgba(238, 67, 67, 0.08) 91.5%
      );
      color: #fb5100;
      font-size: 24px;
      font-weight: 700;
      line-height: 28px;
      position: absolute;
      top: -2px;
      left: -2px;
    }
  }
}
packages/components/src/views/GasBillRecharge/GasBillRechargeStep3.vue
@@ -220,7 +220,7 @@
}
const { state, invokeAliPay, invokeWeixinPay } = useSelectPayType({
  openId: toRef(props, 'openId'),
  getOpenId: props.getOpenId,
  isInWeChat: toRef(props, 'isInWeChat'),
  isH5: toRef(props, 'isH5'),
  appId: toRef(props, 'appId'),
packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeStep2.vue
@@ -211,7 +211,7 @@
}
const { state, invokeAliPay, invokeWeixinPay } = useSelectPayType({
  openId: toRef(props, 'openId'),
  getOpenId: props.getOpenId,
  isInWeChat: toRef(props, 'isInWeChat'),
  isH5: toRef(props, 'isH5'),
  appId: toRef(props, 'appId'),
packages/components/src/views/PhoneBillRecharge/types.ts
@@ -1,6 +1,5 @@
export type RechargeProps = {
  isDev?: boolean;
  openId?: string;
  isInWeChat?: boolean;
  isH5?: boolean;
  appId?: string;
@@ -8,4 +7,5 @@
  isInAlipay?: boolean;
  showAliPay?: boolean;
  showWeixinPay?: boolean;
  getOpenId?: () => Promise<string>;
};
packages/components/src/views/RechargeGrid/RechargeGrid.vue
@@ -3,12 +3,15 @@
    <Grid square :gutter="20" :column-num="2" class="recharge-grid-wrapper">
      <GridItem class="recharge-grid-item" text="话费" @click="emit('phoneBillRecharge')">
        <img :src="IconFreePhone" class="recharge-grid-item-icon" />
        <div class="discountTag">{{ lifePayPhoneRate }}折</div>
      </GridItem>
      <GridItem class="recharge-grid-item" text="电费" @click="emit('electricityBillRecharge')">
        <img :src="IconFreeDian" class="recharge-grid-item-icon" />
        <div class="discountTag">{{ lifePayElectricRate }}折</div>
      </GridItem>
      <!-- <GridItem class="recharge-grid-item" text="燃气" @click="emit('gasBillRecharge')">
        <img :src="IconFreeGas" class="recharge-grid-item-icon" />
        <div class="discountTag">{{ lifePayGasRate }}折</div>
      </GridItem> -->
    </Grid>
  </MainCell>
@@ -20,6 +23,7 @@
import IconFreePhone from '../../assets/icon-free-phone.png';
import IconFreeDian from '../../assets/icon-free-dian.png';
import IconFreeGas from '../../assets/icon-free-gas.png';
import { useGetRate } from '../../hooks';
defineOptions({
  name: 'RechargeGrid',
@@ -34,4 +38,6 @@
  (e: 'electricityBillRecharge'): void;
  (e: 'gasBillRecharge'): void;
}>();
const { lifePayPhoneRate, lifePayElectricRate, lifePayGasRate } = useGetRate();
</script>
packages/components/src/views/SelectPayTypeView/SelectPayTypeView.vue
@@ -29,11 +29,11 @@
  lifePayOrderType?: LifeRechargeConstants.LifePayOrderTypeEnum;
  showAliPay?: boolean;
  showWeixinPay?: boolean;
  openId?: string;
  isInWeChat?: boolean;
  isH5?: boolean;
  appId?: string;
  isFocus?: boolean;
  getOpenId?: () => Promise<string>;
};
const props = withDefaults(defineProps<Props>(), {
@@ -51,7 +51,7 @@
}>();
const { state, invokeAliPay, invokeWeixinPay } = useSelectPayType({
  openId: toRef(props, 'openId'),
  getOpenId: props.getOpenId,
  isInWeChat: toRef(props, 'isInWeChat'),
  isH5: toRef(props, 'isH5'),
  appId: toRef(props, 'appId'),
packages/components/src/views/electricBillRecharge/ElectricBillRechargeStep2.vue
@@ -228,10 +228,10 @@
}
const { state, invokeAliPay, invokeWeixinPay } = useSelectPayType({
  openId: toRef(props, 'openId'),
  isInWeChat: toRef(props, 'isInWeChat'),
  isH5: toRef(props, 'isH5'),
  appId: toRef(props, 'appId'),
  getOpenId: props.getOpenId,
});
const currentOrderNo = ref('');