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_TEST = 'https://zxjt.test.86698.cn'
|
||||
#'https://lottery.api.86698.cn'
|
||||
# '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,11 +54,15 @@ function Home() {
|
|||
const activityCode = authStore.activityCode
|
||||
const userId = authStore.userId
|
||||
const corpId = authStore.corpId
|
||||
const tradeNo = authStore.tradeNo
|
||||
// const code = authStore.code
|
||||
authStore.clear()
|
||||
|
||||
let url = ""
|
||||
if (activityCode != "") {
|
||||
url = res.data.url + `?activityCode=${activityCode}&userId=${userId}&corpId=${corpId}`
|
||||
} else if(tradeNo != ""){
|
||||
url = res.data.url + `?code=${urlParams.get('code')}`
|
||||
}else {
|
||||
url = res.data.url
|
||||
}
|
||||
|
@ -119,16 +123,21 @@ function Home() {
|
|||
const openid = urlParams.get('openid') || urlParams.get('openId')
|
||||
const phone = urlParams.get('phone')
|
||||
const sign = urlParams.get('sign')
|
||||
//学知识专用参数
|
||||
const redirect_url = urlParams.get('redirect_url') || ""
|
||||
//裂变专用参数
|
||||
const activityCode = urlParams.get('activityCode') || ""
|
||||
const userId = urlParams.get('userId') || ""
|
||||
const corpId = urlParams.get('corpId') || ""
|
||||
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 (tid && openid && sign) {
|
||||
//初次登陆或者重新登陆
|
||||
|
@ -142,11 +151,22 @@ function Home() {
|
|||
authStore.setPhone(phone)
|
||||
authStore.setSign(sign)
|
||||
navigateAccessPage()
|
||||
} else if(tid && tradeNo){
|
||||
authStore.setTid(tid)
|
||||
authStore.setTradeNo(tradeNo)
|
||||
navigateAccessPage()
|
||||
} else {
|
||||
//微信跳回
|
||||
const code = urlParams.get('code')
|
||||
if (code) {
|
||||
const tradeNo = authStore.tradeNo
|
||||
if(tradeNo){
|
||||
const tid = authStore.tid
|
||||
authStore.setCode(code)
|
||||
navigateActivityPage(tid)
|
||||
}else{
|
||||
bindIds(code)
|
||||
}
|
||||
} else {
|
||||
recordState()
|
||||
setTips("授权参数不完整")
|
||||
|
|
|
@ -11,6 +11,8 @@ interface AuthState {
|
|||
userId:string,
|
||||
corpId:string,
|
||||
timeStamp:string,
|
||||
redirect_url:string,
|
||||
tradeNo:string,
|
||||
setClientOpenId: (clientOpenid: string) => void,
|
||||
setCode: (code: string) => void,
|
||||
setPhone: (phone: string) => void,
|
||||
|
@ -20,6 +22,8 @@ interface AuthState {
|
|||
setUserId: (userId: string) => void,
|
||||
setCorpId: (corpId: string) => void,
|
||||
setTimeStamp: (timeStamp: string) => void,
|
||||
setRedirectUrl: (redirect_url: string) => void,
|
||||
setTradeNo: (tradeNo: string) => void,
|
||||
clear: () => void
|
||||
}
|
||||
export const useAuthStore = create<AuthState>()(
|
||||
|
@ -34,6 +38,8 @@ export const useAuthStore = create<AuthState>()(
|
|||
userId: '',
|
||||
corpId: '',
|
||||
timeStamp: '',
|
||||
redirect_url: '',
|
||||
tradeNo: '',
|
||||
setClientOpenId: (clientOpenid) => {
|
||||
set({ clientOpenid })
|
||||
},
|
||||
|
@ -61,8 +67,16 @@ export const useAuthStore = create<AuthState>()(
|
|||
setTimeStamp: (timeStamp) => {
|
||||
set({ timeStamp })
|
||||
},
|
||||
setRedirectUrl: (redirect_url) => {
|
||||
set({ redirect_url })
|
||||
},
|
||||
setTradeNo: (tradeNo) => {
|
||||
set({ tradeNo })
|
||||
},
|
||||
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,
|
||||
corpId: state.corpId,
|
||||
timeStamp: state.timeStamp,
|
||||
redirect_url: state.redirect_url,
|
||||
tradeNo: state.tradeNo
|
||||
})
|
||||
}
|
||||
)
|
||||
|
|
|
@ -8,11 +8,34 @@ export interface ReqParam {
|
|||
options?: any;
|
||||
}
|
||||
|
||||
const test_customer_id = [
|
||||
2,3,674,675,676,677,690,691,695,696,697,698
|
||||
]
|
||||
|
||||
export const mRequest = async (req: ReqParam) => {
|
||||
console.log("api: ", req.url, " method: ", req.method, " body: ", req.body)
|
||||
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 ? {} : {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue