|
@@ -11,8 +11,8 @@ import PwdPop from './pages/pwdPop'
|
|
|
import useConfig, { Action, State } from './models/useConfig'
|
|
|
import LoginSucc from './pages/loginSucc'
|
|
|
import React from 'react'
|
|
|
-import { getRedirectUrl, isWeChat } from './utils'
|
|
|
-
|
|
|
+import { getRedirectUrl, isOs, isWeChat, isWx } from './utils'
|
|
|
+import wllqopenImg from './assets/image/wllqopen.png'
|
|
|
|
|
|
export const DispatchContext = React.createContext<{ dispatch: React.Dispatch<Action>, state: State, getDetails: () => void } | null>(null);
|
|
|
|
|
@@ -27,6 +27,8 @@ function App() {
|
|
|
const { typeSwitch, token } = state
|
|
|
// const [isInit, setIsInit] = useState<boolean>(false)
|
|
|
const [isShowLogin, setIsShowLogin] = useState<boolean>(false)
|
|
|
+ const [isPhoneWxShow, setIsPhoneWxShow] = useState<boolean>(true)
|
|
|
+ const [isShow, setIsShow] = useState<boolean>(true)
|
|
|
|
|
|
const getInitApplet = useAjax(() => getInitAppletApi())
|
|
|
const weChatLogin = useAjax((params) => weChatLoginApi(params))
|
|
@@ -46,7 +48,7 @@ function App() {
|
|
|
dispatch({ type: 'setOrientation', params: { orientation: orientationType } })
|
|
|
}
|
|
|
handleOrientationChange()
|
|
|
- function handlePopstate () {
|
|
|
+ function handlePopstate() {
|
|
|
window.history.pushState(null, '');
|
|
|
}
|
|
|
handlePopstate()
|
|
@@ -110,6 +112,7 @@ function App() {
|
|
|
getInitApplet.run().then(res => {
|
|
|
setIsLoding(false)
|
|
|
if (res?.data) {
|
|
|
+ let h5WeChatControl = res?.data?.h5GameConfigDTO?.h5WeChatControl || 'UN_CONTROL'
|
|
|
dispatch({ type: 'setIsPut', params: { isPut: (res.data.isPut && res.data.appId) || false } })
|
|
|
document.title = (res.data?.gameName || '游戏-登录')
|
|
|
dispatch({ type: 'setInitData', params: { initData: { ...res.data, ...res.data?.h5GameConfigDTO } } })
|
|
@@ -117,6 +120,10 @@ function App() {
|
|
|
let iconLink: any = document.querySelector('link[rel="icon"]');
|
|
|
iconLink.href = res.data?.h5GameConfigDTO?.h5SignLogo
|
|
|
}
|
|
|
+ if (isWx() && ['ios', 'android'].includes(isOs()) && h5WeChatControl === 'UN_WE_CHAT') {
|
|
|
+ setIsPhoneWxShow(false)
|
|
|
+ return
|
|
|
+ }
|
|
|
if (!searchParams.get('code') && res.data.isPut && res.data.appId && isWeChat()) {
|
|
|
setIsShowLogin(false)
|
|
|
window.location.replace(`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${res.data.appId}&redirect_uri=${encodeURIComponent(location.href)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`)
|
|
@@ -151,15 +158,25 @@ function App() {
|
|
|
|
|
|
return <AntdApp>
|
|
|
<DispatchContext.Provider value={{ dispatch, state, getDetails }}>
|
|
|
- {gameId ? <>
|
|
|
+ {gameId ? isPhoneWxShow ? <>
|
|
|
{isLoding ? <div className='loaing'><Spin spinning={true} /></div> : <div style={{ width: '100%', height: '100vh' }}>
|
|
|
{token ? <LoginSucc /> : isShowLogin ? Pop : <div className='loaing'><Spin spinning={true} /></div>}
|
|
|
</div>}
|
|
|
- </> : <Result
|
|
|
- status="404"
|
|
|
- title="游戏ID为空"
|
|
|
- subTitle="请在链接上传入游戏ID"
|
|
|
- />}
|
|
|
+ </> : <div style={{ width: '100%', height: '100vh', backgroundColor: '#FFF' }} className='openLlq'>
|
|
|
+ {isShow && <div className='zz' onClick={() => { setIsShow(false) }}>
|
|
|
+ <img src={wllqopenImg} />
|
|
|
+ </div>}
|
|
|
+ <Result
|
|
|
+ status="403"
|
|
|
+ title="请用浏览器打开"
|
|
|
+ />
|
|
|
+ </div> : <div style={{ width: '100%', height: '100vh', backgroundColor: '#FFF' }}>
|
|
|
+ <Result
|
|
|
+ status="404"
|
|
|
+ title="游戏ID为空"
|
|
|
+ subTitle="请在链接上传入游戏ID"
|
|
|
+ />
|
|
|
+ </div>}
|
|
|
</DispatchContext.Provider>
|
|
|
</AntdApp>
|
|
|
}
|