pageHead.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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/#/login?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. // ElMessage({
  141. // message: '请联系管理员注册账户',
  142. // type: 'info',
  143. // plain: true,
  144. // })
  145. }
  146. let gotosystem=()=>{
  147. window.location.href = ("http://admindev.bjzxtw.org.cn/#/login?userurl=http://nwdev.bjzxtw.org.cn")
  148. }
  149. //点击退出按钮
  150. let exit = () => {
  151. window.location.href = ('http://nwdev.bjzxtw.org.cn/')
  152. console.log('退出1111111111111111111111');
  153. isDel.value = 1
  154. token1.value = getToken()
  155. // const currentUrl = window.location.href;
  156. // console.log('currentUrl', currentUrl);
  157. // // 查找参数部分起始位置(?符号位置)
  158. // const index = currentUrl.indexOf('?');
  159. // if (index !== -1) {
  160. // // 截取去除参数后的URL
  161. // var newUrl = currentUrl.slice(0, index);
  162. // // 重新加载页面(赋值给location.href会触发页面刷新)
  163. // window.location.href = newUrl;
  164. // }
  165. axios.get(`http://admindev.bjzxtw.org.cn/auth/logoutapi.php?token=${token}`).then(response => {
  166. console.log("退出登录", response);
  167. isDel.value = response.data.isDel
  168. })
  169. // window.location.href = (`http://admindev.bjzxtw.org.cn/auth/login.php`)
  170. removeToken()
  171. removeTicket()
  172. }
  173. let backHome = () => {
  174. // window.location.href = ('http://localhost:3000/')
  175. window.location.href = ('http://nwdev.bjzxtw.org.cn/')
  176. }
  177. //点击搜索按钮
  178. let goSearch = () => {
  179. // navigateTo({
  180. // path: '/search/search',
  181. // query: {
  182. // keyword: keyword.value
  183. // }
  184. // })
  185. const route = `/search/search?keyword=${keyword.value}`;
  186. window.open(route, '_blank');
  187. }
  188. // 点击广告服务
  189. let goAdvertising = () => {
  190. // navigateTo('/advertising')
  191. if (getToken()) {
  192. navigateTo('/advertising?activeName=${1}')
  193. } else {
  194. goLogin()
  195. }
  196. }
  197. //点击商圈
  198. let goTopic = () => {
  199. // navigateTo('/topic')
  200. if (getToken()) {
  201. navigateTo('/topic')
  202. } else {
  203. goLogin()
  204. }
  205. }
  206. //获取用户信息
  207. let getUserInfo = async () => {
  208. try {
  209. const response = await axios.get("/user/getUserInfo");
  210. console.log(response);
  211. username.value = response.data.nickname
  212. } catch (error) {
  213. console.error(error);
  214. }
  215. }
  216. let token1 = useState("token1", () => '')
  217. let showToken = useState("showToken", () => '')
  218. token1.value = getToken()
  219. watch(token1, (newval, oldval) => {
  220. console.log(newval, oldval);
  221. showToken.value = newval
  222. }, {
  223. deep: true,
  224. immediate: true,
  225. })
  226. onMounted(() => {
  227. //获取用户信息
  228. getUserInfo()
  229. })
  230. </script>
  231. <style lang="less" scoped>
  232. .tips {
  233. padding: 20px 0;
  234. text-align: center;
  235. font-size: 20px;
  236. color: #40663B;
  237. font-weight: bold;
  238. img {
  239. width: 78px;
  240. height: 78px;
  241. vertical-align: middle;
  242. margin-right: 20px;
  243. }
  244. p {
  245. line-height: 40px;
  246. }
  247. >p:first-child {
  248. margin-bottom: 30px;
  249. }
  250. }
  251. /* 页面头部 */
  252. header {
  253. width: 100%;
  254. height: 201px;
  255. font-size: 12px;
  256. font-family: PingFang SC-Regular;
  257. color: #666666;
  258. background: url("../../static/images/Group 1505.png") no-repeat;
  259. }
  260. .headerNav {
  261. width: 100%;
  262. height: 42px;
  263. line-height: 42px;
  264. // background-color: #fff;
  265. }
  266. .headerNav .left>span {
  267. margin-right: 47px;
  268. }
  269. .headerNav .right,
  270. .headerNav .mid {
  271. // float: left;
  272. // margin-left: 100px;
  273. margin-right: 10px;
  274. button {
  275. font-size: 12px;
  276. color: #666666;
  277. border: none;
  278. background-color: #fff;
  279. }
  280. .login {
  281. width: 36px;
  282. height: 19px;
  283. color: #fff;
  284. border-radius: 4px;
  285. background-color: #028E21;
  286. margin-right: 15px;
  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. }
  311. /* // 头部logo */
  312. .headerLogo {
  313. height: 156px;
  314. border-bottom: 3px solid #006616;
  315. // display: flex;
  316. // .inner{
  317. // width: 1200px;
  318. // overflow: hidden;
  319. // margin: 0 auto;
  320. // }
  321. .inner>img {
  322. width: 342px;
  323. height: 72px;
  324. margin-top: 51px;
  325. }
  326. /* // 搜索框部分 */
  327. .search {
  328. float: left;
  329. width: 440px;
  330. height: 40px;
  331. background-color: #fff;
  332. line-height: 40px;
  333. margin-left: 39px;
  334. margin: 71px 39px 48px;
  335. position: relative;
  336. em {
  337. display: inline-block;
  338. width: 30px;
  339. height: 30px;
  340. background: url("../../static/images/Iconly/Broken/Search.png") no-repeat;
  341. position: absolute;
  342. top: 5px;
  343. left: 15px;
  344. }
  345. input {
  346. float: left;
  347. width: 351px;
  348. height: 40px;
  349. border: none;
  350. outline: none;
  351. padding-left: 65px;
  352. box-sizing: border-box;
  353. border: 1px solid #028E21;
  354. border-right: none;
  355. border-radius: 4px 0px 0px 4px;
  356. }
  357. button {
  358. float: right;
  359. width: 89px;
  360. height: 40px;
  361. background-color: #028E21;
  362. border-radius: 0px 4px 4px 0px;
  363. border: none;
  364. font-size: 14px;
  365. color: #fff;
  366. font-family: PingFang SC, PingFang SC;
  367. font-weight: 500;
  368. }
  369. }
  370. /* // 右侧小图标 */
  371. .serve {
  372. float: right;
  373. height: 60px;
  374. margin-top: 60px;
  375. margin-right: 60px;
  376. >li {
  377. float: left;
  378. height: 64px;
  379. margin-left: 48px;
  380. }
  381. >li>a {
  382. display: inline-block;
  383. height: 64px;
  384. }
  385. >li img {
  386. width: 29px;
  387. height: 29px;
  388. padding: 8px 14px;
  389. }
  390. >li p {
  391. height: 28px;
  392. text-align: center;
  393. color: #666666;
  394. }
  395. }
  396. }
  397. </style>