From 49c72167aed25038ece19a41515374a2389cf793 Mon Sep 17 00:00:00 2001 From: hejin Date: Fri, 8 Aug 2025 00:00:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=95=B0=E6=8D=AE=E5=9F=8B?= =?UTF-8?q?=E7=82=B9=EF=BC=8C=E7=9B=98=E7=82=B9=E6=8E=A5=E5=8F=A3=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=AE=BE=E5=A4=87=E7=B1=BB=E5=9E=8B=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- middleware/burying-point.js | 17 +++++++++++++++++ nuxt.config.js | 2 +- pages/inquiry.vue | 3 ++- pages/products/_id.vue | 3 ++- store/index.js | 4 ++++ 5 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 middleware/burying-point.js diff --git a/middleware/burying-point.js b/middleware/burying-point.js new file mode 100644 index 0000000..ee036e6 --- /dev/null +++ b/middleware/burying-point.js @@ -0,0 +1,17 @@ +export default async function ({ + $axios, + store, + req +}) { + let userAgent = process.server ? req.headers['user-agent'] : navigator.userAgent + let url = process.server ? req.headers['referer'] : window.location.href + const isMobile = (userAgent) => { + return /Mobile|Android|iPhone|iPad|iPod|Opera Mini|IEMobile|BlackBerry|webOS/i.test(userAgent); + } + store.commit('SET_DEVICE', isMobile(userAgent)) + let data = { + url: url, + equipment: store.state.device, + } + $axios.post('/web/pageSave',data) +} \ No newline at end of file diff --git a/nuxt.config.js b/nuxt.config.js index 6e99010..185e219 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -156,7 +156,7 @@ export default { ] }, router: { - middleware: ['i18n', 'footer', 'header'] + middleware: ['i18n', 'footer', 'header', 'burying-point'] }, /* ** Build configuration diff --git a/pages/inquiry.vue b/pages/inquiry.vue index 9415e02..0c123f3 100644 --- a/pages/inquiry.vue +++ b/pages/inquiry.vue @@ -185,7 +185,8 @@ export default { company: '', email: '', tel: '', - content: '' + content: '', + equipment: this.$store.state.device } } }, diff --git a/pages/products/_id.vue b/pages/products/_id.vue index db18826..f1f737c 100644 --- a/pages/products/_id.vue +++ b/pages/products/_id.vue @@ -228,7 +228,8 @@ export default { company: '', email: '', tel: '', - content: '' + content: '', + equipment: this.$store.state.device }, swiperOptions: { slidesPerView :'auto', diff --git a/store/index.js b/store/index.js index b041ad7..0aa205b 100644 --- a/store/index.js +++ b/store/index.js @@ -11,6 +11,7 @@ export const state = () => ({ menuTree: [], footerInfo: {}, footerPordCategory: [], + device: '' }) export const mutations = { @@ -44,6 +45,9 @@ export const mutations = { } fn(tree) state.menuTree = [...state.menuTree, ...tree] + }, + SET_DEVICE (state, isMob) { + state.device = isMob ? '手机端' : '电脑端' } }