App.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <div :class="{'body-box': isGrey}" >
  3. <div class="bg bgig" :class="{bgig: isGrey}" >
  4. <img src="@/assets/img/box-bg.png" >
  5. </div>
  6. <div id="app" class="app">
  7. <div class="boxHeader">
  8. <div class="boxLogo">
  9. <img src="@/assets/img/logo.png" >
  10. </div>
  11. <div class="boxSearch">
  12. <input type="text" v-model="searchValue" placeholder="输入关键词搜索" required />
  13. <img src="@/assets/img/search.png" class="searchImg" @click="search">
  14. </div>
  15. </div>
  16. <div class="boxNav">
  17. <div class="nav" v-for="(n,index) in navList" :class="{navC: isNav == index}" @click="navChoose(index,n)">
  18. <img :src="n.img" class="navImg">
  19. <div class="navName">
  20. {{ n.name }}
  21. </div>
  22. </div>
  23. </div>
  24. <router-view />
  25. </div>
  26. <div class="footer">
  27. 版权所有:Copyright©2017-2037  版权所有 荆门市红十字会 <br>
  28. 地址:湖北省荆门市东宝区金虾路60号 浙ICP备17054590号-1
  29. </div>
  30. </div>
  31. </template>
  32. <script>
  33. import { getTime } from '@/utils/utils.js'
  34. import { getList,getSearch,getgrey,index } from '@/request/api.js'
  35. export default {
  36. data() {
  37. return {
  38. isGrey: false,
  39. isNav: 0,
  40. searchValue: '',
  41. navList: [
  42. {
  43. img: require('@/assets/img/navList/nav1.png'),
  44. name: '首页',
  45. url: '/index'
  46. },
  47. {
  48. img: require('@/assets/img/navList/nav2.png'),
  49. name: '组织介绍',
  50. url: '/introduce'
  51. },
  52. {
  53. img: require('@/assets/img/navList/nav3.png'),
  54. name: '政策法规',
  55. url: '/law'
  56. },
  57. {
  58. img: require('@/assets/img/navList/nav4.png'),
  59. name: '核心业务',
  60. url: '/busine'
  61. },
  62. {
  63. img: require('@/assets/img/navList/nav5.png'),
  64. name: '新闻资讯',
  65. url: '/new'
  66. },
  67. {
  68. img: require('@/assets/img/navList/nav6.png'),
  69. name: '我要参与',
  70. url: '/partake'
  71. },
  72. {
  73. img: require('@/assets/img/navList/nav7.png'),
  74. name: '联系我们',
  75. url: '/contactUs'
  76. },
  77. ],
  78. }
  79. },
  80. mounted() {
  81. index().then(res => {
  82. // console.log(res);
  83. console.log(getTime(res.time));
  84. })
  85. // 页面灰化
  86. getgrey().then(res => {
  87. const time = new Date().getTime()
  88. if (getTime(time) == getTime(res.time)) {
  89. // this.isGrey = true
  90. console.log(getTime(res.time));
  91. console.log(this.isGrey);
  92. } else{
  93. console.log(time);
  94. }
  95. })
  96. },
  97. methods: {
  98. // 搜索
  99. search() {
  100. if(this.searchValue == '') {
  101. this.$message('搜索内容为空');
  102. }else {
  103. this.$router.push({
  104. name: 'searchList',
  105. query: {value: this.searchValue}
  106. })
  107. }
  108. },
  109. navChoose(index,n) {
  110. this.isNav = index
  111. this.navTo(n.url)
  112. },
  113. // 跳转页面
  114. navTo(url) {
  115. this.$router.push({
  116. path: url
  117. })
  118. },
  119. getTime(time) {
  120. return getTime(time)
  121. },
  122. },
  123. // 解决刷新导航栏选择返回默认值问题
  124. watch: {
  125. "$route": function(val) {
  126. for (var i = 0; i < this.navList.length; i++) {
  127. if (val.path == '/') {
  128. this.isNav = 0
  129. } else{
  130. if (this.navList[i].url == val.path) {
  131. this.isNav = i
  132. }
  133. }
  134. }
  135. }
  136. },
  137. }
  138. </script>
  139. <style lang="scss">
  140. .body-box {
  141. -webkit-filter: grayscale(100%); /* webkit */
  142. -moz-filter: grayscale(100%); /*firefox*/
  143. -ms-filter: grayscale(100%); /*ie9*/
  144. -o-filter: grayscale(100%); /*opera*/
  145. filter: grayscale(100%);
  146. filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
  147. filter:gray; /*ie9- */
  148. }
  149. .nowarp {
  150. overflow: hidden;
  151. text-overflow: ellipsis;
  152. display: -webkit-box;
  153. -webkit-box-orient: vertical;
  154. -webkit-line-clamp: 1;
  155. }
  156. html, body {
  157. scroll-behavior:smooth;
  158. margin: 0;
  159. }
  160. .bg {
  161. position: absolute;
  162. top: 0;
  163. z-index: -1;
  164. width: 100%;
  165. img {
  166. width: 100%;
  167. }
  168. }
  169. .bgig {
  170. top: -100px;
  171. }
  172. $red: #D82020;
  173. .app {
  174. font-family: PingFang-SC-Bold;
  175. width: 1100px;
  176. margin: 0 auto;
  177. .boxHeader {
  178. display: flex;
  179. justify-content: space-between;
  180. margin: 80px 0;
  181. .boxLogo,.boxSearch {
  182. margin: auto 0;
  183. }
  184. .boxLogo {
  185. img {
  186. width: 300px;
  187. }
  188. }
  189. .boxSearch {
  190. position: relative;
  191. input {
  192. min-width: 180px;
  193. border-radius: 20px;
  194. border: solid 2px $red;
  195. padding: 5px 10px;
  196. padding-right: 30px;
  197. height: 15px;
  198. outline: none; // 设置点击后无效果
  199. }
  200. .searchImg {
  201. width: 15px;
  202. margin: auto 0;
  203. position: absolute;
  204. top: 7px;
  205. right: 10px;
  206. }
  207. }
  208. }
  209. .boxNav {
  210. background-color: $red;
  211. display: flex;
  212. justify-content: space-around;
  213. margin: 20px 0;
  214. .nav {
  215. padding: 10px;
  216. flex: 1;
  217. text-align: center;
  218. color: #fff;
  219. font-size: 16px;
  220. font-family: PingFang-SC-Bold;
  221. // font-weight: Bold;
  222. letter-spacing: 2px;
  223. .navImg {
  224. width: 26px;
  225. height: 24px;
  226. margin: 2px;
  227. }
  228. }
  229. .navC {
  230. background-color: #C2191C;
  231. }
  232. }
  233. }
  234. .footer {
  235. min-width: 1100px;
  236. margin-top: 100px;
  237. background-color: $red;
  238. width: 100%;
  239. color: #fff;
  240. line-height: 20px;
  241. font-size: 14px;
  242. padding: 40px 0;
  243. text-align: center;
  244. }
  245. </style>