zym2525
2025-03-09 c4db0ed5c4218dba29c9924511dc2bbcf169d468
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<template>
  <ContentScrollView>
    <SelectPayTypeView
      style="margin-top: 40px"
      :orderNo="orderNo"
      :lifePayOrderType="lifePayOrderType"
      @paySuccess="handePaySuccess"
      :showAliPay="!isInWeChat"
      :showWeixinPay="!isInAlipay"
      :openId="wxOpenId"
      :isInWeChat="isInWeChat"
      :isH5="isWeb"
      :appId="WXPayAppId"
      :isFocus="isFocus"
    />
  </ContentScrollView>
</template>
 
<script setup lang="ts">
import { SelectPayTypeView } from '@life-payment/components';
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 { WXPayAppId } from '@/constants';
 
defineOptions({
  name: 'selectPayType',
});
 
const router = Taro.useRouter();
const orderNo = router.params?.orderNo ?? '';
const lifePayOrderType = Number(router.params?.lifePayOrderType ?? '');
 
const { wxOpenId } = useUser();
 
const { isFocus } = useFocus();
 
function handePaySuccess(
  orderNo: string,
  lifePayOrderType: LifeRechargeConstants.LifePayOrderTypeEnum
) {
  if (lifePayOrderType === LifeRechargeConstants.LifePayOrderTypeEnum.话费订单) {
    Taro.navigateTo({
      url: `${RouterPath.rechargeResult}?orderNo=${orderNo}&lifePayOrderType=${lifePayOrderType}`,
    });
  } else if (lifePayOrderType === LifeRechargeConstants.LifePayOrderTypeEnum.电费订单) {
    Taro.navigateTo({
      url: `${RouterPath.rechargeElectricResult}?orderNo=${orderNo}&lifePayOrderType=${lifePayOrderType}`,
    });
  }
}
</script>