zhengyiming
2025-03-17 8434c4b22d915ed796f7662cb10817b8e33c47c6
fix: 修改支付方式选择
11个文件已修改
106 ■■■■ 已修改文件
apps/taro/src/constants/tabBar.ts 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/subpackages/recharge/electricBillRecharge/InnerPage.vue 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/subpackages/recharge/gasBillRecharge/InnerPage.vue 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/subpackages/recharge/phoneBillRecharge/InnerPage.vue 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/components/SelectPayTypeFormItem/SelectPayTypeFormItem.vue 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/hooks/selectPayType.ts 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/views/GasBillRecharge/GasBillRechargeStep3.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeStep2.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/views/PhoneBillRecharge/types.ts 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/views/SelectPayTypeView/SelectPayTypeView.vue 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/views/electricBillRecharge/ElectricBillRechargeStep2.vue 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/constants/tabBar.ts
@@ -1,6 +1,5 @@
import Taro from '@tarojs/taro';
let res = Taro.getLaunchOptionsSync();
console.log('getLaunchOptionsSync: ', res);
export const TabBarPageRouterForCheck = {
  Home: `/pages/home/index`,
apps/taro/src/subpackages/recharge/electricBillRecharge/InnerPage.vue
@@ -10,6 +10,8 @@
      :isH5="isWeb"
      :appId="WXPayAppId"
      :isFocus="isFocus"
      :showAliPay="!isInWeChat"
      :showWeixinPay="isInWeChat"
    />
  </ContentScrollView>
</template>
apps/taro/src/subpackages/recharge/gasBillRecharge/InnerPage.vue
@@ -10,6 +10,8 @@
      :isH5="isWeb"
      :appId="WXPayAppId"
      :isFocus="isFocus"
      :showAliPay="!isInWeChat"
      :showWeixinPay="isInWeChat"
    />
  </ContentScrollView>
</template>
apps/taro/src/subpackages/recharge/phoneBillRecharge/InnerPage.vue
@@ -10,6 +10,8 @@
      :isH5="isWeb"
      :appId="WXPayAppId"
      :isFocus="isFocus"
      :showAliPay="!isInWeChat"
      :showWeixinPay="isInWeChat"
    />
  </ContentScrollView>
</template>
packages/components/src/components/SelectPayTypeFormItem/SelectPayTypeFormItem.vue
@@ -2,15 +2,29 @@
  <NutFormItem label="选择支付方式" class="bole-form-item" prop="lifePayType" required>
    <NutRadioGroup v-model="lifePayType" direction="horizontal">
      <BlRadio
        :label="Number(lifePayTypeEnum)"
        v-for="(lifePayTypeEnumText, lifePayTypeEnum) in LifeRechargeConstants.LifePayTypeEnumText"
        :key="lifePayTypeEnum"
        :label="LifeRechargeConstants.LifePayTypeEnum.AliPay"
        shape="button"
        class="select-pay-type-view-form-item-radio"
        v-if="showAliPay"
      >
        <div class="select-pay-type-view-form-item">
          <img class="select-pay-type-view-form-item-icon" :src="IconMap[lifePayTypeEnum]" />
          {{ lifePayTypeEnumText }}
          <img class="select-pay-type-view-form-item-icon" :src="IconAliPay" />
          {{
            LifeRechargeConstants.LifePayTypeEnumText[LifeRechargeConstants.LifePayTypeEnum.AliPay]
          }}
        </div>
      </BlRadio>
      <BlRadio
        :label="LifeRechargeConstants.LifePayTypeEnum.WxPay"
        shape="button"
        class="select-pay-type-view-form-item-radio"
        v-if="showWeixinPay"
      >
        <div class="select-pay-type-view-form-item">
          <img class="select-pay-type-view-form-item-icon" :src="IconWeixin" />
          {{
            LifeRechargeConstants.LifePayTypeEnumText[LifeRechargeConstants.LifePayTypeEnum.WxPay]
          }}
        </div>
      </BlRadio>
    </NutRadioGroup>
@@ -28,10 +42,15 @@
  name: 'SelectPayTypeFormItem',
});
const lifePayType = defineModel<LifeRechargeConstants.LifePayTypeEnum>();
const IconMap = {
  [LifeRechargeConstants.LifePayTypeEnum.WxPay]: IconWeixin,
  [LifeRechargeConstants.LifePayTypeEnum.AliPay]: IconAliPay,
type Props = {
  showAliPay?: boolean;
  showWeixinPay?: boolean;
};
const props = withDefaults(defineProps<Props>(), {
  showAliPay: true,
  showWeixinPay: true,
});
const lifePayType = defineModel<LifeRechargeConstants.LifePayTypeEnum>();
</script>
packages/components/src/hooks/selectPayType.ts
@@ -34,7 +34,9 @@
      if (res) {
        location.href = res;
      }
    } catch (error) {}
    } catch (error) {
      throw error;
    }
  }
  async function setLifePayOrderPayType(
@@ -47,7 +49,9 @@
        lifePayType: lifePayType,
      };
      return await blLifeRecharge.services.setLifePayOrderPayType(params);
    } catch (error) {}
    } catch (error) {
      throw error;
    }
  }
  async function invokeWeixinPay(orderNo: string) {
@@ -87,7 +91,9 @@
          fail: function (res) {},
        });
      }
    } catch (error) {}
    } catch (error) {
      throw error;
    }
  }
  async function getPayOrderForJsAPI(orderNo: string) {
@@ -101,7 +107,9 @@
      };
      let res = await blLifeRecharge.services.getPayOrderForJsAPI(params);
      return res;
    } catch (error) {}
    } catch (error) {
      throw error;
    }
  }
  async function handleWeixinPayByJsApi(orderNo: string) {
@@ -137,7 +145,9 @@
          );
        }
      }
    } catch (error) {}
    } catch (error) {
      throw error;
    }
  }
  return {
packages/components/src/views/GasBillRecharge/GasBillRechargeStep3.vue
@@ -56,7 +56,11 @@
        </NutRadio>
      </NutRadioGroup>
    </NutFormItem>
    <SelectPayTypeFormItem v-model="form.lifePayType"></SelectPayTypeFormItem>
    <SelectPayTypeFormItem
      v-model="form.lifePayType"
      :showWeixinPay="showWeixinPay"
      :showAliPay="showAliPay"
    ></SelectPayTypeFormItem>
    <div class="common-content">
      <nut-button class="recharge-button" type="primary" @click="handleSubmit">
        <div class="recharge-button-inner">
packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeStep2.vue
@@ -60,7 +60,11 @@
        </NutRadio>
      </NutRadioGroup>
    </NutFormItem>
    <SelectPayTypeFormItem v-model="form.lifePayType"></SelectPayTypeFormItem>
    <SelectPayTypeFormItem
      v-model="form.lifePayType"
      :showWeixinPay="showWeixinPay"
      :showAliPay="showAliPay"
    ></SelectPayTypeFormItem>
    <div class="common-content">
      <nut-button class="recharge-button" type="primary" @click="handleSubmit">
        <div class="recharge-button-inner">
packages/components/src/views/PhoneBillRecharge/types.ts
@@ -6,4 +6,6 @@
  appId?: string;
  isFocus?: boolean;
  isInAlipay?: boolean;
  showAliPay?: boolean;
  showWeixinPay?: boolean;
};
packages/components/src/views/SelectPayTypeView/SelectPayTypeView.vue
@@ -57,12 +57,16 @@
  appId: toRef(props, 'appId'),
});
function handleAliPay() {
  invokeAliPay(props.orderNo);
async function handleAliPay() {
  try {
    await invokeAliPay(props.orderNo);
  } catch (error) {}
}
function handleWeixinPay() {
  invokeWeixinPay(props.orderNo);
async function handleWeixinPay() {
  try {
    await invokeWeixinPay(props.orderNo);
  } catch (error) {}
}
useGetPayStatusByOrderNo({
packages/components/src/views/electricBillRecharge/ElectricBillRechargeStep2.vue
@@ -62,6 +62,11 @@
        </NutRadio>
      </NutRadioGroup>
    </NutFormItem>
    <SelectPayTypeFormItem
      v-model="form.lifePayType"
      :showWeixinPay="showWeixinPay"
      :showAliPay="showAliPay"
    ></SelectPayTypeFormItem>
    <div class="common-content">
      <nut-button class="recharge-button" type="primary" @click="handleSubmit">
        <div class="recharge-button-inner">
@@ -266,4 +271,13 @@
    currentOrderNo.value = res.orderNo;
  } catch (error) {}
}
useGetPayStatusByOrderNo({
  orderNo: currentOrderNo,
  enabled: computed(() => props.isFocus && !!currentOrderNo.value),
  onPaySuccess: (orderNo) => {
    emit('paySuccess', orderNo);
    currentOrderNo.value = '';
  },
});
</script>