HomeList.vue 7.0 KB

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