fanzhen1227

This commit is contained in:
fanzhen123
2019-12-27 11:55:33 +08:00
parent 3218f04277
commit 1615011375
7 changed files with 116 additions and 72 deletions

View File

@@ -24,11 +24,15 @@
<div class="dsearch">
<!-- <img :src="imageUrl.search" alt srcset /> -->
<!-- 未登录 -->
<div class="div1" v-if="!userLogin" @click="loginWindow()">登录</div>
<div
class="div1"
v-if="!$store.state.ipLogin&&!$store.state.normalLogin"
@click="loginWindow()"
>登录</div>
<!-- 登陆成功后显示 -->
<div
:class="{loginAfter:true,loginAfters:fontsF}"
v-if="userLogin"
v-if="$store.state.ipLogin||$store.state.normalLogin"
@mouseenter="userLoginC()"
@mouseleave="userLoginC()"
>
@@ -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', {

View File

@@ -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({

View File

@@ -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 {

View File

@@ -5,6 +5,10 @@ Vue.use(Vuex)
export default new Vuex.Store({
state: {
// ip登陆状态
ipLogin: false,
// 平常登录状态
normalLogin: false,
// 定义一个窗口状态(新增指标)
insertWindowState: false,
// 定义一个筛选窗口状态

View File

@@ -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

View File

@@ -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
}
}
}
</script>

View File

@@ -5,7 +5,7 @@
<div class="cont">
<!-- 全局搜索 -->
<search></search>
<div class="cont_content" v-if="cont_basic.length>0">
<div class="cont_content">
<div class="header">
<div class="left">个人中心</div>
<div class="right">
@@ -25,7 +25,7 @@
<div class="right">
<div class="right_title">
<div class="left">{{staticSelect}}</div>
<div class="right" v-if="staticSelect==='我的收藏'&&collect">
<div class="right" v-if="staticSelect==='我的收藏'&&collect.length!==0">
<input type="text" placeholder="请输入搜索内容" v-model="searchCollect" />
<div @click="getCollectData(1)">搜索</div>
</div>
@@ -50,7 +50,7 @@
</div>
<!-- 我的收藏 -->
<div class="right_cont_collect" v-if="staticSelect==='我的收藏'">
<div class="collect_yes" v-if="collect">
<div class="collect_yes" v-if="collect.length!==0">
<div class="content">
<div class="header">
<div>名称</div>
@@ -92,10 +92,7 @@
@current-change="currentChange"
></el-pagination>
</div>
<div
class="collect_no"
v-if="!collect"
>{{!collect?collect.length!==0?'':'暂无收藏记录':'加载中...'}}</div>
<div class="collect_no" v-else>暂无收藏记录</div>
</div>
</div>
</div>
@@ -218,7 +215,7 @@ export default {
// // staticInput: false
// // }
// ],
collect: null,
collect: [],
// 我的收藏名称
collectName: '',
// 分页配置
@@ -380,7 +377,8 @@ export default {
id: item.id,
classify_id: item.classify_id,
type: item.type,
uid: item.uid
uid: item.uid,
f: item.f
}
})
}
@@ -441,13 +439,19 @@ export default {
// 跳转至查询页面
jumpSearch (listCount) {
console.log(listCount)
this.$route.push(
this.$router.push(
{
path: '/datasweb',
type: listCount.f,
defaultLeftId: listCount.classify_id
query: {
type: listCount.f,
defaultLeftId: listCount.classify_id
}
}
)
},
// 页面刷新跳转
beforeunloadEv () {
this.$router.push({ path: '/' })
}
},
// 自定义指令v-*
@@ -465,6 +469,7 @@ export default {
// 计算字符串
computedStr () {
return (str) => {
console.log(str, 'str10123')
let Strs = ''
str.length <= 62 ? (Strs = str) : (Strs = str.slice(0, 61) + '...')
return Strs
@@ -473,6 +478,7 @@ export default {
},
mounted () {
this.getPersonalCenter(1)
window.onbeforeunload = this.beforeunloadEv()
}
}