pageHead.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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="isDel">
  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="!isDel">
  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="">
  53. <img src="../../static/images/huiyuan 1.png" alt="">
  54. <p>会员服务</p>
  55. </NuxtLink>
  56. </li>
  57. <li @click="goAdvertising">
  58. <NuxtLink target="_blank">
  59. <img src="../../static/images/lingquguanggao 1.png" alt="">
  60. <p>广告服务</p>
  61. </NuxtLink>
  62. </li>
  63. </ul>
  64. </div>
  65. </div>
  66. </header>
  67. </template>
  68. <script setup>
  69. import { ref } from 'vue'
  70. import { ElPopover } from 'element-plus'
  71. import { getToken, setToken, removeToken } from '@/store/useCookieStore'
  72. import { setTicket, removeTicket } from '@/store/useticketStore'
  73. //关键词搜索
  74. // const props = defineProps({
  75. // keyword: String
  76. // });
  77. const nuxtApp = useNuxtApp();
  78. const axios = nuxtApp.$axios;
  79. let ticket = ref('')
  80. let token = ref('')
  81. let route = useRoute()
  82. ticket.value = route.query.ticket
  83. token.value = route.query.admintoken
  84. setTicket(ticket.value)
  85. setToken(token.value)
  86. console.log('查询参数:', ticket.value);
  87. console.log('查询参数:', token.value);
  88. definePageMeta({
  89. middleware: 'auth'
  90. });
  91. let keyword = ref('')
  92. let username = ref('')
  93. let isDel = ref(1)
  94. //点击登录按钮
  95. let goLogin = () => {
  96. window.location.href = ("http://admindev.bjzxtw.org.cn/auth/login.php?backurl=http%3a%2f%2faaa.letitgo.cn%2f")
  97. axios.get("/user/getUserInfo").then(response => {
  98. console.log(response);
  99. username.value = response.data.real_name
  100. })
  101. console.log(isDel.value);
  102. isDel.value = 0
  103. console.log(isDel.value);
  104. }
  105. //点击注册按钮
  106. // let goRegister = () => {
  107. // navigateTo('http://admindev.bjzxtw.org.cn/auth/login.php')
  108. // }
  109. //点击退出按钮
  110. let exit = () => {
  111. axios.get(`http://admindev.bjzxtw.org.cn/auth/logoutapi.php?token=${token}`).then(response => {
  112. console.log(response.data.isDel);
  113. isDel.value = response.data.isDel
  114. })
  115. removeToken()
  116. removeTicket()
  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. // if (getToken()) {
  131. // navigateTo('/advertising')
  132. // } else {
  133. // window.location.href = ("http://admindev.bjzxtw.org.cn/auth/login.php?backurl=http%3a%2f%2faaa.letitgo.cn%2f")
  134. // }
  135. }
  136. </script>
  137. <style lang="less" scoped>
  138. /* 页面头部 */
  139. header {
  140. width: 100%;
  141. height: 201px;
  142. font-size: 12px;
  143. font-family: PingFang SC-Regular;
  144. color: #666666;
  145. background: url("../../static/images/Group 1505.png") no-repeat;
  146. }
  147. .headerNav {
  148. width: 100%;
  149. height: 42px;
  150. line-height: 42px;
  151. background-color: #fff;
  152. }
  153. .headerNav .left>span {
  154. margin-right: 47px;
  155. }
  156. .headerNav .mid {
  157. float: left;
  158. margin-left: 100px;
  159. button {
  160. font-size: 12px;
  161. color: #666666;
  162. border: none;
  163. background-color: #fff;
  164. }
  165. .login {
  166. width: 36px;
  167. height: 19px;
  168. color: #fff;
  169. border-radius: 4px;
  170. background-color: #028E21;
  171. margin-right: 15px;
  172. }
  173. .reg {
  174. margin-right: 30px;
  175. }
  176. }
  177. .headerNav .right {
  178. span {
  179. margin-left: 26px;
  180. }
  181. .home,
  182. .collection {
  183. display: inline-block;
  184. width: 16px;
  185. height: 16px;
  186. vertical-align: -3px;
  187. }
  188. .home {
  189. background-image: url("../../static/images/Iconly/Light/Home.png");
  190. }
  191. .collection {
  192. background-image: url("../../static/images/Iconly/Light/Star.png");
  193. }
  194. }
  195. /* // 头部logo */
  196. .headerLogo {
  197. height: 156px;
  198. border-bottom: 3px solid #006616;
  199. .inner>img {
  200. width: 342px;
  201. height: 72px;
  202. margin-top: 51px;
  203. }
  204. /* // 搜索框部分 */
  205. .search {
  206. float: left;
  207. width: 440px;
  208. height: 40px;
  209. background-color: #fff;
  210. line-height: 40px;
  211. margin-left: 39px;
  212. margin: 71px 39px 48px;
  213. position: relative;
  214. em {
  215. display: inline-block;
  216. width: 30px;
  217. height: 30px;
  218. background: url("../../static/images/Iconly/Broken/Search.png") no-repeat;
  219. position: absolute;
  220. top: 5px;
  221. left: 15px;
  222. }
  223. input {
  224. float: left;
  225. width: 351px;
  226. height: 40px;
  227. border: none;
  228. outline: none;
  229. padding-left: 65px;
  230. box-sizing: border-box;
  231. border: 1px solid #028E21;
  232. border-right: none;
  233. border-radius: 4px 0px 0px 4px;
  234. }
  235. button {
  236. float: right;
  237. width: 89px;
  238. height: 40px;
  239. background-color: #028E21;
  240. border-radius: 0px 4px 4px 0px;
  241. border: none;
  242. font-size: 14px;
  243. color: #fff;
  244. font-family: PingFang SC, PingFang SC;
  245. font-weight: 500;
  246. }
  247. }
  248. /* // 右侧小图标 */
  249. .serve {
  250. float: right;
  251. height: 60px;
  252. margin-top: 60px;
  253. margin-right: 60px;
  254. >li {
  255. float: left;
  256. height: 64px;
  257. margin-left: 48px;
  258. }
  259. >li>a {
  260. display: inline-block;
  261. height: 64px;
  262. }
  263. >li img {
  264. width: 29px;
  265. height: 29px;
  266. padding: 8px 14px;
  267. }
  268. >li p {
  269. height: 28px;
  270. text-align: center;
  271. color: #666666;
  272. }
  273. }
  274. }
  275. </style>