|
@@ -3,7 +3,9 @@
|
|
|
<nav class="headerNav">
|
|
|
<div class="inner">
|
|
|
<div class="left">
|
|
|
- <span>中农兴业网团</span>
|
|
|
+ <span>
|
|
|
+ <a href="http://znxyw.org.cn/" target="_blank">中农兴业网团</a>
|
|
|
+ </span>
|
|
|
<span>旗下网站:<span>农业百强网站(政府类30强)</span></span>
|
|
|
</div>
|
|
|
<div class="right">
|
|
@@ -23,7 +25,8 @@
|
|
|
<img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/head/topicon4.png" alt="注册">注册
|
|
|
</button>
|
|
|
<button class="reg" @click="userCenter" v-show="showToken">
|
|
|
- <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/head/topicon3.png" alt="用户信息">{{ username }}
|
|
|
+ <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/head/topicon3.png" alt="用户信息">{{
|
|
|
+ username }}
|
|
|
</button>
|
|
|
<button class="reg" @click="goSearch">
|
|
|
<img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/head/searchicon.png" alt="搜索">搜索
|
|
@@ -40,11 +43,12 @@
|
|
|
<div class="inner">
|
|
|
<img :src="logo" :alt="webSiteName" class="left" @click="backHome">
|
|
|
<div class="titlead" v-if="adImg">
|
|
|
- <a href="http://sannongdy.org.cn/" v-if="adImg.image_url==null" target="_blank" :title="adImg.place_name">
|
|
|
- <img :src="adImg.thumb" :alt="adImg.place_name" data-tag="imgurl.ad_tag">
|
|
|
- </a>
|
|
|
- <a :href="adImg.image_url" v-else :title="adImg.ad_name">
|
|
|
- <img :src="adImg.image_src" :alt="adImg.ad_name" data-tag="imgurl.ad_tag">
|
|
|
+ <a href="http://sannongdy.org.cn/" v-if="adImg.image_url == null" target="_blank"
|
|
|
+ :title="adImg.introduce">
|
|
|
+ <img :src="adImg.thumb" :alt="adImg.introduce" data-tag="imgurl.ad_tag" :id="adImg.ad_tag">
|
|
|
+ </a>
|
|
|
+ <a :href="adImg.image_url" v-else :title="adImg.introduce">
|
|
|
+ <img :src="adImg.image_src" :alt="adImg.introduce" data-tag="imgurl.ad_tag" :id="adImg.ad_tag">
|
|
|
</a>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -68,7 +72,7 @@ import { ElDialog } from 'element-plus'
|
|
|
import { getToken, setToken, removeToken } from '@/store/useCookieStore'
|
|
|
import { setTicket, removeTicket } from '@/store/useticketStore'
|
|
|
//网站地址
|
|
|
-const { $webUrl, $CwebUrl, $BwebUrl} = useNuxtApp()
|
|
|
+const { $webUrl, $CwebUrl, $BwebUrl, $LoginWebUrl } = useNuxtApp()
|
|
|
//1.加载基本依赖 end ---------------------------------------->
|
|
|
|
|
|
//1.登录逻辑 start ---------------------------------------->
|
|
@@ -101,14 +105,15 @@ let token1 = useState("token1", () => '')
|
|
|
let showToken = useState("showToken", () => '')
|
|
|
token1.value = getToken()
|
|
|
|
|
|
+
|
|
|
//检测登录状态
|
|
|
let tokenStatus = ref('');
|
|
|
tokenStatus.value = getToken()
|
|
|
-if(tokenStatus.value == undefined){
|
|
|
+if (tokenStatus.value == undefined) {
|
|
|
console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
|
|
|
console.log('错误:未获取到用户token,如果在本地测试请忽略!');
|
|
|
console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
|
|
|
-}else{
|
|
|
+} else {
|
|
|
console.log(tokenStatus.value);
|
|
|
}
|
|
|
|
|
@@ -117,7 +122,11 @@ let goLogin = () => {
|
|
|
//开启线上登录模式 start---------------------------------------->
|
|
|
isDel.value = 0
|
|
|
token1.value = getToken()
|
|
|
+
|
|
|
+ //王鹏
|
|
|
window.open($BwebUrl + "/auth/login.php?backurl=" + $CwebUrl, '_blank');
|
|
|
+ //刘佳伟
|
|
|
+ // window.open($LoginWebUrl + "/api/goLogin?backurl=" + $CwebUrl, '_blank');
|
|
|
//开启线上登录模式 end---------------------------------------->
|
|
|
|
|
|
//开启本地登录模式 start---------------------------------------->
|
|
@@ -134,54 +143,29 @@ let goRegister = () => {
|
|
|
|
|
|
//点击用户中心
|
|
|
let userCenter = () => {
|
|
|
- if(isShow.value){
|
|
|
+ if (isShow.value) {
|
|
|
isShow.value = false
|
|
|
return
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
isShow.value = true
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//获取用户登录信息
|
|
|
-// let getUserInfo = async () => {
|
|
|
-// const responseStatus = await requestDataPromise('/user/getUserInfo', {
|
|
|
-// method: 'GET',
|
|
|
-// query: {},
|
|
|
-// });
|
|
|
-// //console.log('用户信息:', responseStatus);
|
|
|
-// //如果能拿到信息,就赋值给username
|
|
|
-// if(responseStatus.code==200){
|
|
|
-// username.value = responseStatus.data.nickname
|
|
|
-// }
|
|
|
-// }
|
|
|
-// getUserInfo();
|
|
|
-
|
|
|
-//获取登录状态
|
|
|
-// let getLoginStatus = async () => {
|
|
|
-// //let url = $BwebUrl + '/auth/loginstatus.php' //王鹏
|
|
|
-// let url = $webUrl + '/api/loginStatus' //刘佳伟
|
|
|
-// const responseStatus = await requestDataWebUrl( url, {
|
|
|
-// method: 'GET',
|
|
|
-// query: {
|
|
|
-// 'token': tokenStatus
|
|
|
-// },
|
|
|
-// });
|
|
|
-// console.log('登录状态', responseStatus);
|
|
|
-// if(responseStatus.data.code == 200){
|
|
|
-// if(responseStatus.data.data.islogin == true){
|
|
|
-// showToken.value = true
|
|
|
-// }else{
|
|
|
-// showToken.value = false
|
|
|
-// exit()
|
|
|
-// }
|
|
|
-// }else if(responseStatus.data.code == 0){
|
|
|
-// //退出登录
|
|
|
-// exit();
|
|
|
-// }
|
|
|
-// }
|
|
|
-// getLoginStatus();
|
|
|
-
|
|
|
+// 添加点击事件处理函数
|
|
|
+const handleClickOutside = (event) => {
|
|
|
+ // 获取用户信息菜单元素
|
|
|
+ const userInfoMenu = document.querySelector('.userInfo11');
|
|
|
+ // 获取用户按钮元素
|
|
|
+ const userButton = document.querySelector('.reg img[alt="用户信息"]')?.parentElement;
|
|
|
+
|
|
|
+ // 如果点击的不是菜单本身且不是用户按钮,则隐藏菜单
|
|
|
+ if (userInfoMenu &&
|
|
|
+ !userInfoMenu.contains(event.target) &&
|
|
|
+ !userButton?.contains(event.target)) {
|
|
|
+ isShow.value = false;
|
|
|
+ }
|
|
|
+}
|
|
|
//2.登录逻辑 end ---------------------------------------->
|
|
|
|
|
|
//3.跳转菜单逻辑 start ---------------------------------------->
|
|
@@ -198,7 +182,13 @@ let exit = () => {
|
|
|
isDel.value = 1
|
|
|
token1.value = getToken()
|
|
|
|
|
|
- let url = $BwebUrl + '/auth/logout.php?backurl=' + $CwebUrl + '&admintoken=' + token1;
|
|
|
+ let tokendata = getToken()
|
|
|
+
|
|
|
+ //王鹏
|
|
|
+ let url = $BwebUrl + '/auth/logout.php?backurl=' + $CwebUrl + '&admintoken=' + tokendata;
|
|
|
+ console.log("用户退出登录======token为:", tokendata,url)
|
|
|
+ //刘佳伟
|
|
|
+ // let url = $LoginWebUrl + '/api/logout?backurl=' + $CwebUrl + '&admintoken=' + tokendata;
|
|
|
window.location.href = url;
|
|
|
removeToken()
|
|
|
removeTicket()
|
|
@@ -230,7 +220,6 @@ let goAdvertising = () => {
|
|
|
//点击商圈
|
|
|
let goTopic = () => {
|
|
|
if (getToken()) {
|
|
|
- //window.open('http://nwpre.bjzxtw.org.cn/topic', '_blank');
|
|
|
window.open($CwebUrl + '/topic', '_blank');
|
|
|
} else {
|
|
|
goLogin()
|
|
@@ -250,7 +239,7 @@ watch(token1, (newval, oldval) => {
|
|
|
const logo = ref("")
|
|
|
const webSiteName = ref("")
|
|
|
let getLogo = async () => {
|
|
|
- const responseStatus = await requestDataPromise('/web/getWebsiteHead', {
|
|
|
+ const responseStatus = await requestDataPromise('/web/getWebsiteHead', {
|
|
|
method: 'GET',
|
|
|
query: {},
|
|
|
});
|
|
@@ -262,41 +251,28 @@ getLogo();
|
|
|
|
|
|
//4.获取广告 start ---------------------------------------->
|
|
|
let adImg = ref({})
|
|
|
-//let adList = ref([]);
|
|
|
-// let adImg = ref({})
|
|
|
-// async function getAdData(){
|
|
|
-// const adData = await requestDataPromise('/web/getWebsiteAdvertisement',{method:'GET',query:{'ad_tag':'INDEDX'}});
|
|
|
-// if(adData.code == 200){
|
|
|
-// for(let item of adData.data){
|
|
|
-// if(item.ad_tag == 'INDEDX_0001'){
|
|
|
-// adImg.value = item;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }else{
|
|
|
-// console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
|
|
|
-// console.log("错误位置:设置logo旁广告")
|
|
|
-// console.log("后端错误反馈:",adData.message)
|
|
|
-// console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
|
|
|
-// }
|
|
|
-// }
|
|
|
-// getAdData();
|
|
|
//4.获取广告 end ---------------------------------------->
|
|
|
|
|
|
-
|
|
|
//5.获取登录状态 start ---------------------------------------->
|
|
|
+// 在组件卸载时移除事件监听
|
|
|
+onUnmounted(() => {
|
|
|
+ document.removeEventListener('click', handleClickOutside);
|
|
|
+})
|
|
|
+
|
|
|
onMounted(async () => {
|
|
|
-
|
|
|
+ //添加监听关闭个人中心菜单
|
|
|
+ document.addEventListener('click', handleClickOutside);
|
|
|
+
|
|
|
//从客户端获取登录状态
|
|
|
//从客户端阶段开始 持续查询登录状态
|
|
|
let getLoginStatus = async () => {
|
|
|
const { $webUrl, $CwebUrl } = useNuxtApp();
|
|
|
- //let url = $webUrl + '/api/loginStatus'
|
|
|
const queryParams = new URLSearchParams({
|
|
|
token: getToken()
|
|
|
});
|
|
|
let url = `${$webUrl}/api/loginStatus?${queryParams.toString()}`
|
|
|
-
|
|
|
- const responseStatus = await fetch( url, {
|
|
|
+
|
|
|
+ const responseStatus = await fetch(url, {
|
|
|
method: 'GET',
|
|
|
headers: {
|
|
|
'Content-Type': 'application/json',
|
|
@@ -307,12 +283,12 @@ onMounted(async () => {
|
|
|
});
|
|
|
const result = await responseStatus.json();
|
|
|
console.log(result)
|
|
|
- if(result.code == 200){
|
|
|
- if(result.data.isLogin == true){
|
|
|
+ if (result.code == 200) {
|
|
|
+ if (result.data.isLogin == true) {
|
|
|
console.log("用户已经登录!");
|
|
|
- showToken.value = true;
|
|
|
+ showToken.value = true;
|
|
|
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
console.log("用户未登录!");
|
|
|
showToken.value = false;
|
|
|
//退出登录
|
|
@@ -320,7 +296,7 @@ onMounted(async () => {
|
|
|
removeToken();
|
|
|
removeTicket();
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
console.log("用户已退出登录!");
|
|
|
//退出登录
|
|
|
isShow.value = false;
|
|
@@ -357,7 +333,7 @@ onMounted(async () => {
|
|
|
}
|
|
|
});
|
|
|
const userInfo = await userInfoResponse.json();
|
|
|
- if(userInfo.code==200){
|
|
|
+ if (userInfo.code == 200) {
|
|
|
username.value = userInfo.data.nickname
|
|
|
}
|
|
|
})
|
|
@@ -420,7 +396,7 @@ onMounted(async () => {
|
|
|
/* 页面头部 */
|
|
|
header {
|
|
|
width: 100%;
|
|
|
- height: 201px;
|
|
|
+ // height: 201px;
|
|
|
font-size: 12px;
|
|
|
font-family: PingFang SC-Regular;
|
|
|
color: #666666;
|
|
@@ -434,7 +410,10 @@ header {
|
|
|
}
|
|
|
|
|
|
.headerNav .left>span {
|
|
|
- margin-right: 47px;
|
|
|
+ margin-right: 20px;
|
|
|
+ a{
|
|
|
+ color: #666666;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
.headerNav .right {
|
|
@@ -513,34 +492,39 @@ header {
|
|
|
|
|
|
/* // 头部logo */
|
|
|
.headerLogo {
|
|
|
- height: 185px;
|
|
|
+ height: 145px;
|
|
|
position: relative;
|
|
|
+
|
|
|
//background: url("../../public/head/topBg.png") no-repeat center;
|
|
|
.titlead {
|
|
|
position: absolute;
|
|
|
- bottom: 33px;
|
|
|
+ bottom: 5px;
|
|
|
right: 0;
|
|
|
width: 830px;
|
|
|
height: 120px;
|
|
|
overflow: hidden;
|
|
|
+
|
|
|
a {
|
|
|
display: block;
|
|
|
height: 110px;
|
|
|
overflow: hidden;
|
|
|
}
|
|
|
+
|
|
|
img {
|
|
|
width: 100%;
|
|
|
height: 110px;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
.inner {
|
|
|
position: relative;
|
|
|
- height: 185px;
|
|
|
+ height: 145px;
|
|
|
}
|
|
|
+
|
|
|
.inner>img {
|
|
|
// width: 342px;
|
|
|
//height: 120px;
|
|
|
- margin-top: 31px;
|
|
|
+ margin-top: 22px;
|
|
|
cursor: pointer;
|
|
|
}
|
|
|
|