new
This commit is contained in:
parent
84254b9ffc
commit
cf83611d02
|
@ -3,7 +3,9 @@ VITE_NODE_ENV = 'production'
|
||||||
|
|
||||||
#生产环境接口地址
|
#生产环境接口地址
|
||||||
VITE_SERVE = 'https://zxjt.86698.cn'
|
VITE_SERVE = 'https://zxjt.86698.cn'
|
||||||
|
|
||||||
|
VITE_SERVE_TEST = 'https://zxjt.test.86698.cn'
|
||||||
#'https://lottery.api.86698.cn'
|
#'https://lottery.api.86698.cn'
|
||||||
# 'http://39.98.117.3'
|
# 'http://39.98.117.3'
|
||||||
|
|
||||||
https://lsxdwx.access.86698.cn/
|
# https://lsxdwx.access.86698.cn/
|
30
README.md
30
README.md
|
@ -1,30 +1,8 @@
|
||||||
# React + TypeScript + Vite
|
# 中信银行-授权H5页
|
||||||
|
|
||||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
## 说明
|
||||||
|
|
||||||
Currently, two official plugins are available:
|
## 部署方式
|
||||||
|
|
||||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
|
|
||||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
||||||
|
|
||||||
## Expanding the ESLint configuration
|
|
||||||
|
|
||||||
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
|
|
||||||
|
|
||||||
- Configure the top-level `parserOptions` property like this:
|
|
||||||
|
|
||||||
```js
|
|
||||||
export default {
|
|
||||||
// other rules...
|
|
||||||
parserOptions: {
|
|
||||||
ecmaVersion: 'latest',
|
|
||||||
sourceType: 'module',
|
|
||||||
project: ['./tsconfig.json', './tsconfig.node.json'],
|
|
||||||
tsconfigRootDir: __dirname,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
```
|
||||||
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
|
|
||||||
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
|
|
||||||
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
|
|
|
@ -54,12 +54,16 @@ function Home() {
|
||||||
const activityCode = authStore.activityCode
|
const activityCode = authStore.activityCode
|
||||||
const userId = authStore.userId
|
const userId = authStore.userId
|
||||||
const corpId = authStore.corpId
|
const corpId = authStore.corpId
|
||||||
|
const tradeNo = authStore.tradeNo
|
||||||
|
// const code = authStore.code
|
||||||
authStore.clear()
|
authStore.clear()
|
||||||
|
|
||||||
let url = ""
|
let url = ""
|
||||||
if (activityCode != "") {
|
if (activityCode != "") {
|
||||||
url = res.data.url + `?activityCode=${activityCode}&userId=${userId}&corpId=${corpId}`
|
url = res.data.url + `?activityCode=${activityCode}&userId=${userId}&corpId=${corpId}`
|
||||||
} else {
|
} else if(tradeNo != ""){
|
||||||
|
url = res.data.url + `?code=${urlParams.get('code')}`
|
||||||
|
}else {
|
||||||
url = res.data.url
|
url = res.data.url
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,16 +123,21 @@ function Home() {
|
||||||
const openid = urlParams.get('openid') || urlParams.get('openId')
|
const openid = urlParams.get('openid') || urlParams.get('openId')
|
||||||
const phone = urlParams.get('phone')
|
const phone = urlParams.get('phone')
|
||||||
const sign = urlParams.get('sign')
|
const sign = urlParams.get('sign')
|
||||||
|
//学知识专用参数
|
||||||
|
const redirect_url = urlParams.get('redirect_url') || ""
|
||||||
//裂变专用参数
|
//裂变专用参数
|
||||||
const activityCode = urlParams.get('activityCode') || ""
|
const activityCode = urlParams.get('activityCode') || ""
|
||||||
const userId = urlParams.get('userId') || ""
|
const userId = urlParams.get('userId') || ""
|
||||||
const corpId = urlParams.get('corpId') || ""
|
const corpId = urlParams.get('corpId') || ""
|
||||||
const timestamp = urlParams.get('timestamp') || ""
|
const timestamp = urlParams.get('timestamp') || ""
|
||||||
|
const tradeNo = urlParams.get('tradeNo') || ""
|
||||||
|
|
||||||
authStore.setActivityCode(activityCode)
|
authStore.setActivityCode(activityCode)
|
||||||
authStore.setUserId(userId)
|
authStore.setUserId(userId)
|
||||||
authStore.setCorpId(corpId)
|
authStore.setCorpId(corpId)
|
||||||
authStore.setTimeStamp(timestamp)
|
authStore.setTimeStamp(timestamp)
|
||||||
|
authStore.setRedirectUrl(redirect_url)
|
||||||
|
|
||||||
|
|
||||||
if (tid && openid && sign) {
|
if (tid && openid && sign) {
|
||||||
//初次登陆或者重新登陆
|
//初次登陆或者重新登陆
|
||||||
|
@ -142,11 +151,22 @@ function Home() {
|
||||||
authStore.setPhone(phone)
|
authStore.setPhone(phone)
|
||||||
authStore.setSign(sign)
|
authStore.setSign(sign)
|
||||||
navigateAccessPage()
|
navigateAccessPage()
|
||||||
|
} else if(tid && tradeNo){
|
||||||
|
authStore.setTid(tid)
|
||||||
|
authStore.setTradeNo(tradeNo)
|
||||||
|
navigateAccessPage()
|
||||||
} else {
|
} else {
|
||||||
//微信跳回
|
//微信跳回
|
||||||
const code = urlParams.get('code')
|
const code = urlParams.get('code')
|
||||||
if (code) {
|
if (code) {
|
||||||
|
const tradeNo = authStore.tradeNo
|
||||||
|
if(tradeNo){
|
||||||
|
const tid = authStore.tid
|
||||||
|
authStore.setCode(code)
|
||||||
|
navigateActivityPage(tid)
|
||||||
|
}else{
|
||||||
bindIds(code)
|
bindIds(code)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
recordState()
|
recordState()
|
||||||
setTips("授权参数不完整")
|
setTips("授权参数不完整")
|
||||||
|
|
|
@ -11,6 +11,8 @@ interface AuthState {
|
||||||
userId:string,
|
userId:string,
|
||||||
corpId:string,
|
corpId:string,
|
||||||
timeStamp:string,
|
timeStamp:string,
|
||||||
|
redirect_url:string,
|
||||||
|
tradeNo:string,
|
||||||
setClientOpenId: (clientOpenid: string) => void,
|
setClientOpenId: (clientOpenid: string) => void,
|
||||||
setCode: (code: string) => void,
|
setCode: (code: string) => void,
|
||||||
setPhone: (phone: string) => void,
|
setPhone: (phone: string) => void,
|
||||||
|
@ -20,6 +22,8 @@ interface AuthState {
|
||||||
setUserId: (userId: string) => void,
|
setUserId: (userId: string) => void,
|
||||||
setCorpId: (corpId: string) => void,
|
setCorpId: (corpId: string) => void,
|
||||||
setTimeStamp: (timeStamp: string) => void,
|
setTimeStamp: (timeStamp: string) => void,
|
||||||
|
setRedirectUrl: (redirect_url: string) => void,
|
||||||
|
setTradeNo: (tradeNo: string) => void,
|
||||||
clear: () => void
|
clear: () => void
|
||||||
}
|
}
|
||||||
export const useAuthStore = create<AuthState>()(
|
export const useAuthStore = create<AuthState>()(
|
||||||
|
@ -34,6 +38,8 @@ export const useAuthStore = create<AuthState>()(
|
||||||
userId: '',
|
userId: '',
|
||||||
corpId: '',
|
corpId: '',
|
||||||
timeStamp: '',
|
timeStamp: '',
|
||||||
|
redirect_url: '',
|
||||||
|
tradeNo: '',
|
||||||
setClientOpenId: (clientOpenid) => {
|
setClientOpenId: (clientOpenid) => {
|
||||||
set({ clientOpenid })
|
set({ clientOpenid })
|
||||||
},
|
},
|
||||||
|
@ -61,8 +67,16 @@ export const useAuthStore = create<AuthState>()(
|
||||||
setTimeStamp: (timeStamp) => {
|
setTimeStamp: (timeStamp) => {
|
||||||
set({ timeStamp })
|
set({ timeStamp })
|
||||||
},
|
},
|
||||||
|
setRedirectUrl: (redirect_url) => {
|
||||||
|
set({ redirect_url })
|
||||||
|
},
|
||||||
|
setTradeNo: (tradeNo) => {
|
||||||
|
set({ tradeNo })
|
||||||
|
},
|
||||||
clear: () => {
|
clear: () => {
|
||||||
set({ clientOpenid: '', code:'', tid:0, phone:'', sign: '' })
|
set({ clientOpenid: '', code:'',
|
||||||
|
tid:0, phone:'', sign: '',redirect_url:'',
|
||||||
|
activityCode:'', userId:'', corpId:'', timeStamp:''})
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
|
@ -78,6 +92,8 @@ export const useAuthStore = create<AuthState>()(
|
||||||
userId: state.userId,
|
userId: state.userId,
|
||||||
corpId: state.corpId,
|
corpId: state.corpId,
|
||||||
timeStamp: state.timeStamp,
|
timeStamp: state.timeStamp,
|
||||||
|
redirect_url: state.redirect_url,
|
||||||
|
tradeNo: state.tradeNo
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -8,11 +8,34 @@ export interface ReqParam {
|
||||||
options?: any;
|
options?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const test_customer_id = [
|
||||||
|
2,3,674,675,676,677,690,691,695,696,697,698
|
||||||
|
]
|
||||||
|
|
||||||
export const mRequest = async (req: ReqParam) => {
|
export const mRequest = async (req: ReqParam) => {
|
||||||
console.log("api: ", req.url, " method: ", req.method, " body: ", req.body)
|
console.log("api: ", req.url, " method: ", req.method, " body: ", req.body)
|
||||||
const current_env = import.meta.env.VITE_NODE_ENV;
|
const current_env = import.meta.env.VITE_NODE_ENV;
|
||||||
|
let url = current_env == "production" ? import.meta.env.VITE_SERVE + req.url:req.url;
|
||||||
|
|
||||||
|
|
||||||
|
if(req.method == "GET"){
|
||||||
|
console.log(req.url)
|
||||||
|
const param = req.url.split("?")
|
||||||
|
if(param.length > 1){
|
||||||
|
const customer_id = Number(param[1].split("=")[1])
|
||||||
|
if(test_customer_id.includes(Number(customer_id))){
|
||||||
|
url = import.meta.env.VITE_SERVE_TEST + req.url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
const customer_id = req.body.customer_id
|
||||||
|
if(test_customer_id.includes(Number(customer_id))){
|
||||||
|
url = import.meta.env.VITE_SERVE_TEST + req.url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(url)
|
||||||
|
|
||||||
const url = current_env == "production" ? import.meta.env.VITE_SERVE + req.url:req.url;//req.url.replace(/^\/api/, '') : req.url;
|
|
||||||
const content_type = req.body && req.body instanceof FormData ? {} : {
|
const content_type = req.body && req.body instanceof FormData ? {} : {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue