123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 |
- <template>
- <header>
- <nav class="headerNav">
- <div class="inner">
- <div class="left">
- <span>中农兴业网团</span>
- <span>旗下网站:<span>农业百强网站(政府类30强)</span></span>
- </div>
- <div class="right">
- <div class="menu">
- <button class="reg" @click="goTopic">
- <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/head/topicon1.png" alt="商圈">商圈
- </button>
- <button class="reg" @click="goAdvertising">
- <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/head/topicon2.png" alt="广告服务">广告服务
- </button>
- </div>
- <div class="right-top-menu">
- <button class="reg" @click="goLogin" v-show="!showToken">
- <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/head/topicon3.png" alt="登录">登录
- </button>
- <button class="reg" @click="goRegister" v-show="!showToken">
- <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 }}
- </button>
- <button class="reg" @click="goSearch">
- <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/head/searchicon.png" alt="搜索">搜索
- </button>
- </div>
- <ul class="userInfo11" v-if="isShow">
- <li @click="gotosystem">个人中心</li>
- <li @click="exit">退出</li>
- </ul>
- </div>
- </div>
- </nav>
- <div class="headerLogo">
- <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">
- <img :src="adImg.thumb" >
- </a>
- <a :href="adImg.image_url" v-else>
- <img :src="adImg.image_src">
- </a>
- </div>
- </div>
- </div>
- <el-dialog v-model="dialogTableVisible" width="800">
- <div class="tips">
- <p>
- <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/tips.png"> 提示:注册请联系管理员操作!
- </p>
- <p>联系电话:010-56019387</p>
- <p>QQ : 2909421493 、213552413</p>
- </div>
- </el-dialog>
- </header>
- </template>
- <script setup>
- //1.加载基本依赖 start ---------------------------------------->
- import { ref, watch } from 'vue'
- import { ElDialog } from 'element-plus'
- import { getToken, setToken, removeToken } from '@/store/useCookieStore'
- import { setTicket, removeTicket } from '@/store/useticketStore'
- //网站地址
- const { $webUrl, $CwebUrl, $BwebUrl} = useNuxtApp()
- //1.加载基本依赖 end ---------------------------------------->
- //1.登录逻辑 start ---------------------------------------->
- let ticket = ref('')
- let token = ref('')
- let route = useRoute()
- ticket.value = route.query.ticket
- token.value = route.query.admintoken
- if (ticket.value) {
- setTicket(ticket.value)
- }
- if (token.value) {
- setToken(token.value)
- }
- definePageMeta({
- middleware: 'auth'
- });
- //搜索框
- let keyword = useState('keyword', () => '')
- //用户名
- let username = useState('username', () => '用户中心')
- //是否删除
- let isDel = useState('isDel', () => 1)
- //是否显示用户中心
- let isShow = useState('isShow', () => false)
- let token1 = useState("token1", () => '')
- let showToken = useState("showToken", () => '')
- token1.value = getToken()
- //检测登录状态
- let tokenStatus = ref('');
- tokenStatus.value = getToken()
- if(tokenStatus.value == undefined){
- console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- console.log('错误:未获取到用户token,如果在本地测试请忽略!');
- console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- }else{
- console.log(tokenStatus.value);
- }
- //点击登录按钮
- let goLogin = () => {
- //开启线上登录模式 start---------------------------------------->
- isDel.value = 0
- token1.value = getToken()
- window.open($BwebUrl + "/auth/login.php?backurl=" + $CwebUrl, '_blank');
- //开启线上登录模式 end---------------------------------------->
- //开启本地登录模式 start---------------------------------------->
- // window.location.href = $BwebUrl + "/auth/login.php?backurl=" + $CwebUrl;
- //"http://adminpre.bjzxtw.org.cn/auth/login.php?backurl=http://nwpre.bjzxtw.org.cn";
- //开启本地登录模式 end---------------------------------------->
- }
- let dialogTableVisible = ref(false)
- //点击注册按钮
- let goRegister = () => {
- dialogTableVisible.value = true
- }
- //点击用户中心
- let userCenter = () => {
- if(isShow.value){
- isShow.value = false
- return
- }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();
- //2.登录逻辑 end ---------------------------------------->
- //3.跳转菜单逻辑 start ---------------------------------------->
- let gotosystem = () => {
- let url = $BwebUrl + '/#/login?userurl=' + $CwebUrl;
- //window.location.href = url;
- window.open(url, '_blank');
- }
- //点击退出按钮
- let exit = () => {
- window.location.href = $CwebUrl;
- isDel.value = 1
- token1.value = getToken()
- let url = $BwebUrl + '/auth/logout.php?backurl=' + $CwebUrl + '&admintoken=' + token1;
- window.location.href = url;
- removeToken()
- removeTicket()
- }
- //点击返回首页
- let backHome = () => {
- window.location.href = $CwebUrl;
- }
- //点击搜索按钮
- let goSearch = () => {
- const route = `/search/search?keyword=${keyword.value}`;
- window.location.href = route;
- }
- // 点击广告服务
- let goAdvertising = () => {
- //本地启动广告服务
- //window.open('/advertising?activeName=1', '_blank');
- //线上启动
- if (getToken()) {
- window.open($CwebUrl + '/advertising?activeName=1', '_blank');
- } else {
- goLogin()
- }
- }
- //点击商圈
- let goTopic = () => {
- if (getToken()) {
- //window.open('http://nwpre.bjzxtw.org.cn/topic', '_blank');
- window.open($CwebUrl + '/topic', '_blank');
- } else {
- goLogin()
- }
- }
- //监听token状态
- watch(token1, (newval, oldval) => {
- //console.log(newval, oldval);
- showToken.value = newval
- }, {
- deep: true,
- immediate: true,
- })
- //获得网站logo
- const logo = ref("")
- const webSiteName = ref("")
- let getLogo = async () => {
- const responseStatus = await requestDataPromise('/web/getWebsiteFootInfo', {
- method: 'GET',
- query: {},
- });
- logo.value = responseStatus.data.website_head.logo;
- webSiteName.value = responseStatus.data.website_head.website_name;
- }
- getLogo();
- //3.跳转菜单逻辑 end ---------------------------------------->
- //4.获取广告 start ---------------------------------------->
- //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 ---------------------------------------->
- </script>
- <style lang="less" scoped>
- .userInfo11 {
- width: 100px;
- height: 80px;
- background-color: #fff;
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
- border-radius: 3px;
- position: absolute;
- top: 40px;
- right: 35px;
- font-size: 14px;
- z-index: 999;
- li {
- height: 40px;
- line-height: 40px;
- color: #333333;
- padding-left: 10px;
- }
- >li:hover {
- color: #028E21;
- }
- }
- .tips {
- padding: 20px 0;
- text-align: center;
- font-size: 20px;
- color: #40663B;
- font-weight: bold;
- img {
- width: 78px;
- height: 78px;
- vertical-align: middle;
- margin-right: 20px;
- p {
- line-height: 30px;
- }
- }
- p {
- line-height: 40px;
- }
- >p:first-child {
- margin-bottom: 30px;
- }
- }
- /* 页面头部 */
- header {
- width: 100%;
- height: 201px;
- font-size: 12px;
- font-family: PingFang SC-Regular;
- color: #666666;
- background: url("http://img.bjzxtw.org.cn/master/bjzxtw/public/head/headtopbg.png") repeat-x;
- }
- .headerNav {
- width: 100%;
- height: 33px;
- line-height: 33px;
- }
- .headerNav .left>span {
- margin-right: 47px;
- }
- .headerNav .right {
- display: flex;
- margin-right: 10px;
- position: relative;
- button {
- font-size: 12px;
- color: #666666;
- border: none;
- background: none;
- cursor: pointer;
- }
- .login {
- width: 36px;
- height: 19px;
- color: #fff;
- border-radius: 4px;
- background-color: #028E21;
- margin-right: 15px;
- cursor: pointer;
- }
- .menu,
- .right-top-menu {
- display: flex;
- }
- .reg {
- margin-right: 20px;
- display: flex;
- align-items: center;
- justify-content: center;
- height: 33px;
- img {
- margin-right: 5px;
- }
- }
- }
- .headerNav .right {
- float: right;
- font-size: 12px;
- span {
- margin-right: 20px;
- }
- .home,
- .collection {
- display: inline-block;
- width: 16px;
- height: 16px;
- vertical-align: -3px;
- }
- .home {
- background-image: url("http://img.bjzxtw.org.cn/master/bjzxtw/public/image/search.png");
- }
- .collection {
- background-image: url("http://img.bjzxtw.org.cn/master/bjzxtw/public/image/search.png");
- }
- .exit {
- line-height: 30px;
- }
- // .exit:hover{
- // color: #028E21;
- // }
- }
- /* // 头部logo */
- .headerLogo {
- height: 185px;
- position: relative;
- //background: url("../../public/head/topBg.png") no-repeat center;
- .titlead {
- position: absolute;
- bottom: 33px;
- right: 0;
- width: 830px;
- height: 120px;
- overflow: hidden;
- a {
- display: block;
- width: 830px;
- height: 110px;
- overflow: hidden;
- }
- img {
- width: 100%;
- }
- }
- .inner {
- position: relative;
- height: 185px;
- }
- .inner>img {
- // width: 342px;
- //height: 120px;
- margin-top: 47px;
- cursor: pointer;
- }
- /* // 搜索框部分 */
- .search {
- float: left;
- width: 440px;
- height: 40px;
- background-color: #fff;
- line-height: 40px;
- margin-left: 39px;
- margin: 71px 39px 48px;
- position: relative;
- em {
- display: inline-block;
- width: 30px;
- height: 30px;
- background: url("http://img.bjzxtw.org.cn/master/bjzxtw/public/image/search.png") no-repeat;
- position: absolute;
- top: 5px;
- left: 15px;
- }
- input {
- float: left;
- width: 351px;
- height: 40px;
- border: none;
- outline: none;
- padding-left: 65px;
- box-sizing: border-box;
- border: 1px solid #028E21;
- border-right: none;
- border-radius: 4px 0px 0px 4px;
- }
- button {
- float: right;
- width: 89px;
- height: 40px;
- background-color: #028E21;
- border-radius: 0px 4px 4px 0px;
- border: none;
- font-size: 14px;
- color: #fff;
- font-family: PingFang SC, PingFang SC;
- font-weight: 500;
- }
- }
- /* // 右侧小图标 */
- .serve {
- float: right;
- height: 60px;
- margin-top: 60px;
- margin-right: 60px;
- >li {
- float: left;
- height: 64px;
- margin-left: 48px;
- }
- >li>a {
- display: inline-block;
- height: 64px;
- }
- >li img {
- width: 29px;
- height: 29px;
- padding: 8px 14px;
- }
- >li p {
- height: 28px;
- text-align: center;
- color: #666666;
- }
- }
- }
- </style>
|