fix
This commit is contained in:
parent
cf83611d02
commit
9267d8cc85
|
@ -2,5 +2,6 @@ VITE_NODE_ENV = 'development'
|
|||
|
||||
#生产环境接口地址
|
||||
VITE_SERVE = 'http://127.0.0.1:8099'
|
||||
VITE_SERVE_TEST = 'https://zxjt.test.86698.cn'
|
||||
#'https://lottery.api.86698.cn'
|
||||
#'http://39.98.117.3'
|
|
@ -20,7 +20,8 @@ function Home() {
|
|||
|
||||
} catch (e: any) {
|
||||
setTips("获取活动页失败")
|
||||
console.error(e.message);
|
||||
recordError(e.message)
|
||||
// console.error(e.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +41,27 @@ function Home() {
|
|||
throw new Error(res.message);
|
||||
}
|
||||
} catch (e: any) {
|
||||
console.error(e.message);
|
||||
// console.error(e.message);
|
||||
}
|
||||
}
|
||||
|
||||
const recordError = async (str:string) => {
|
||||
try {
|
||||
const code = "error"
|
||||
const state = str
|
||||
const customer_id = authStore.tid || 0
|
||||
const customer_openid = authStore.clientOpenid || "null"
|
||||
const res = await Api.recordState({
|
||||
code: code,
|
||||
state: state,
|
||||
customer_id: customer_id,
|
||||
customer_openid: customer_openid,
|
||||
})
|
||||
if (res.code !== 200) {
|
||||
throw new Error(res.message);
|
||||
}
|
||||
} catch (e: any) {
|
||||
// console.error(e.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,6 +69,7 @@ function Home() {
|
|||
try {
|
||||
const res = await Api.getActivityPage(customer_id)
|
||||
if (res.code !== 200) {
|
||||
recordError(res.message)
|
||||
throw new Error(res.message);
|
||||
}
|
||||
|
||||
|
@ -55,11 +77,14 @@ function Home() {
|
|||
const userId = authStore.userId
|
||||
const corpId = authStore.corpId
|
||||
const tradeNo = authStore.tradeNo
|
||||
const redirectUrl = authStore.redirect_url
|
||||
// const code = authStore.code
|
||||
authStore.clear()
|
||||
|
||||
let url = ""
|
||||
if (activityCode != "") {
|
||||
if(redirectUrl != ""){
|
||||
url = redirectUrl
|
||||
}else if (activityCode != "") {
|
||||
url = res.data.url + `?activityCode=${activityCode}&userId=${userId}&corpId=${corpId}`
|
||||
} else if(tradeNo != ""){
|
||||
url = res.data.url + `?code=${urlParams.get('code')}`
|
||||
|
@ -75,7 +100,8 @@ function Home() {
|
|||
})
|
||||
}
|
||||
} catch (e: any) {
|
||||
console.error(e.message);
|
||||
recordError(e.message)
|
||||
// console.error(e.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,11 +139,31 @@ function Home() {
|
|||
setTips("授权参数失效,请再次尝试")
|
||||
}
|
||||
} catch (e: any) {
|
||||
console.error(e.message);
|
||||
recordError(e.message)
|
||||
// console.error(e.message);
|
||||
setTips("授权失败")
|
||||
}
|
||||
}
|
||||
|
||||
const parseRedirectUrl = (redirect_url:string) => {
|
||||
if(redirect_url=="")return ""
|
||||
const urlDecode = decodeURIComponent(redirect_url)
|
||||
const urlJson = JSON.parse(urlDecode)
|
||||
const paramJson = JSON.parse(urlJson.params)
|
||||
let redirectUrl = urlJson.path
|
||||
if(paramJson.length > 0){
|
||||
redirectUrl+="?"
|
||||
for (let i=0;i<paramJson.length;i++) {
|
||||
if(i != 0){
|
||||
redirectUrl += "&"
|
||||
}
|
||||
redirectUrl += `${paramJson[i]}`
|
||||
}
|
||||
}
|
||||
console.log(redirectUrl)
|
||||
return redirectUrl
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const tid = parseInt(urlParams.get('tid') || "0")
|
||||
const openid = urlParams.get('openid') || urlParams.get('openId')
|
||||
|
@ -132,12 +178,11 @@ function Home() {
|
|||
const timestamp = urlParams.get('timestamp') || ""
|
||||
const tradeNo = urlParams.get('tradeNo') || ""
|
||||
|
||||
authStore.setActivityCode(activityCode)
|
||||
authStore.setUserId(userId)
|
||||
authStore.setCorpId(corpId)
|
||||
authStore.setTimeStamp(timestamp)
|
||||
authStore.setRedirectUrl(redirect_url)
|
||||
|
||||
if(activityCode!="")authStore.setActivityCode(activityCode)
|
||||
if(userId!="")authStore.setUserId(userId)
|
||||
if(corpId!="")authStore.setCorpId(corpId)
|
||||
if(timestamp!="")authStore.setTimeStamp(timestamp)
|
||||
if(redirect_url!="")authStore.setRedirectUrl(parseRedirectUrl(redirect_url))
|
||||
|
||||
if (tid && openid && sign) {
|
||||
//初次登陆或者重新登陆
|
||||
|
@ -154,13 +199,16 @@ function Home() {
|
|||
} else if(tid && tradeNo){
|
||||
authStore.setTid(tid)
|
||||
authStore.setTradeNo(tradeNo)
|
||||
console.log("tid: ",authStore.tid)
|
||||
navigateAccessPage()
|
||||
} else {
|
||||
//微信跳回
|
||||
const code = urlParams.get('code')
|
||||
// const redirectUrl = urlParams.get('redirect_url')
|
||||
console.log("tid: ",authStore.tid)
|
||||
const tid = authStore.tid
|
||||
if (code) {
|
||||
const tradeNo = authStore.tradeNo
|
||||
if(tradeNo){
|
||||
if(tid == 783 || tid == 788 || tid ==790 || tid == 10081 || tid == 10084 || tid == 10088 || tid == 10090){
|
||||
const tid = authStore.tid
|
||||
authStore.setCode(code)
|
||||
navigateActivityPage(tid)
|
||||
|
@ -169,6 +217,7 @@ function Home() {
|
|||
}
|
||||
} else {
|
||||
recordState()
|
||||
recordError("没有获取到code")
|
||||
setTips("授权参数不完整")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ export interface ReqParam {
|
|||
}
|
||||
|
||||
const test_customer_id = [
|
||||
2,3,674,675,676,677,690,691,695,696,697,698
|
||||
2,3,674,675,676,677,690,691,695,696,697,698,699,780,781,782,783,784,785,786,787,788,789,790
|
||||
]
|
||||
|
||||
export const mRequest = async (req: ReqParam) => {
|
||||
|
|
Loading…
Reference in New Issue