@@ -181,6 +185,7 @@ export default {
})
// alert('验证码输入不正确请重新输入!')
} else {
+ let that = this
// 调接口判断密码是否输入正确,改变登录状态
this.$axios({
method: 'POST',
@@ -192,10 +197,6 @@ export default {
}).then(res => {
console.log(res)
// 请求接口完成注册 请求成功
- this.$alert(res.data.message, '温馨提示', {
- confirmButtonText: '确定'
- })
- // alert(res.data.message)
if (res.data.code === 200) {
this.showWinStatic = !this.showWinStatic
this.$auth.auth = this.showWinStatic
@@ -205,18 +206,26 @@ export default {
localStorage.setItem('userPwd', this.userpwd)
localStorage.setItem('token', 'Bearer ' + res.data.data.token)
localStorage.setItem('tokenB', res.data.data.token)
- setTimeout(() => {
- localStorage.clear()
- this.$router.go(0)
- }, 7200000)
- // 登录状态
- localStorage.setItem('userLogin', true)
- console.log(this.$route, '000111')
- if (this.$route.path === '/') {
- this.$router.go(0)
- } else {
- this.$router.push({ path: '/' })
- }
+ this.$alert(res.data.message, '温馨提示', {
+ confirmButtonText: '确定',
+ callback: res => {
+ console.log(10000)
+ that.userLogin = localStorage.getItem('userLogin')
+ that.userName = localStorage.getItem('username')
+ that.userPic = localStorage.getItem('pic')
+ // 登录状态
+ localStorage.setItem('userLogin', true)
+ // 普通登陆状态
+ this.$store.state.normalLogin = true
+ if (this.$route.path !== '/') {
+ this.$router.push({ path: '/' })
+ }
+ setTimeout(() => {
+ localStorage.clear()
+ this.$router.go(0)
+ }, 7200000)
+ }
+ })
}
}).catch((fail) => {
console.log(fail)
@@ -314,10 +323,44 @@ export default {
computed: {
},
mounted () {
+ // IP端
+ this.$axios({
+ method: 'GET',
+ url: 'site/check',
+ params: {}
+ }).then(res => {
+ console.log(res, 'IP段')
+ if (res.data.code === 200) {
+ this.$store.state.normalLogin = false
+ // 用户信息存本地
+ localStorage.setItem('username', res.data.data.username)
+ localStorage.setItem('pic', res.data.data.pic)
+ localStorage.setItem('userPwd', '123456')
+ localStorage.setItem('token', 'Bearer ' + res.data.data.token)
+ localStorage.setItem('tokenB', res.data.data.token)
+ setTimeout(() => {
+ localStorage.clear()
+ location.reload()
+ }, 7200000)
+ // 登录状态
+ localStorage.setItem('userLogin', false)
+ this.$auth = true
+ this.$store.state.ipLogin = true
+ } else {
+ if (this.$store.state.ipLogin) {
+ localStorage.clear()
+ this.$store.state.ipLogin = false
+ }
+ }
+ this.userLogin = localStorage.getItem('userLogin')
+ this.userName = localStorage.getItem('username')
+ this.userPic = localStorage.getItem('pic')
+ this.$store.state.normalLogin = this.userLogin
+ // 请求接口完成 请求成功
+ }).catch((fail) => {
+ console.log(fail)
+ })
let that = this
- this.userLogin = localStorage.getItem('userLogin')
- this.userName = localStorage.getItem('username')
- this.userPic = localStorage.getItem('pic')
// 监听对象的变化
/* eslint-disable */
Object.defineProperty(this.$auth, 'auth', {
diff --git a/src/main.js b/src/main.js
index 74fbe83..8063c20 100644
--- a/src/main.js
+++ b/src/main.js
@@ -82,35 +82,6 @@ axios.interceptors.response.use(data => {
// }
return data
})
-// IP端
-axios({
- method: 'GET',
- url: 'site/check',
- params: {}
-}).then(res => {
- // console.log(res, 'IP段')
- if (res.data.code === 200) {
- if (!localStorage.getItem('userLogin')) {
- history.go(0)
- }
- // 用户信息存本地
- localStorage.setItem('username', res.data.data.username)
- localStorage.setItem('pic', res.data.data.pic)
- localStorage.setItem('userPwd', '123456')
- localStorage.setItem('token', 'Bearer ' + res.data.data.token)
- localStorage.setItem('tokenB', res.data.data.token)
- setTimeout(() => {
- localStorage.clear()
- this.$router.go(0)
- }, 7200000)
- // 登录状态
- localStorage.setItem('userLogin', true)
- Vue.prototype.$auth = true
- }
- // 请求接口完成 请求成功
-}).catch((fail) => {
- console.log(fail)
-})
// 将图形验证码写入
Vue.prototype.$identify = identify.default
Vue.prototype.$axios = axios
@@ -124,6 +95,10 @@ Vue.prototype.$auth = {
Vue.use(VueAwesomeSwiper)
Vue.use(ElementUI)
+// 关闭浏览器
+window.addEventListener('beforeunload', e => {
+ window.localStorage.clear()
+})
Vue.config.productionTip = false
new Vue({
diff --git a/src/router.js b/src/router.js
index ad2f0ed..68c0837 100644
--- a/src/router.js
+++ b/src/router.js
@@ -107,17 +107,28 @@ let RouterObj = new Router({
})
RouterObj.beforeEach((to, from, next) => {
console.log(to, 'to')
+ console.log(from, 'from')
if (to.name === 'personalCenter' || to.name === 'datasweb') {
console.log(localStorage.getItem('token'), 'localStorage.getItem()')
if (!localStorage.getItem('token')) {
// alert('您没有该账号的登陆权限,请重新登录后再次操作!')
- this.$alert('您没有该账号的登陆权限,请重新登录后再次操作!', '温馨提示', {
- confirmButtonText: '确定'
+ Vue.prototype.$alert('您没有该账号的登陆权限,请重新登录后再次操作!', '温馨提示', {
+ confirmButtonText: '确定',
+ callback: res => {
+ console.log(Vue.prototype.$auth, 'Vue.prototype.$auth')
+ Vue.prototype.$auth.auth = true
+ console.log(Vue.prototype.$auth, 'Vue.prototype.$auth')
+ if (from.name !== 'index') {
+ next({
+ name: 'index',
+ params: {
+ type: 'loginTrue'
+ }
+ })
+ }
+ }
})
// 权限通过时赋值
- console.log(Vue.prototype.$auth, 'Vue.prototype.$auth')
- Vue.prototype.$auth.auth = true
- console.log(Vue.prototype.$auth, 'Vue.prototype.$auth')
// localStorage.clear()
// window.location.reload()
} else {
diff --git a/src/store.js b/src/store.js
index 5a8a6c4..985d917 100644
--- a/src/store.js
+++ b/src/store.js
@@ -5,6 +5,10 @@ Vue.use(Vuex)
export default new Vuex.Store({
state: {
+ // ip登陆状态
+ ipLogin: false,
+ // 平常登录状态
+ normalLogin: false,
// 定义一个窗口状态(新增指标)
insertWindowState: false,
// 定义一个筛选窗口状态
diff --git a/src/views/datasweb/Datasweb.vue b/src/views/datasweb/Datasweb.vue
index d20fccf..5174b1f 100644
--- a/src/views/datasweb/Datasweb.vue
+++ b/src/views/datasweb/Datasweb.vue
@@ -574,23 +574,24 @@ export default {
let that = this
switch (ind) {
case 0:
- this.cutStateSeach = 'simpleness'
this.$store.state.advancedSearchState = false
+ this.cutStateSeach = 'simpleness'
+ this.$router.go(0)
break
case 1:
- this.cutStateSeach = 'advanced'
this.$store.state.advancedSearchState = true
+ this.cutStateSeach = 'advanced'
break
case 2:
if (this.$route.query.type === 'area') {
this.cutStateSeach = 'map'
} else {
+ this.$store.state.advancedSearchState = false
// alert('地图功能对非地区数据无效!')
this.$alert('地图功能对非地区数据无效!', '温馨提示', {
confirmButtonText: '确定'
})
}
- this.$store.state.advancedSearchState = false
break
case 3:// 添加收藏
this.$store.state.addCollectState = true
@@ -634,9 +635,9 @@ export default {
case 'search':// 调接进行高级查询
// 调用接口查询高级查询的数据
console.log(this.$store.state.advanceData)
- if (this.$store.state.advanceData.length < 4) {
+ if (this.$store.state.advanceData.length < 1) {
// alert('筛选数据数据不能少于4条!')
- this.$alert('筛选数据数据不能少于4条!', '温馨提示', {
+ this.$alert('筛选数据数据不能少于1条!', '温馨提示', {
confirmButtonText: '确定'
})
return
diff --git a/src/views/index/Index.vue b/src/views/index/Index.vue
index b28dee6..4ea3de1 100644
--- a/src/views/index/Index.vue
+++ b/src/views/index/Index.vue
@@ -660,6 +660,10 @@ export default {
this.dataUpdating()
// 24小时热闻
this.hotArticle()
+ if (this.$route.params.type === 'loginTrue') {
+ console.log(this.$route.params.type, 'this.$router.query.type ')
+ this.$auth.auth = true
+ }
}
}
diff --git a/src/views/personalCenter/PersonalCenter.vue b/src/views/personalCenter/PersonalCenter.vue
index 4ca2c5e..45b8d13 100644
--- a/src/views/personalCenter/PersonalCenter.vue
+++ b/src/views/personalCenter/PersonalCenter.vue
@@ -5,7 +5,7 @@