添加数据埋点,盘点接口添加设备类型字段
This commit is contained in:
parent
52e80be212
commit
49c72167ae
17
middleware/burying-point.js
Normal file
17
middleware/burying-point.js
Normal file
@ -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)
|
||||
}
|
@ -156,7 +156,7 @@ export default {
|
||||
]
|
||||
},
|
||||
router: {
|
||||
middleware: ['i18n', 'footer', 'header']
|
||||
middleware: ['i18n', 'footer', 'header', 'burying-point']
|
||||
},
|
||||
/*
|
||||
** Build configuration
|
||||
|
@ -185,7 +185,8 @@ export default {
|
||||
company: '',
|
||||
email: '',
|
||||
tel: '',
|
||||
content: ''
|
||||
content: '',
|
||||
equipment: this.$store.state.device
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -228,7 +228,8 @@ export default {
|
||||
company: '',
|
||||
email: '',
|
||||
tel: '',
|
||||
content: ''
|
||||
content: '',
|
||||
equipment: this.$store.state.device
|
||||
},
|
||||
swiperOptions: {
|
||||
slidesPerView :'auto',
|
||||
|
@ -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 ? '手机端' : '电脑端'
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user