pageHead.vue 13 KB

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