pageHead.vue 12 KB

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