yangc 8 жил өмнө
parent
commit
6b7d680227

+ 7 - 3
layouts/default.vue

@@ -23,10 +23,14 @@
     },
     computed: {
       isInFrame () {
-        if (this.$route.path === '/' || this.$route.path === '') {
-          this.$store.dispatch('userType/setUserType', {type: this.$route.query.type || 'mall'})
+        let cookies = this.$store.state.option.cookies
+        let cookieArr = cookies.split(';')
+        let cookieObj = {}
+        for (let i = 0; i < cookieArr.length; i++) {
+          let tmpArr = cookieArr[i].split('=')
+          cookieObj[tmpArr[0].trim()] = tmpArr[1].trim()
         }
-        return this.$store.state.userType.type.type.data === 'erp'
+        return cookieObj.type === 'erp'
       },
       title () {
         let path = this.$route.path

+ 9 - 3
layouts/main.vue

@@ -36,10 +36,16 @@
     },
     computed: {
       isInFrame () {
-        if (this.$route.path === '/' || this.$route.path === '') {
-          this.$store.dispatch('userType/setUserType', {type: this.$route.query.type || 'mall'})
+        let cookies = this.$store.state.option.cookies
+        let cookieArr = cookies.split(';')
+        let cookieObj = {}
+        for (let i = 0; i < cookieArr.length; i++) {
+          let tmpArr = cookieArr[i].split('=') || []
+          if (tmpArr.length === 2) {
+            cookieObj[tmpArr[0].trim()] = tmpArr[1].trim()
+          }
         }
-        return this.$store.state.userType.type.type.data === 'erp'
+        return cookieObj.type === 'erp'
       },
       title () {
         let path = this.$route.path

+ 7 - 3
layouts/shop.vue

@@ -35,10 +35,14 @@
     },
     computed: {
       isInFrame () {
-        if (this.$route.path === '/' || this.$route.path === '') {
-          this.$store.dispatch('userType/setUserType', {type: this.$route.query.type || 'mall'})
+        let cookies = this.$store.state.option.cookies
+        let cookieArr = cookies.split(';')
+        let cookieObj = {}
+        for (let i = 0; i < cookieArr.length; i++) {
+          let tmpArr = cookieArr[i].split('=')
+          cookieObj[tmpArr[0].trim()] = tmpArr[1].trim()
         }
-        return this.$store.state.userType.type.type.data === 'erp'
+        return cookieObj.type === 'erp'
       },
       title () {
         let path = this.$route.path

+ 3 - 0
server.js

@@ -21,6 +21,9 @@ if (proxyTable) {
     res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE')
     res.header('Access-Control-Allow-Headers', 'Content-Type')
     res.header('Access-Control-Allow-Credentials', 'true')
+    if (res.req.headers.referer && res.req.headers.referer.substring(res.req.headers.referer.length - 9, res.req.headers.referer.length) === '?type=erp') {
+      res.cookie('type', 'erp')
+    }
     next()
   })
   if (Array.isArray(proxyTable)) {