123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440 |
- <template>
- <!-- 页面头部 -->
- <header>
- <!-- 顶部导航 -->
- <nav class="headerNav">
- <div class="inner">
- <div class="left">
- <span>中农兴业网团</span>
- <span>旗下网站:
- <span>农业百强网站(政府类30强)</span>
- </span>
- </div>
- <div class="mid" v-show="!showToken">
- <!-- <button class="login" @click="goLogin">登录</button>
- <NuxtLink to="/">
- <button class="reg">注册</button>
- </NuxtLink> -->
- <!-- <button class="changePwd">修改密码</button> -->
- <!-- <el-popover placement="top-start" :width="100" trigger="hover" algin="center">
- <template #reference>
- <span v-show="showToken">
- <em class="iconfont icon-gerenzhongxin"></em>
- {{ username }}
- </span>
- </template>
- <p class="exit" @click="exit">退出</p>
- </el-popover> -->
- </div>
- <div class="right">
- <div v-show="!showToken">
- <button class="login" @click="goLogin">登录</button>
- <NuxtLink to="/">
- <button class="reg" @click="goRegister">注册</button>
- </NuxtLink>
- </div>
- <el-popover placement="top-start" :width="100" trigger="hover" algin="center">
- <template #reference>
- <span v-show="showToken">
- <em class="iconfont icon-gerenzhongxin"></em>
- {{ username }}
- </span>
- </template>
- <p class="exit" @click="exit">退出</p>
- </el-popover>
- <!-- <span>
- <em class="home"></em>
- 设为首页
- </span>
- <span>
- <em class="collection"></em>
- 加入收藏
- </span> -->
- </div>
- </div>
- </nav>
- <!-- 头部logo -->
- <div class="headerLogo">
- <div class="inner">
- <img src="../../static/images/logo1.png" alt="" class="left">
- <div class="search">
- <em></em>
- <input type="text" placeholder="输入关键词" v-model="keyword">
- <button @click="goSearch">搜索</button>
- </div>
- <ul class="serve">
- <li @click="goTopic">
- <!-- <NuxtLink to="/topic" target="_blank"> -->
- <img src="../../static/images/huiyuan 1.png" alt="">
- <p>商圈</p>
- <!-- </NuxtLink> -->
- </li>
- <li @click="goAdvertising">
- <NuxtLink :to="`/advertising?activeName=${1}`" target="_blank">
- <img src="../../static/images/lingquguanggao 1.png" alt="">
- <p>广告服务</p>
- </NuxtLink>
- </li>
- </ul>
- </div>
- </div>
- <el-dialog v-model="dialogTableVisible" title="" width="800">
- <div class="tips">
- <p>
- <img src="../../static/topic/tips.png" alt="">
- 提示:注册请联系管理员操作!
- </p>
- <p>
- 联系邮箱:qgsndy@163.com
- </p>
- <p>
- 联系电话:010-80440269、010-69945235、010-56019387
- </p>
- </div>
- </el-dialog>
- </header>
- </template>
- <script setup>
- import { ref, onMounted, watch } from 'vue'
- import { ElPopover, ElDialog } from 'element-plus'
- import { getToken, setToken, removeToken } from '@/store/useCookieStore'
- import { setTicket, removeTicket } from '@/store/useticketStore'
- import { fa } from 'element-plus/es/locale/index.mjs';
- // import { navigateTo } from '@nuxtjs/composables';
- const nuxtApp = useNuxtApp();
- const axios = nuxtApp.$axios;
- 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)
- }
- console.log('查询参数:', ticket.value);
- console.log('查询参数:', token.value);
- definePageMeta({
- middleware: 'auth'
- });
- let keyword = useState('keyword', () => '')
- let username = useState('username', () => '')
- let isDel = useState('isDel', () => 1)
- //点击登录按钮
- let goLogin = () => {
- isDel.value = 0
- token1.value = getToken()
- window.location.href = ("http://admindev.bjzxtw.org.cn/#/login?backurl=http%3a%2f%2fnwdev.bjzxtw.org.cn%2f")
- token1.value = getToken()
- navigateTo.back()
- }
- let dialogTableVisible = ref(false)
- //点击注册按钮
- let goRegister = () => {
- dialogTableVisible.value = true
- // ElMessage({
- // message: '请联系管理员注册账户',
- // type: 'info',
- // plain: true,
- // })
- }
- //点击退出按钮
- let exit = () => {
- window.location.href = ('http://nwdev.bjzxtw.org.cn/')
- console.log('退出1111111111111111111111');
- isDel.value = 1
- token1.value = getToken()
- // const currentUrl = window.location.href;
- // console.log('currentUrl', currentUrl);
- // // 查找参数部分起始位置(?符号位置)
- // const index = currentUrl.indexOf('?');
- // if (index !== -1) {
- // // 截取去除参数后的URL
- // var newUrl = currentUrl.slice(0, index);
- // // 重新加载页面(赋值给location.href会触发页面刷新)
- // window.location.href = newUrl;
- // }
- axios.get(`http://admindev.bjzxtw.org.cn/auth/logoutapi.php?token=${token}`).then(response => {
- console.log("退出登录", response);
- isDel.value = response.data.isDel
- })
- // window.location.href = (`http://admindev.bjzxtw.org.cn/auth/login.php`)
- removeToken()
- removeTicket()
- }
- //点击搜索按钮
- let goSearch = () => {
- // navigateTo({
- // path: '/search/search',
- // query: {
- // keyword: keyword.value
- // }
- // })
- const route = `/search/search?keyword=${keyword.value}`;
- window.open(route, '_blank');
- }
- // 点击广告服务
- let goAdvertising = () => {
- // navigateTo('/advertising')
- if (getToken()) {
- navigateTo('/advertising')
- } else {
- goLogin()
- }
- }
- //点击商圈
- let goTopic = () => {
- // navigateTo('/topic')
- if (getToken()) {
- navigateTo('/topic')
- } else {
- goLogin()
- }
- }
- //获取用户信息
- let getUserInfo = async () => {
- try {
- const response = await axios.get("/user/getUserInfo");
- console.log(response);
- username.value = response.data.nickname
- } catch (error) {
- console.error(error);
- }
- }
- let token1 = useState("token1", () => '')
- let showToken = useState("showToken", () => '')
- token1.value = getToken()
- watch(token1, (newval, oldval) => {
- console.log(newval, oldval);
- showToken.value = newval
- }, {
- deep: true,
- immediate: true,
- })
- onMounted(() => {
- //获取用户信息
- getUserInfo()
- })
- </script>
- <style lang="less" scoped>
- .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: 40px;
- }
- >p:first-child{
- margin-bottom: 30px;
- }
- }
- /* 页面头部 */
- header {
- width: 100%;
- height: 201px;
- font-size: 12px;
- font-family: PingFang SC-Regular;
- color: #666666;
- background: url("../../static/images/Group 1505.png") no-repeat;
- }
- .headerNav {
- width: 100%;
- height: 42px;
- line-height: 42px;
- // background-color: #fff;
- }
- .headerNav .left>span {
- margin-right: 47px;
- }
- .headerNav .right,
- .headerNav .mid {
- // float: left;
- // margin-left: 100px;
- margin-right: 10px;
- button {
- font-size: 12px;
- color: #666666;
- border: none;
- background-color: #fff;
- }
- .login {
- width: 36px;
- height: 19px;
- color: #fff;
- border-radius: 4px;
- background-color: #028E21;
- margin-right: 15px;
- }
- .reg {
- margin-right: 30px;
- }
- }
- .headerNav .right {
- float: right;
- span {
- margin-left: 26px;
- }
- .home,
- .collection {
- display: inline-block;
- width: 16px;
- height: 16px;
- vertical-align: -3px;
- }
- .home {
- background-image: url("../../static/images/Iconly/Light/Home.png");
- }
- .collection {
- background-image: url("../../static/images/Iconly/Light/Star.png");
- }
- }
- /* // 头部logo */
- .headerLogo {
- height: 156px;
- border-bottom: 3px solid #006616;
- // display: flex;
- // .inner{
- // width: 1200px;
- // overflow: hidden;
- // margin: 0 auto;
- // }
- .inner>img {
- width: 342px;
- height: 72px;
- margin-top: 51px;
- }
- /* // 搜索框部分 */
- .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("../../static/images/Iconly/Broken/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>
|