pageHead.vue 12 KB

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