🎈 perf(优化支付):

This commit is contained in:
czm 2022-12-12 10:48:10 +08:00
parent a79ffacf95
commit 662617b5ac
5 changed files with 59 additions and 30 deletions

View File

@ -5,6 +5,7 @@ import configStore from './store'
import { shareShop } from './common/util' import { shareShop } from './common/util'
import ContextBlueTooth from '@/use/contextBlueTooth' import ContextBlueTooth from '@/use/contextBlueTooth'
import './app.scss' import './app.scss'
import { BANk_WX_APPID } from './common/constant'
const store = configStore() const store = configStore()
const App: FC = (params: { children?: React.ReactNode }) => { const App: FC = (params: { children?: React.ReactNode }) => {

View File

@ -1,4 +1,4 @@
// export const BASE_URL = CURRENT_BASE_URL export const BASE_URL = CURRENT_BASE_URL
// export const BASE_URL = `http://192.168.0.75:50001/lymarket` // export const BASE_URL = `http://192.168.0.75:50001/lymarket`
// export const BASE_URL = `http://192.168.0.89:50001/lymarket` // export const BASE_URL = `http://192.168.0.89:50001/lymarket`
// export const BASE_URL = `http://10.0.0.5:50001/lymarket` // export const BASE_URL = `http://10.0.0.5:50001/lymarket`
@ -40,6 +40,9 @@ export const CDN_UPLOAD_IMG = `${UPLOAD_CDN_URL || ''}`
// appid // appid
export const WX_APPID = 'wx68d92d7cbf0b6963' export const WX_APPID = 'wx68d92d7cbf0b6963'
// 招商银行小程序appid
export const BANk_WX_APPID = 'wx65934ee32a88d726'
// 支付码单跳转链接 // 支付码单跳转链接
export const PAY_H5_CODE_URL = CURRENT_PAY_H5_CODE_URL export const PAY_H5_CODE_URL = CURRENT_PAY_H5_CODE_URL

View File

@ -27,6 +27,29 @@ $top: 190px;
line-height: 182px; line-height: 182px;
text-align: center; text-align: center;
border-bottom: 3px dashed #daddea; border-bottom: 3px dashed #daddea;
position: relative;
&::before {
content: '';
width: 60px;
height: 60px;
background-color: #f7f7f7ff;
position: absolute;
bottom: 0;
right: 0;
border-radius: 50%;
transform: translate(50%, 50%);
}
&::after {
content: '';
width: 60px;
height: 60px;
background-color: #f7f7f7ff;
position: absolute;
bottom: 0;
left: 0;
border-radius: 50%;
transform: translate(-50%, 50%);
}
} }
.playMode { .playMode {
width: 100%; width: 100%;
@ -38,7 +61,6 @@ $top: 190px;
.payment_list { .payment_list {
background-color: #fff; background-color: #fff;
// box-shadow: 2px 2px 6px 0px rgba(0,0,0,0.16);
min-height: 300px; min-height: 300px;
border-radius: 10px; border-radius: 10px;
padding-bottom: 100px; padding-bottom: 100px;

View File

@ -180,22 +180,12 @@ const Payment = ({ show = false, onClose, orderInfo, onSubmitSuccess }: Param) =
}, [orderInfo, payInfo]) }, [orderInfo, payInfo])
// 直接微信支付事件 // 直接微信支付事件
const { pullBank, payStatus } = usePayBank()
const onBankPay = useCallback(() => {
pullBank({ merchId: payInfo.merch_id, custMerchId: payInfo.pay_no })
}, [payInfo])
const { fetchData: SubmitTradeOrderPayData } = SubmitTradeOrderPayApi() const { fetchData: SubmitTradeOrderPayData } = SubmitTradeOrderPayApi()
useEffect(() => { const bankCallBack = useCallback(async() => {
if (payStatus) { const res = await SubmitTradeOrderPayData({ pay_no: payInfo?.pay_no })
(async() => { if (res.success) { onSubmitSuccess?.() }
const res = await SubmitTradeOrderPayData() }, [payInfo])
if (res.success) { const { pullBank, payStatus } = usePayBank({ merchId: payInfo?.merch_id, custMerchId: payInfo?.pay_no, callBack: bankCallBack })
onSubmitSuccess?.()
}
})()
}
}, [payStatus])
return ( return (
<View className={styles.payment_main}> <View className={styles.payment_main}>
@ -239,7 +229,7 @@ const Payment = ({ show = false, onClose, orderInfo, onSubmitSuccess }: Param) =
onClose={() => advanceSelectData(null)} onClose={() => advanceSelectData(null)}
/> />
</View> </View>
<View className={styles.payment_list_item} onClick={onBankPay}> <View className={styles.payment_list_item} onClick={pullBank}>
<View className={styles.payment_list_item_left}> <View className={styles.payment_list_item_left}>
<View className={classnames(styles.miconfont)}><IconFont name="icon-weixin" size={70} /></View> <View className={classnames(styles.miconfont)}><IconFont name="icon-weixin" size={70} /></View>
<View className={styles.payment_list_item_left_name}> <View className={styles.payment_list_item_left_name}>

View File

@ -1,24 +1,36 @@
import { Button, View } from '@tarojs/components' import { Button, View } from '@tarojs/components'
import Taro, { useDidShow, useRouter } from '@tarojs/taro' import Taro, { useDidShow, useLoad, useRouter } from '@tarojs/taro'
import { useEffect, useState } from 'react' import { useEffect, useRef, useState } from 'react'
import { BANk_WX_APPID } from '@/common/constant'
interface Param { interface Param {
merchId: string merchId: string
custMerchId: string custMerchId: string
needCashier?: '1'|'0' needCashier?: '1'|'0'
callBack?: (val: any) => void // 从招商银行返回时的回调函数
} }
export default () => { export default (props: Param) => {
const { merchId = '', custMerchId = '', needCashier = '1', callBack } = props
const [payStatus, setPayStatus] = useState(false) const [payStatus, setPayStatus] = useState(false)
const openStatus = useRef(false)
console.log('openstatus::', openStatus)
useEffect(() => {
Taro.onAppShow((res) => { Taro.onAppShow((res) => {
if (res?.referrerInfo?.appId == 'wx65934ee32a88d726') { if (res?.referrerInfo?.appId == BANk_WX_APPID && !openStatus.current) {
console.log('onAppShow::', res)
callBack?.(res)
const tf = res?.referrerInfo?.extraData?.payStatus == 'success' const tf = res?.referrerInfo?.extraData?.payStatus == 'success'
setPayStatus(() => tf) setPayStatus(() => tf)
openStatus.current = true
} }
}) })
const pullBank = ({ merchId = '', custMerchId = '', needCashier = '1' }: Param) => { }, [])
const pullBank = () => {
console.log('merchId::', `${merchId}&&${custMerchId}`)
Taro.navigateToMiniProgram({ Taro.navigateToMiniProgram({
appId: CURRENT_PAY_Bank_APPID, // 生产环境Id【UAT测试环境appId:wx0fb358ee24237c71】 // appId: CURRENT_PAY_Bank_APPID, // 生产环境Id【UAT测试环境appId:wx0fb358ee24237c71】
// appId: 'wx0fb358ee24237c71', // 生产环境Id【UAT测试环境appId:wx0fb358ee24237c71】 appId: 'wx65934ee32a88d726', // 生产环境Id【UAT测试环境appId:wx0fb358ee24237c71】
path: 'pages/index/index', path: 'pages/index/index',
extraData: { extraData: {
merchId, // 传商户号必填此处传JE开头的商户号 merchId, // 传商户号必填此处传JE开头的商户号
@ -27,6 +39,7 @@ export default () => {
}, },
success(res) { // 打开成功的回调函数 success(res) { // 打开成功的回调函数
console.log('打开成功::', res) console.log('打开成功::', res)
openStatus.current = false
}, },
fail(res) { fail(res) {
console.log('打开失败::', res) console.log('打开失败::', res)