pageHead.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <template>
  2. <!-- 页面头部 -->
  3. <header>
  4. <!-- 顶部导航 -->
  5. <nav class="headerNav">
  6. <div class="inner">
  7. <div class="left">
  8. <span>中农兴业网团</span>
  9. <span>旗下网站:
  10. <span>农业百强网站(政府类30强)</span>
  11. </span>
  12. </div>
  13. <div class="mid" v-show="!showToken">
  14. <!-- <button class="login" @click="goLogin">登录</button>
  15. <NuxtLink to="/">
  16. <button class="reg">注册</button>
  17. </NuxtLink> -->
  18. <!-- <button class="changePwd">修改密码</button> -->
  19. <!-- <el-popover placement="top-start" :width="100" trigger="hover" algin="center">
  20. <template #reference>
  21. <span v-show="showToken">
  22. <em class="iconfont icon-gerenzhongxin"></em>
  23. {{ username }}
  24. </span>
  25. </template>
  26. <p class="exit" @click="exit">退出</p>
  27. </el-popover> -->
  28. </div>
  29. <div class="right">
  30. <div v-show="!showToken">
  31. <button class="login" @click="goLogin">登录</button>
  32. <NuxtLink to="/">
  33. <button class="reg" @click="goRegister">注册</button>
  34. </NuxtLink>
  35. </div>
  36. <el-popover placement="top-start" :width="100" trigger="hover" algin="center">
  37. <template #reference>
  38. <span v-show="showToken">
  39. <em class="iconfont icon-gerenzhongxin"></em>
  40. {{ username }}
  41. </span>
  42. </template>
  43. <p class="exit" @click="exit">退出</p>
  44. </el-popover>
  45. <!-- <span>
  46. <em class="home"></em>
  47. 设为首页
  48. </span>
  49. <span>
  50. <em class="collection"></em>
  51. 加入收藏
  52. </span> -->
  53. </div>
  54. </div>
  55. </nav>
  56. <!-- 头部logo -->
  57. <div class="headerLogo">
  58. <div class="inner">
  59. <img src="../../static/images/logo1.png" alt="" class="left">
  60. <div class="search">
  61. <em></em>
  62. <input type="text" placeholder="输入关键词" v-model="keyword">
  63. <button @click="goSearch">搜索</button>
  64. </div>
  65. <ul class="serve">
  66. <li @click="goTopic">
  67. <!-- <NuxtLink to="/topic" target="_blank"> -->
  68. <img src="../../static/images/huiyuan 1.png" alt="">
  69. <p>商圈</p>
  70. <!-- </NuxtLink> -->
  71. </li>
  72. <li @click="goAdvertising">
  73. <NuxtLink :to="`/advertising?activeName=${1}`" target="_blank">
  74. <img src="../../static/images/lingquguanggao 1.png" alt="">
  75. <p>广告服务</p>
  76. </NuxtLink>
  77. </li>
  78. </ul>
  79. </div>
  80. </div>
  81. <el-dialog v-model="dialogTableVisible" title="" width="800">
  82. <div class="tips">
  83. <p>
  84. <img src="../../static/topic/tips.png" alt="">
  85. 提示:注册请联系管理员操作!
  86. </p>
  87. <p>
  88. 联系邮箱:qgsndy@163.com
  89. </p>
  90. <p>
  91. 联系电话:010-80440269、010-69945235、010-56019387
  92. </p>
  93. </div>
  94. </el-dialog>
  95. </header>
  96. </template>
  97. <script setup>
  98. import { ref, onMounted, watch } from 'vue'
  99. import { ElPopover, ElDialog } from 'element-plus'
  100. import { getToken, setToken, removeToken } from '@/store/useCookieStore'
  101. import { setTicket, removeTicket } from '@/store/useticketStore'
  102. import { fa } from 'element-plus/es/locale/index.mjs';
  103. // import { navigateTo } from '@nuxtjs/composables';
  104. const nuxtApp = useNuxtApp();
  105. const axios = nuxtApp.$axios;
  106. let ticket = ref('')
  107. let token = ref('')
  108. let route = useRoute()
  109. ticket.value = route.query.ticket
  110. token.value = route.query.admintoken
  111. if (ticket.value) {
  112. setTicket(ticket.value)
  113. }
  114. if (token.value) {
  115. setToken(token.value)
  116. }
  117. console.log('查询参数:', ticket.value);
  118. console.log('查询参数:', token.value);
  119. definePageMeta({
  120. middleware: 'auth'
  121. });
  122. let keyword = useState('keyword', () => '')
  123. let username = useState('username', () => '')
  124. let isDel = useState('isDel', () => 1)
  125. //点击登录按钮
  126. let goLogin = () => {
  127. isDel.value = 0
  128. token1.value = getToken()
  129. window.location.href = ("http://admindev.bjzxtw.org.cn/#/login?backurl=http%3a%2f%2fnwdev.bjzxtw.org.cn%2f")
  130. token1.value = getToken()
  131. navigateTo.back()
  132. }
  133. let dialogTableVisible = ref(false)
  134. //点击注册按钮
  135. let goRegister = () => {
  136. dialogTableVisible.value = true
  137. // ElMessage({
  138. // message: '请联系管理员注册账户',
  139. // type: 'info',
  140. // plain: true,
  141. // })
  142. }
  143. //点击退出按钮
  144. let exit = () => {
  145. window.location.href = ('http://nwdev.bjzxtw.org.cn/')
  146. console.log('退出1111111111111111111111');
  147. isDel.value = 1
  148. token1.value = getToken()
  149. // const currentUrl = window.location.href;
  150. // console.log('currentUrl', currentUrl);
  151. // // 查找参数部分起始位置(?符号位置)
  152. // const index = currentUrl.indexOf('?');
  153. // if (index !== -1) {
  154. // // 截取去除参数后的URL
  155. // var newUrl = currentUrl.slice(0, index);
  156. // // 重新加载页面(赋值给location.href会触发页面刷新)
  157. // window.location.href = newUrl;
  158. // }
  159. axios.get(`http://admindev.bjzxtw.org.cn/auth/logoutapi.php?token=${token}`).then(response => {
  160. console.log("退出登录", response);
  161. isDel.value = response.data.isDel
  162. })
  163. // window.location.href = (`http://admindev.bjzxtw.org.cn/auth/login.php`)
  164. removeToken()
  165. removeTicket()
  166. }
  167. //点击搜索按钮
  168. let goSearch = () => {
  169. // navigateTo({
  170. // path: '/search/search',
  171. // query: {
  172. // keyword: keyword.value
  173. // }
  174. // })
  175. const route = `/search/search?keyword=${keyword.value}`;
  176. window.open(route, '_blank');
  177. }
  178. // 点击广告服务
  179. let goAdvertising = () => {
  180. // navigateTo('/advertising')
  181. if (getToken()) {
  182. navigateTo('/advertising')
  183. } else {
  184. goLogin()
  185. }
  186. }
  187. //点击商圈
  188. let goTopic = () => {
  189. // navigateTo('/topic')
  190. if (getToken()) {
  191. navigateTo('/topic')
  192. } else {
  193. goLogin()
  194. }
  195. }
  196. //获取用户信息
  197. let getUserInfo = async () => {
  198. try {
  199. const response = await axios.get("/user/getUserInfo");
  200. console.log(response);
  201. username.value = response.data.nickname
  202. } catch (error) {
  203. console.error(error);
  204. }
  205. }
  206. let token1 = useState("token1", () => '')
  207. let showToken = useState("showToken", () => '')
  208. token1.value = getToken()
  209. watch(token1, (newval, oldval) => {
  210. console.log(newval, oldval);
  211. showToken.value = newval
  212. }, {
  213. deep: true,
  214. immediate: true,
  215. })
  216. onMounted(() => {
  217. //获取用户信息
  218. getUserInfo()
  219. })
  220. </script>
  221. <style lang="less" scoped>
  222. .tips{
  223. padding: 20px 0;
  224. text-align: center;
  225. font-size: 20px;
  226. color: #40663B ;
  227. font-weight: bold;
  228. img{
  229. width: 78px;
  230. height: 78px;
  231. vertical-align: middle;
  232. margin-right: 20px;
  233. }
  234. p{
  235. line-height: 40px;
  236. }
  237. >p:first-child{
  238. margin-bottom: 30px;
  239. }
  240. }
  241. /* 页面头部 */
  242. header {
  243. width: 100%;
  244. height: 201px;
  245. font-size: 12px;
  246. font-family: PingFang SC-Regular;
  247. color: #666666;
  248. background: url("../../static/images/Group 1505.png") no-repeat;
  249. }
  250. .headerNav {
  251. width: 100%;
  252. height: 42px;
  253. line-height: 42px;
  254. // background-color: #fff;
  255. }
  256. .headerNav .left>span {
  257. margin-right: 47px;
  258. }
  259. .headerNav .right,
  260. .headerNav .mid {
  261. // float: left;
  262. // margin-left: 100px;
  263. margin-right: 10px;
  264. button {
  265. font-size: 12px;
  266. color: #666666;
  267. border: none;
  268. background-color: #fff;
  269. }
  270. .login {
  271. width: 36px;
  272. height: 19px;
  273. color: #fff;
  274. border-radius: 4px;
  275. background-color: #028E21;
  276. margin-right: 15px;
  277. }
  278. .reg {
  279. margin-right: 30px;
  280. }
  281. }
  282. .headerNav .right {
  283. float: right;
  284. span {
  285. margin-left: 26px;
  286. }
  287. .home,
  288. .collection {
  289. display: inline-block;
  290. width: 16px;
  291. height: 16px;
  292. vertical-align: -3px;
  293. }
  294. .home {
  295. background-image: url("../../static/images/Iconly/Light/Home.png");
  296. }
  297. .collection {
  298. background-image: url("../../static/images/Iconly/Light/Star.png");
  299. }
  300. }
  301. /* // 头部logo */
  302. .headerLogo {
  303. height: 156px;
  304. border-bottom: 3px solid #006616;
  305. // display: flex;
  306. // .inner{
  307. // width: 1200px;
  308. // overflow: hidden;
  309. // margin: 0 auto;
  310. // }
  311. .inner>img {
  312. width: 342px;
  313. height: 72px;
  314. margin-top: 51px;
  315. }
  316. /* // 搜索框部分 */
  317. .search {
  318. float: left;
  319. width: 440px;
  320. height: 40px;
  321. background-color: #fff;
  322. line-height: 40px;
  323. margin-left: 39px;
  324. margin: 71px 39px 48px;
  325. position: relative;
  326. em {
  327. display: inline-block;
  328. width: 30px;
  329. height: 30px;
  330. background: url("../../static/images/Iconly/Broken/Search.png") no-repeat;
  331. position: absolute;
  332. top: 5px;
  333. left: 15px;
  334. }
  335. input {
  336. float: left;
  337. width: 351px;
  338. height: 40px;
  339. border: none;
  340. outline: none;
  341. padding-left: 65px;
  342. box-sizing: border-box;
  343. border: 1px solid #028E21;
  344. border-right: none;
  345. border-radius: 4px 0px 0px 4px;
  346. }
  347. button {
  348. float: right;
  349. width: 89px;
  350. height: 40px;
  351. background-color: #028E21;
  352. border-radius: 0px 4px 4px 0px;
  353. border: none;
  354. font-size: 14px;
  355. color: #fff;
  356. font-family: PingFang SC, PingFang SC;
  357. font-weight: 500;
  358. }
  359. }
  360. /* // 右侧小图标 */
  361. .serve {
  362. float: right;
  363. height: 60px;
  364. margin-top: 60px;
  365. margin-right: 60px;
  366. >li {
  367. float: left;
  368. height: 64px;
  369. margin-left: 48px;
  370. }
  371. >li>a {
  372. display: inline-block;
  373. height: 64px;
  374. }
  375. >li img {
  376. width: 29px;
  377. height: 29px;
  378. padding: 8px 14px;
  379. }
  380. >li p {
  381. height: 28px;
  382. text-align: center;
  383. color: #666666;
  384. }
  385. }
  386. }
  387. </style>