任一存 пре 2 година
родитељ
комит
f24b424cea
2 измењених фајлова са 18 додато и 1 уклоњено
  1. 14 0
      src/api.js
  2. 4 1
      src/router/index.js

+ 14 - 0
src/api.js

@@ -16,6 +16,20 @@ function _like() {
 }
 
 export default {
+  recordVisit() {
+    axios({
+      method: 'post',
+      url: `http://project.4dage.com:8036/api/visit/saveType`,
+      headers: {
+        appId: "E9A27605CEB3FFAF48F4D7B86858A03D9868419F60B5A45027FB6E6867F4EDA9",
+        "Content-Type": "application/json",
+      },
+      data: {
+        moduleType: "web",
+        type: 'visit',
+      },
+    })
+  },
   like: globalUtils.throttle(_like, 2000),
   async fetchPanoData() {
     const res = await axios({

+ 4 - 1
src/router/index.js

@@ -23,6 +23,9 @@ const routes = [
         audioNode.src = require(`@/assets/audios/${globalConfig.audioName.homeView}.mp3`)
         audioNode.play()
       }
+      if (!from.name) {
+        globalApi.recordVisit()
+      }
       next()
     }
   },
@@ -144,9 +147,9 @@ const router = new VueRouter({
   routes
 })
 
-// 强制每次都从首页进入
 router.beforeEach((to, from, next) => {
   console.log('beforeEach: ', to, from, next)
+  // 强制每次都从首页进入
   if (process.env.NODE_ENV === 'production' && !from.name && to.name !== 'HomeView' && !location.href.endsWith('autoReload=true')) {
     next('/')
   } else {