pageHead.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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. </div>
  20. <div class="right">
  21. <el-popover placement="top-start" :width="100" trigger="hover" algin="center">
  22. <template #reference>
  23. <span v-show="showToken">
  24. <em class="iconfont icon-gerenzhongxin"></em>
  25. {{ username }}
  26. </span>
  27. </template>
  28. <p class="exit" @click="exit">退出</p>
  29. </el-popover>
  30. <span>
  31. <em class="home"></em>
  32. 设为首页
  33. </span>
  34. <span>
  35. <em class="collection"></em>
  36. 加入收藏
  37. </span>
  38. </div>
  39. </div>
  40. </nav>
  41. <!-- 头部logo -->
  42. <div class="headerLogo">
  43. <div class="inner">
  44. <img src="../../static/images/image 36@2x.png" alt="" class="left">
  45. <div class="search">
  46. <em></em>
  47. <input type="text" placeholder="输入关键词" v-model="keyword">
  48. <button @click="goSearch">搜索</button>
  49. </div>
  50. <ul class="serve">
  51. <li>
  52. <NuxtLink to="/login">
  53. <img src="../../static/images/huiyuan 1.png" alt="">
  54. <p>会员服务</p>
  55. </NuxtLink>
  56. </li>
  57. <li>
  58. <NuxtLink to="/topic">
  59. <img src="../../static/images/huiyuan 1.png" alt="">
  60. <p>商圈</p>
  61. </NuxtLink>
  62. </li>
  63. <!-- <li>
  64. <NuxtLink target="_blank" to="/advertising">
  65. <img src="../../static/images/lingquguanggao 1.png" alt="">
  66. <p>广告服务</p>
  67. </NuxtLink>
  68. </li> -->
  69. </ul>
  70. </div>
  71. </div>
  72. </header>
  73. </template>
  74. <script setup>
  75. import { ref, onMounted, watch } from 'vue'
  76. import { ElPopover } from 'element-plus'
  77. import { getToken, setToken, removeToken } from '@/store/useCookieStore'
  78. import { setTicket, removeTicket } from '@/store/useticketStore'
  79. const nuxtApp = useNuxtApp();
  80. const axios = nuxtApp.$axios;
  81. let ticket = ref('')
  82. let token = ref('')
  83. let route = useRoute()
  84. ticket.value = route.query.ticket
  85. token.value = route.query.admintoken
  86. setTicket(ticket.value)
  87. setToken(token.value)
  88. console.log('查询参数:', ticket.value);
  89. console.log('查询参数:', token.value);
  90. definePageMeta({
  91. middleware: 'auth'
  92. });
  93. let keyword = useState('keyword', () => '')
  94. let username = useState('username', () => '')
  95. let isDel = useState('isDel', () => 1)
  96. //点击登录按钮
  97. let goLogin = () => {
  98. isDel.value = 0
  99. token1.value = getToken()
  100. window.location.href = ("http://admindev.bjzxtw.org.cn/auth/login.php?backurl=http%3a%2f%2faaa.letitgo.cn%2f")
  101. token1.value = getToken()
  102. }
  103. //点击注册按钮
  104. // let goRegister = () => {
  105. // navigateTo('http://admindev.bjzxtw.org.cn/auth/login.php')
  106. // }
  107. //点击退出按钮
  108. let exit = () => {
  109. isDel.value = 1
  110. removeToken()
  111. removeTicket()
  112. token1.value = getToken()
  113. axios.get(`http://admindev.bjzxtw.org.cn/auth/logoutapi.php?token=${token}`).then(response => {
  114. console.log(response.data.isDel);
  115. isDel.value = response.data.isDel
  116. })
  117. }
  118. //点击搜索按钮
  119. let goSearch = () => {
  120. navigateTo({
  121. path: '/primaryNavigation/newsList',
  122. query: {
  123. keyword: keyword.value
  124. }
  125. })
  126. }
  127. //点击广告服务
  128. let goAdvertising = () => {
  129. console.log(111);
  130. navigateTo('/advertising')
  131. // if (getToken()) {
  132. // navigateTo('/advertising')
  133. // } else {
  134. // window.location.href = ("http://admindev.bjzxtw.org.cn/auth/login.php?backurl=http%3a%2f%2faaa.letitgo.cn%2f")
  135. // }
  136. }
  137. //获取用户信息
  138. let getUserInfo = async () => {
  139. try {
  140. const response = await axios.get("/user/getUserInfo");
  141. console.log(response);
  142. username.value = response.data.real_name
  143. } catch (error) {
  144. console.error(error);
  145. }
  146. }
  147. let token1 = useState("token1", () => '')
  148. let showToken = useState("showToken", () => '')
  149. token1.value = getToken()
  150. watch(token1, (newval, oldval) => {
  151. console.log(newval, oldval);
  152. showToken.value = newval
  153. }, {
  154. deep: true,
  155. immediate: true,
  156. })
  157. onMounted(() => {
  158. //获取用户信息
  159. getUserInfo()
  160. })
  161. </script>
  162. <style lang="less" scoped>
  163. /* 页面头部 */
  164. header {
  165. width: 100%;
  166. height: 201px;
  167. font-size: 12px;
  168. font-family: PingFang SC-Regular;
  169. color: #666666;
  170. background: url("../../static/images/Group 1505.png") no-repeat;
  171. }
  172. .headerNav {
  173. width: 100%;
  174. height: 42px;
  175. line-height: 42px;
  176. background-color: #fff;
  177. }
  178. .headerNav .left>span {
  179. margin-right: 47px;
  180. }
  181. .headerNav .mid {
  182. float: left;
  183. margin-left: 100px;
  184. button {
  185. font-size: 12px;
  186. color: #666666;
  187. border: none;
  188. background-color: #fff;
  189. }
  190. .login {
  191. width: 36px;
  192. height: 19px;
  193. color: #fff;
  194. border-radius: 4px;
  195. background-color: #028E21;
  196. margin-right: 15px;
  197. }
  198. .reg {
  199. margin-right: 30px;
  200. }
  201. }
  202. .headerNav .right {
  203. span {
  204. margin-left: 26px;
  205. }
  206. .home,
  207. .collection {
  208. display: inline-block;
  209. width: 16px;
  210. height: 16px;
  211. vertical-align: -3px;
  212. }
  213. .home {
  214. background-image: url("../../static/images/Iconly/Light/Home.png");
  215. }
  216. .collection {
  217. background-image: url("../../static/images/Iconly/Light/Star.png");
  218. }
  219. }
  220. /* // 头部logo */
  221. .headerLogo {
  222. height: 156px;
  223. border-bottom: 3px solid #006616;
  224. .inner>img {
  225. width: 342px;
  226. height: 72px;
  227. margin-top: 51px;
  228. }
  229. /* // 搜索框部分 */
  230. .search {
  231. float: left;
  232. width: 440px;
  233. height: 40px;
  234. background-color: #fff;
  235. line-height: 40px;
  236. margin-left: 39px;
  237. margin: 71px 39px 48px;
  238. position: relative;
  239. em {
  240. display: inline-block;
  241. width: 30px;
  242. height: 30px;
  243. background: url("../../static/images/Iconly/Broken/Search.png") no-repeat;
  244. position: absolute;
  245. top: 5px;
  246. left: 15px;
  247. }
  248. input {
  249. float: left;
  250. width: 351px;
  251. height: 40px;
  252. border: none;
  253. outline: none;
  254. padding-left: 65px;
  255. box-sizing: border-box;
  256. border: 1px solid #028E21;
  257. border-right: none;
  258. border-radius: 4px 0px 0px 4px;
  259. }
  260. button {
  261. float: right;
  262. width: 89px;
  263. height: 40px;
  264. background-color: #028E21;
  265. border-radius: 0px 4px 4px 0px;
  266. border: none;
  267. font-size: 14px;
  268. color: #fff;
  269. font-family: PingFang SC, PingFang SC;
  270. font-weight: 500;
  271. }
  272. }
  273. /* // 右侧小图标 */
  274. .serve {
  275. float: right;
  276. height: 60px;
  277. margin-top: 60px;
  278. margin-right: 60px;
  279. >li {
  280. float: left;
  281. height: 64px;
  282. margin-left: 48px;
  283. }
  284. >li>a {
  285. display: inline-block;
  286. height: 64px;
  287. }
  288. >li img {
  289. width: 29px;
  290. height: 29px;
  291. padding: 8px 14px;
  292. }
  293. >li p {
  294. height: 28px;
  295. text-align: center;
  296. color: #666666;
  297. }
  298. }
  299. }
  300. </style>