pageHead.vue 8.3 KB

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