43278d55d4c6634df88c75a496cf0325714786d4.svn-base 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <div>
  3. <div class="box">
  4. <div class="row allAlignment center head_on_box">
  5. <p
  6. class="logo"
  7. style="font-size:.6rem;color:#E1E1DF;font-family: 'Franklin Gothic Medium'"
  8. >
  9. <i style="color:#F76649;">HX</i>669
  10. </p>
  11. <!-- <img class="log" src="../assets/st-imges/indexlogo.png" alt=""> -->
  12. <div class="row allAlignment center">
  13. <yd-button type="primary" bgcolor="rgba(0,0,0,0)" @click.native="urseInfo()">
  14. <img class="user-ion" src="../assets/st-imges/user.png" alt>
  15. </yd-button>
  16. <!-- <div v-if="nameShow" class="row allAlignment center username">
  17. {{name}}
  18. </div>-->
  19. <img
  20. style="margin-left: 0.44rem;"
  21. class="user-ion"
  22. src="../assets/st-imges/contact.png"
  23. alt
  24. >
  25. </div>
  26. </div>
  27. <div class="navtitle-box row">
  28. <div style="width:1rem;height:1rem" class="row center">
  29. <img
  30. @click="returnHome"
  31. :src="headActive=='home'?img1:img2"
  32. style="width:0.4rem;height:0.4rem;"
  33. alt
  34. >
  35. </div>
  36. <div class="head_box">
  37. <nav>
  38. <div v-for="(item,$index) in title" class="row" :key="item.id">
  39. <div class="row item-center nav-arr ">
  40. <div
  41. class="headbox"
  42. @click="activityJump($index,item.type_code)"
  43. :class="{active:headActive==item.type_code}"
  44. >{{item.type_name}}</div>
  45. <span
  46. :class="{numactive:headActive==item.type_code}"
  47. class="head_box_num row center"
  48. >{{item.matchNum>99?'1+':item.matchNum}}</span>
  49. </div>
  50. </div>
  51. </nav>
  52. </div>
  53. </div>
  54. </div>
  55. <div v-if="Lshow==true" class="login">
  56. <Login></Login>
  57. </div>
  58. <div v-else-if="rgShow==true">
  59. <register></register>
  60. </div>
  61. </div>
  62. </template>
  63. <script>
  64. import "../css/index.css";
  65. import Login from "@/pages/Login/index/StLogin";
  66. import register from "@/pages/Login/index/register";
  67. export default {
  68. name: "SportsHead",
  69. components: {
  70. Login,
  71. register
  72. },
  73. data() {
  74. return {
  75. show: false,
  76. img1: require("../assets/st-imges/home.png"),
  77. img2: require("../assets/st-imges/gengduo-1.png"),
  78. title:'',
  79. headActive: "",
  80. init: true,
  81. nameShow: false, //展示登录组件或者是名字
  82. timers: true, //定时器清理
  83. Lshow: false,
  84. rgShow: false, //隐藏注册框
  85. getIsShow:true
  86. };
  87. },
  88. methods: {
  89. //判断登录是否过期
  90. getuserData(){
  91. if(localStorage.getItem('token')){
  92. this.$http.post(this.$ports.login.getAgent,{token:localStorage.getItem('token')}).then(res=>{
  93. if(res.data.status==-4001){
  94. this.$store.dispatch('SET_TOKEN','');
  95. this.$store.dispatch('GET_ISSHOW',false);
  96. this.$dialog.toast({mes: '对不起您的登录已过期,请您重新登录', timeout: 3000});
  97. }
  98. })
  99. }
  100. },
  101. urseInfo() {
  102. if (!localStorage.getItem("token")) {
  103. this.$store.dispatch("GET_ISSHOW", true);
  104. // 设置背景禁止滚动
  105. this.$store.dispatch('SET_NOROLL',true)
  106. } else {
  107. this.$router.push("/PersonalCenter");
  108. }
  109. },
  110. // 数据封装
  111. getAjax() {
  112. //this.$store.dispatch("GETSHOW", true);
  113. this.$http.get(this.$ports.home.navTypeList).then(res => {
  114. if (res.data.status == 1) {
  115. this.title = res.data.data;
  116. this.$store.dispatch("SET_HEADTITLE", res.data.data);
  117. }
  118. });
  119. },
  120. /**
  121. * 头部导航
  122. */
  123. activityJump: function(index, code) {
  124. // 头部激活样式
  125. if(this.headActive!=code){
  126. this.headActive = code;
  127. }
  128. this.indeximg = false;
  129. this.$store.dispatch("GETACTIVITY", code); //将活动类别存入vuex里面
  130. if (this.$route.query.isTrue) return false;
  131. this.$router.replace({
  132. path: "/StRollBallpage",
  133. query: { home: 1 }
  134. });
  135. },
  136. /**
  137. * 回到首页
  138. */
  139. returnHome: function() {
  140. this.headActive='home'
  141. this.$store.dispatch("GETACTIVITY", "home");
  142. this.$router.replace({ path: "/" });
  143. }
  144. },
  145. /**
  146. *
  147. */
  148. computed: {
  149. // 获取登录注册状态
  150. loginAntReg: function() {
  151. return {
  152. isshow_code: this.$store.getters.getIsShow,
  153. rgShow: this.$store.getters.getRgShow
  154. };
  155. },
  156. },
  157. /**
  158. *
  159. */
  160. watch: {
  161. // 获取登录注册状态
  162. loginAntReg(obj) {
  163. this.Lshow = obj.isshow_code;
  164. this.rgShow = obj.rgShow;
  165. }
  166. },
  167. mounted() {
  168. // 导航样式初始化
  169. if (localStorage.getItem("activity")) {
  170. this.headActive = localStorage.getItem("activity");
  171. }else{
  172. this.headActive='home';
  173. this.$store.dispatch("GETACTIVITY", "home");
  174. }
  175. // 头部导航数据判断储存和更换
  176. if (this.$store.getters.getHeadTitle) {
  177. this.title = this.$store.getters.getHeadTitle;
  178. } else {
  179. this.getAjax();
  180. }
  181. if (localStorage.getItem("name")) {
  182. this.name = localStorage.getItem("name");
  183. this.nameShow = true;
  184. } else {
  185. this.nameShow = false;
  186. }
  187. // 轮询获取头部导航信息
  188. let _this = this;
  189. this.$public.ajaxTimerFun(function(timing) {
  190. if (_this.timers) {
  191. _this.getAjax();
  192. _this.getuserData()
  193. }else{
  194. clearInterval(timing);
  195. }
  196. },(1000*60));
  197. },
  198. beforeDestroy() {
  199. this.timers = false;
  200. },
  201. beforeUpdate(){
  202. // 获取url进入首页更改样式
  203. if(localStorage.getItem("activity")=='home'){
  204. this.headActive='home';
  205. }
  206. }
  207. };
  208. </script>
  209. <style scoped>
  210. .no-roll{
  211. position: fixed;
  212. top: 0;
  213. left: 0;
  214. }
  215. .head_on_box {
  216. padding: 0 .32rem;
  217. }
  218. .box {
  219. height: 1.76rem;
  220. background: linear-gradient(to bottom, #999999, #6a6a6b);
  221. overflow: hidden;
  222. }
  223. .navtitle-box {
  224. height: 1rem;
  225. padding: 0 0.32rem 0 0;
  226. }
  227. .headbox {
  228. font-size: 0.3rem;
  229. font-weight: bold;
  230. color: #e1e1df;
  231. }
  232. .head_box {
  233. width: 86%;
  234. height: 1rem;
  235. overflow: hidden;
  236. }
  237. .head_box nav {
  238. /* display: -webkit-box;
  239. display: -ms-flexbox;
  240. -webkit-box-align: middle;
  241. height: 1rem;
  242. -ms-flex-align: middle;
  243. align-items: middle;
  244. overflow-x: auto;
  245. -webkit-overflow-scrolling: touch; */
  246. display: -webkit-box;
  247. display: -ms-flexbox;
  248. display: flex;
  249. -webkit-box-align: middle;
  250. -ms-flex-align: middle;
  251. align-items: middle;
  252. overflow: auto;
  253. }
  254. /* .navtitle {
  255. font-size: 0.16rem;
  256. height: 1rem;
  257. -ms-flex-negative: 0;
  258. flex-shrink: 0;
  259. } */
  260. /* nav{
  261. width: 8.39rem;
  262. } */
  263. .nav-arr {
  264. width: 1.3rem;
  265. /* margin: 0 0.1rem; */
  266. font-size: 0.16rem;
  267. height: 1rem;
  268. }
  269. .user-ion {
  270. width: 0.3rem;
  271. height: 0.3rem;
  272. }
  273. div.active {
  274. color: #f76649;
  275. }
  276. .numactive {
  277. background: #f76649 !important;
  278. color: #f8f8f8 !important;
  279. }
  280. .head_box_num {
  281. width: 0.4rem;
  282. height: 0.4rem;
  283. border-radius: 50%;
  284. font-size: 0.2rem;
  285. background: #e1e1df;
  286. color: #333;
  287. margin-left: 0.1rem;
  288. }
  289. .username {
  290. color: #e1e1df;
  291. }
  292. </style>