HomeList.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <div class="HomeList">
  3. <!-- 输入框 -->
  4. <div class="inputBox" @keydown.enter="searchFu()">
  5. <div class="searInco">
  6. <van-icon name="search" />
  7. </div>
  8. <div class="searBtn" @click="searchFu()">搜索</div>
  9. <van-field
  10. maxlength="10"
  11. v-model="txt"
  12. placeholder="输入您感兴趣的内容"
  13. />
  14. </div>
  15. <!-- 主体内容 -->
  16. <div class="mainBoxNull" v-if="dataShow.length===0">暂无内容</div>
  17. <div class="mainBox" v-else>
  18. <div
  19. class="row"
  20. @click="handlClick(item.id)"
  21. v-for="item in dataShow"
  22. :key="item.id"
  23. >
  24. <img :src="require(`@/assets/img/home/${item.id}.jpg`)" alt="" />
  25. <div class="name">{{ item.name }}</div>
  26. <div class="loc">
  27. <img src="../../../assets/img/home/loc.png" alt="" />
  28. {{ item.loction }}
  29. </div>
  30. </div>
  31. </div>
  32. <!-- 视频盒子 -->
  33. <div class="videoBox" :class="{ videoAc: videoShow }">
  34. <video muted src="../../../assets/media/home.mp4"></video>
  35. <img
  36. v-show="videoBtnShow"
  37. class="videoBtn"
  38. src="../../../assets/img/home/videoBtn.png"
  39. alt=""
  40. @click="$router.push('/layout/construct')"
  41. />
  42. </div>
  43. </div>
  44. </template>
  45. <script>
  46. import { Toast } from "vant";
  47. export default {
  48. name: "HomeList",
  49. components: {},
  50. data() {
  51. return {
  52. txt: "",
  53. data: [
  54. { id: 1, name: "老芜湖海关旧址", loction: "滨江公园内" },
  55. { id: 2, name: "英驻芜领事署旧址", loction: "范罗山" },
  56. { id: 3, name: "总税务司公所旧址", loction: "范罗山" },
  57. { id: 4, name: "洋员帮办楼旧址", loction: "范罗山" },
  58. { id: 5, name: "英驻芜领事官邸旧址", loction: "吉和南路 26 号雨耕山顶" },
  59. { id: 6, name: "大教堂", loction: "吉和街28 号" },
  60. { id: 7, name: "神父楼", loction: "吉和街28 号" },
  61. { id: 8, name: "天主教主教公署旧址", loction: "狮子山马路39号" },
  62. { id: 9, name: "圣母院旧址", loction: "狮子山马路39号" },
  63. { id: 10, name: "天主教修士楼", loction: "大官山顶" },
  64. { id: 11, name: "内思高级工业职业学校旧址", loction: "吉和街26号" },
  65. { id: 12, name: "博仁堂", loction: "安师大附属外国语学校中学内" },
  66. { id: 13, name: "义德堂", loction: "安师大附属外国语学校中学内" },
  67. { id: 14, name: "经方堂", loction: "安师大附属外国语学校中学内" },
  68. { id: 15, name: "广济寺塔", loction: "广济寺内" },
  69. ],
  70. dataShow: [],
  71. videoShow: false,
  72. videoBtnShow: false,
  73. };
  74. },
  75. computed: {},
  76. watch: {
  77. videoShow(val) {
  78. if (val) {
  79. let dom = document.querySelector("video");
  80. dom.play();
  81. dom.addEventListener(
  82. "ended",
  83. () => {
  84. //结束
  85. this.$router.push("/layout/construct");
  86. },
  87. false
  88. );
  89. setTimeout(() => {
  90. this.videoBtnShow = true;
  91. }, 1000);
  92. }
  93. },
  94. },
  95. methods: {
  96. handlClick(id) {
  97. if (id === 1) this.videoShow = true;
  98. else return Toast("敬请期待!");
  99. },
  100. // 获取列表的方法
  101. getList() {
  102. if (this.txt.trim() === "") this.dataShow = this.data;
  103. else this.dataShow = this.data.filter((v) => v.name.includes(this.txt));
  104. },
  105. searchFu() {
  106. this.getList();
  107. },
  108. },
  109. created() {
  110. document.querySelector("#app").style.maxWidth = "500px";
  111. this.getList();
  112. if (this.$route.query.autoWatch) {
  113. this.handlClick(this.$route.query.autoWatch)
  114. }
  115. },
  116. mounted() {},
  117. beforeCreate() {}, //生命周期 - 创建之前
  118. beforeMount() {}, //生命周期 - 挂载之前
  119. beforeUpdate() {}, //生命周期 - 更新之前
  120. updated() {}, //生命周期 - 更新之后
  121. beforeDestroy() {}, //生命周期 - 销毁之前
  122. destroyed() {}, //生命周期 - 销毁完成
  123. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  124. };
  125. </script>
  126. <style lang='less' scoped>
  127. .HomeList {
  128. width: 100%;
  129. height: calc(100% - 80px);
  130. overflow-y: auto;
  131. padding: 20px 15px;
  132. position: relative;
  133. .inputBox {
  134. margin: 0px auto;
  135. width: 100%;
  136. height: 30px;
  137. position: relative;
  138. .searBtn {
  139. position: absolute;
  140. right: 0;
  141. top: 0;
  142. width: 40px;
  143. height: 30px;
  144. border-radius: 3px;
  145. z-index: 2;
  146. background-color: #fe6e69;
  147. font-size: 14px;
  148. color: #fff;
  149. line-height: 30px;
  150. text-align: center;
  151. }
  152. .searInco {
  153. color: #a0a0a0;
  154. display: flex;
  155. justify-content: center;
  156. align-items: center;
  157. font-size: 16px;
  158. position: absolute;
  159. top: 0;
  160. left: 10px;
  161. z-index: 3;
  162. width: 20px;
  163. height: 30px;
  164. }
  165. /deep/.van-cell {
  166. width: 100%;
  167. height: 30px;
  168. line-height: 30px;
  169. padding: 0px 0 0px 36px;
  170. background-color: #f4f4f4;
  171. border-radius: 5px;
  172. }
  173. }
  174. .mainBoxNull{
  175. width: 100%;
  176. height: 300px;
  177. display: flex;
  178. justify-content: center;
  179. align-items: center;
  180. font-size: 16px;
  181. }
  182. .mainBox {
  183. margin-top: 20px;
  184. display: flex;
  185. flex-wrap: wrap;
  186. .row {
  187. margin-right: 4%;
  188. margin-bottom: 4%;
  189. overflow: hidden;
  190. width: 48%;
  191. height: 250px;
  192. background-color: #f7f8fa;
  193. border-radius: 4px;
  194. color: #333333;
  195. &:nth-of-type(2n) {
  196. margin-right: 0;
  197. }
  198. & > img {
  199. width: 100%;
  200. height: 180px;
  201. object-fit: cover;
  202. }
  203. .name {
  204. padding: 8px 10px 3px;
  205. font-size: 14px;
  206. font-weight: 700;
  207. }
  208. .loc {
  209. padding-left: 10px;
  210. display: flex;
  211. align-items: center;
  212. margin-top: 3px;
  213. font-size: 12px;
  214. & > img {
  215. margin-right: 3px;
  216. width: 14px;
  217. }
  218. }
  219. }
  220. }
  221. .videoBox {
  222. opacity: 0;
  223. pointer-events: none;
  224. transition: opacity 0.3s;
  225. position: fixed;
  226. top: 0;
  227. left: 0;
  228. z-index: 3;
  229. width: 100%;
  230. height: 100%;
  231. background-color: #fff;
  232. video {
  233. position: absolute;
  234. top: 50%;
  235. left: 50%;
  236. transform: translate(-50%, -50%);
  237. width: 100%;
  238. // height: 100%;
  239. }
  240. .videoBtn {
  241. position: absolute;
  242. bottom: 40px;
  243. width: 200px;
  244. z-index: 2;
  245. left: 50%;
  246. transform: translateX(-50%);
  247. }
  248. }
  249. .videoAc {
  250. opacity: 1;
  251. pointer-events: auto;
  252. }
  253. }
  254. </style>