Merge branch 'master' of http://120.26.58.240:8888/r/LifePaymentFront
| | |
| | | |
| | | OSS_URL: '"https://waterdroptest2.oss-cn-hangzhou.aliyuncs.com/"', |
| | | WEMAP_KEY: 'T2UBZ-N563J-ZCHFF-XDOXN-VCH7S-CJB2T', |
| | | WXPayAppId: 'wxf940ff1d35a98493', |
| | | }, |
| | | defineConstants: {}, |
| | | mini: {}, |
| | |
| | | OSS_URL: '"https://parkmanagement.oss-cn-hangzhou.aliyuncs.com"', |
| | | |
| | | WEMAP_KEY: 'DYRBZ-ZGPCF-X3OJN-N2AA3-JWUCE-HEBXJ', |
| | | WXPayAppId: 'wxf940ff1d35a98493', |
| | | }, |
| | | defineConstants: {}, |
| | | mini: {}, |
| | |
| | | APP_ENV: '"staging"', |
| | | |
| | | WEMAP_KEY: 'T2UBZ-N563J-ZCHFF-XDOXN-VCH7S-CJB2T', |
| | | WXPayAppId: 'wxf940ff1d35a98493', |
| | | }, |
| | | h5: { |
| | | output: { |
| | |
| | | toDetail = 'toDetail', |
| | | back = 'back', |
| | | } |
| | | |
| | | export const WXPayAppId = process.env.WXPayAppId; |
| | |
| | | import { useRefeshDidShow } from './infiniteLoading'; |
| | | import { LoginFormTabs } from '@/subpackages/login/constants'; |
| | | import { useLoginedJump } from './login'; |
| | | import { useLifeRechargeContext, APIgetLifePayWxIndentityParams } from '@life-payment/core-vue'; |
| | | |
| | | export function useUser() { |
| | | const userStore = useUserStore(); |
| | | |
| | | const { userDetail, userInfo, locationCity, virtualUserId, virtualPhoneNumber } = |
| | | storeToRefs(userStore); |
| | | const { |
| | | userDetail, |
| | | userInfo, |
| | | locationCity, |
| | | virtualUserId, |
| | | virtualPhoneNumber, |
| | | wxCode, |
| | | wxOpenId, |
| | | } = storeToRefs(userStore); |
| | | |
| | | function updateUserInfo() { |
| | | return userStore.getCurrentUserInfo(); |
| | |
| | | locationCity, |
| | | virtualUserId, |
| | | virtualPhoneNumber, |
| | | wxCode, |
| | | wxOpenId, |
| | | }; |
| | | } |
| | | |
| | |
| | | return { isAuth }; |
| | | } |
| | | |
| | | export function useInitWeixinJSBridge() { |
| | | const { wxCode } = useUser(); |
| | | |
| | | const userStore = useUserStore(); |
| | | const router = Taro.useRouter(); |
| | | |
| | | const code = router.params.code ?? ''; |
| | | |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | | |
| | | Taro.useReady(async () => { |
| | | if (!code && !!WeixinJSBridge && !wxCode) { |
| | | location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf940ff1d35a98493&redirect_uri=${location.href}&response_type=code&scope=snsapi_base#wechat_redirect`; |
| | | } |
| | | if (!!code && !wxCode) { |
| | | try { |
| | | userStore.setWxCode(router.params.code ?? ''); |
| | | let res = await getLifePayWxIndentity(); |
| | | userStore.setWxOpenId(res.openId); |
| | | } catch (error) {} |
| | | } |
| | | |
| | | async function getLifePayWxIndentity() { |
| | | try { |
| | | let params: APIgetLifePayWxIndentityParams = { |
| | | code: code, |
| | | }; |
| | | let res = await blLifeRecharge.services.getLifePayWxIndentity(params, { |
| | | showLoading: false, |
| | | }); |
| | | return res; |
| | | } catch (error) {} |
| | | } |
| | | }); |
| | | } |
| | | |
| | | export function useGoLogin() { |
| | | const router = Taro.useRouter(); |
| | | const { redirectParams } = useLoginedJump(); |
| | |
| | | <script> |
| | | <%= htmlWebpackPlugin.options.script %> |
| | | </script> |
| | | <script src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script> |
| | | </head> |
| | | <body> |
| | | <div id="app"></div> |
| | |
| | | import { OrderInputType } from '@life-payment/constants'; |
| | | import { RechargeGrid } from '@life-payment/components'; |
| | | |
| | | const userStore = useUserStore(); |
| | | |
| | | const router = Taro.useRouter(); |
| | | |
| | | const goPhoneBillRecharge = useAccessLogin(() => { |
| | | Taro.navigateTo({ |
| | | url: `${RouterPath.phoneBillRecharge}`, |
| | |
| | | |
| | | virtualUserId?: string; |
| | | virtualPhoneNumber?: string; |
| | | |
| | | wxCode?: string; |
| | | wxOpenId?: string; |
| | | } |
| | | |
| | | const goAuthorization = debounce( |
| | |
| | | |
| | | virtualUserId: storageVirtualUser?.virtualUserId ?? '', |
| | | virtualPhoneNumber: storageVirtualUser?.virtualPhoneNumber ?? '', |
| | | |
| | | wxCode: '', |
| | | wxOpenId: '', |
| | | }; |
| | | }, |
| | | getters: { |
| | |
| | | setUserDetail(detail); |
| | | }, |
| | | |
| | | setWxCode(code: string) { |
| | | this.wxCode = code; |
| | | }, |
| | | setWxOpenId(openId: string) { |
| | | this.wxOpenId = openId; |
| | | }, |
| | | |
| | | resetState() { |
| | | this.userInfo = null; |
| | | this.token = ''; |
| | |
| | | this.userDetail = null; |
| | | this.virtualUserId = ''; |
| | | this.virtualPhoneNumber = ''; |
| | | this.wxCode = ''; |
| | | this.wxOpenId = ''; |
| | | removeUserInfo(); |
| | | removeUserDetail(); |
| | | removeStorageVirtualUserId(); |
| | |
| | | @paySuccess="handePaySuccess" |
| | | :showAliPay="!isInWeChat" |
| | | :showWeixinPay="!isInAlipay" |
| | | :openId="wxOpenId" |
| | | :isInWeChat="isInWeChat" |
| | | :isH5="isH5" |
| | | :appId="WXPayAppId" |
| | | /> |
| | | </ContentScrollView> |
| | | </template> |
| | |
| | | import { SelectPayTypeView } from '@life-payment/components'; |
| | | import { LifeRechargeConstants } from '@life-payment/core-vue'; |
| | | import Taro from '@tarojs/taro'; |
| | | import { isInAlipay, isInWeChat } from '@/utils/env'; |
| | | import { isInAlipay, isInWeChat, isH5 } from '@/utils/env'; |
| | | import { useUser } from '@/hooks'; |
| | | import { WXPayAppId } from '@/constants'; |
| | | |
| | | defineOptions({ |
| | | name: 'selectPayType', |
| | |
| | | const orderNo = router.params?.orderNo ?? ''; |
| | | const lifePayOrderType = Number(router.params?.lifePayOrderType ?? ''); |
| | | |
| | | const { wxOpenId } = useUser(); |
| | | |
| | | function handePaySuccess( |
| | | orderNo: string, |
| | | lifePayOrderType: LifeRechargeConstants.LifePayOrderTypeEnum |
| | |
| | | } |
| | | } |
| | | |
| | | interface Window { |
| | | WeixinJSBridge: any |
| | | } |
| | | } |
| | | |
| | | declare namespace NodeJS { |
| | |
| | | OSS_URL: string; |
| | | TEST_OSS_URL: string; |
| | | WEMAP_KEY: string; |
| | | WXPayAppId: string; |
| | | } |
| | | } |
| | | |
| | |
| | | <img class="select-pay-type-view-item-icon" :src="IconAliPay" /> |
| | | <div class="select-pay-type-view-item-text">支付宝支付</div> |
| | | </div> |
| | | <div class="select-pay-type-view-item" v-if="showWeixinPay" @click="handleWeixinPay"> |
| | | <div class="select-pay-type-view-item" v-if="showWeixinPay" @click="handleWeixinPayByJsApi"> |
| | | <img class="select-pay-type-view-item-icon" :src="IconWeixin" /> |
| | | <div class="select-pay-type-view-item-text">微信支付</div> |
| | | </div> |
| | |
| | | useLifeRechargeContext, |
| | | SetLifePayOrderPayTypeInput, |
| | | LifeRechargeConstants, |
| | | GetPayOrderForJsAPIInput, |
| | | } from '@life-payment/core-vue'; |
| | | import { useQuery } from '@tanstack/vue-query'; |
| | | |
| | |
| | | lifePayOrderType?: LifeRechargeConstants.LifePayOrderTypeEnum; |
| | | showAliPay?: boolean; |
| | | showWeixinPay?: boolean; |
| | | openId?: string; |
| | | isInWeChat?: boolean; |
| | | isH5?: boolean; |
| | | appId?: string; |
| | | }; |
| | | |
| | | const props = withDefaults(defineProps<Props>(), { |
| | |
| | | orderNo: string, |
| | | lifePayOrderType: LifeRechargeConstants.LifePayOrderTypeEnum |
| | | ): void; |
| | | (e: 'payOrderForJsAPISuccess'): void; |
| | | }>(); |
| | | |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | |
| | | } |
| | | |
| | | async function handleWeixinPay() { |
| | | if (props.isH5) { |
| | | if (props.isInWeChat) { |
| | | handleWeixinPayByJsApi(); |
| | | } else { |
| | | try { |
| | | let res = await setLifePayOrderPayType(blLifeRecharge.constants.LifePayTypeEnum.WxPay); |
| | | if (res) { |
| | | location.href = res; |
| | | } |
| | | } catch (error) {} |
| | | } |
| | | } |
| | | } |
| | | |
| | | async function handleWeixinPayByJsApi() { |
| | | try { |
| | | let res = await setLifePayOrderPayType(blLifeRecharge.constants.LifePayTypeEnum.WxPay); |
| | | if (res) { |
| | | location.href = res; |
| | | let params: GetPayOrderForJsAPIInput = { |
| | | orderNo: props.orderNo, |
| | | lifePayType: blLifeRecharge.constants.LifePayTypeEnum.WxPay, |
| | | openId: props.openId, |
| | | attach: Date.now().toString(), |
| | | }; |
| | | let res = await blLifeRecharge.services.getPayOrderForJsAPI(params); |
| | | //@ts-ignore |
| | | if (res && WeixinJSBridge) { |
| | | //@ts-ignore |
| | | WeixinJSBridge.invoke( |
| | | 'getBrandWCPayRequest', |
| | | { |
| | | appId: props.appId, //公众号ID,由商户传入 |
| | | timeStamp: res.timestamp, //时间戳,自1970年以来的秒数 |
| | | nonceStr: res.nonceStr, //随机串 |
| | | package: res.package, |
| | | signType: res.signType, //微信签名方式: |
| | | paySign: res.paySign, //微信签名 |
| | | }, |
| | | function (res) { |
| | | if (res.err_msg == 'get_brand_wcpay_request:ok') { |
| | | // 使用以上方式判断前端返回,微信团队郑重提示: |
| | | //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠,商户需进一步调用后端查单确认支付结果。 |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | } catch (error) {} |
| | | } |
| | |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** 获取生活缴费用户身份会话信息 GET /api/Account/GetLifePayWxIndentity */ |
| | | async getLifePayWxIndentity( |
| | | // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) |
| | | params: APIgetLifePayWxIndentityParams, |
| | | options?: RequestConfig |
| | | ) { |
| | | return this.request<WxMiniAppIndentityInfo>('/api/Account/GetLifePayWxIndentity', { |
| | | method: 'GET', |
| | | params: { |
| | | ...params, |
| | | }, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | |
| | | /** 获取微信支付的JSAPI POST /api/LifePay/GetPayOrderForJsAPI */ |
| | | async getPayOrderForJsAPI(body: GetPayOrderForJsAPIInput, options?: RequestConfig) { |
| | | return this.request<ModelPaymentMiniPay>('/api/LifePay/GetPayOrderForJsAPI', { |
| | | method: 'POST', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | }, |
| | | data: body, |
| | | ...(options || {}), |
| | | }); |
| | | } |
| | | } |
| | | |
| | | export interface PhoneMesssageCodeLoginInput { |
| | |
| | | cityParentId?: string; |
| | | ciytId?: string; |
| | | } |
| | | export interface APIgetLifePayWxIndentityParams { |
| | | /** 用户登录凭证 */ |
| | | code?: string; |
| | | } |
| | | |
| | | export interface WxMiniAppIndentityInfo { |
| | | /** 会话密钥 */ |
| | | sessionKey?: string; |
| | | /** 小程序OpenId */ |
| | | openId?: string; |
| | | /** 用户名(该值为空则需手机授权登录,不为空则已有该小程序用户) */ |
| | | userName?: string; |
| | | unionId?: string; |
| | | } |
| | | |
| | | export interface GetPayOrderForJsAPIInput { |
| | | orderNo: string; |
| | | lifePayType?: LifeRechargeConstants.LifePayTypeEnum; |
| | | openId?: string; |
| | | attach?: string; |
| | | } |
| | | |
| | | export interface ModelPaymentMiniPay { |
| | | nonceStr?: string; |
| | | package?: string; |
| | | signType?: string; |
| | | paySign?: string; |
| | | timestamp?: string; |
| | | timeExpire?: string; |
| | | message?: string; |
| | | } |