diff --git a/src/App.vue b/src/App.vue index c23c7ef..d2f5d99 100644 --- a/src/App.vue +++ b/src/App.vue @@ -32,30 +32,35 @@ export default { updated() { window.scroll(0, 0); }, - created() { - console.log("this._isMobile();") - this._isMobile(); - - // const userId = '1218763410024566784'; - // const params = { userId }; - // this.getUserId(params); - // if (sessionStorage.getItem('store')) { - // this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(sessionStorage.getItem('store')))); - // } - // window.addEventListener('beforeunload', () => { - // sessionStorage.setItem('store', JSON.stringify(this.$store.state)); - // }); + beforeCreate(){ + let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i) + let ismobile = flag ? 1 : 0 + if (ismobile == 1) { + window.location.href = "http://www.sxgreenvalley.com/green-phone" + } }, + // created() { + // console.log("this._isMobile();") + // this._isMobile(); + + // // const userId = '1218763410024566784'; + // // const params = { userId }; + // // this.getUserId(params); + // // if (sessionStorage.getItem('store')) { + // // this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(sessionStorage.getItem('store')))); + // // } + // // window.addEventListener('beforeunload', () => { + // // sessionStorage.setItem('store', JSON.stringify(this.$store.state)); + // // }); + // }, methods: { ...mapActions('user', ['getUserId']), _isMobile(){ - console.log("是否走到了_isMobile") + let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i) - // localStorage.setItem('isiphone',flag) - // localStorage.setItem('ismobile',flag?1:0) - // return flag; + console.log("======>",flag) let ismobile = flag ? 1 : 0 // 电脑