wjx 1 anno fa
parent
commit
8941e75541
3 ha cambiato i file con 22 aggiunte e 3 eliminazioni
  1. 9 1
      src/App.tsx
  2. 13 0
      src/api/index.ts
  3. 0 2
      src/pages/payPop/index.tsx

+ 9 - 1
src/App.tsx

@@ -1,7 +1,7 @@
 import { useEffect, useMemo, useState } from 'react'
 import './App.less'
 import LoginPop from './pages/loginPop'
-import { getInitAppletApi, tokenExpireTimeCheckApi, weChatLoginApi } from './api'
+import { getInitAppletApi, setVisitLogPushApi, tokenExpireTimeCheckApi, weChatLoginApi } from './api'
 import { useAjax } from './hooks/useAjax'
 import { removeGameId, removeToken, setGameId, setToken } from './utils/auth'
 import { Spin, App as AntdApp, Result } from 'antd'
@@ -24,6 +24,7 @@ function App() {
 	const searchParams = new URLSearchParams(new URL(url).search);
 	const gameId = searchParams.get('game_id')
 	const isSw = searchParams.get('isSw')
+	const vt = searchParams.get('vt')
 	const { state, dispatch, getDetails } = useConfig()
 	const { typeSwitch, token } = state
 	// const [isInit, setIsInit] = useState<boolean>(false)
@@ -33,6 +34,7 @@ function App() {
 
 	const getInitApplet = useAjax(() => getInitAppletApi())
 	const weChatLogin = useAjax((params) => weChatLoginApi(params))
+	const setVisitLogPush = useAjax((params) => setVisitLogPushApi(params))
 	const tokenExpireTimeCheck = useAjax(() => tokenExpireTimeCheckApi())
 	/**************************************/
 
@@ -77,6 +79,12 @@ function App() {
 		}
 	}, [gameId])
 
+	useEffect(() => {
+		if (vt === '1' && gameId) {
+			setVisitLogPush.run({ url: window.location.href })
+		}
+	}, [vt, gameId])
+
 	// 监听token 获取用户信息
 	useEffect(() => {
 		if (token) {

+ 13 - 0
src/api/index.ts

@@ -1,6 +1,19 @@
 import request from "../utils/request";
 
 
+/**
+ * 渠道打开调用
+ * @param data 
+ * @returns 
+ */
+export async function setVisitLogPushApi(data: { url: string }) {
+    return request({
+        url: "/api/visit/log/push",
+        method: 'POST',
+        data
+    })
+}
+
 /**
  * 初始化接口
  * @returns 

+ 0 - 2
src/pages/payPop/index.tsx

@@ -64,8 +64,6 @@ const PayPop: React.FC<Props> = ({ open, data, onClose, onChange, isVer }) => {
         })
     }
 
-console.log(data)
-
     return <>
         {payPostReady.loading && <LoadingPop />}