|
@@ -0,0 +1,259 @@
|
|
|
|
+<template>
|
|
|
|
+ <div class="Search">
|
|
|
|
+ <div class="ban" ref="ban">
|
|
|
|
+ <img src="@/assets/img/bannerRes.png" alt="" />
|
|
|
|
+ <h3>Result</h3>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="mainBox" :class="{ curSorll: menaSon }">
|
|
|
|
+ <div class="rowAll">
|
|
|
|
+ <div
|
|
|
|
+ @click="cutCom(item.cut, index)"
|
|
|
|
+ class="row"
|
|
|
|
+ v-for="(item, index) in tabData"
|
|
|
|
+ :key="index"
|
|
|
|
+ :class="{ active: cut === item.cut }"
|
|
|
|
+ >
|
|
|
|
+ {{ item.name }}
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <div class="main">
|
|
|
|
+ <div class="title">
|
|
|
|
+ <span>{{ num }}</span> results
|
|
|
|
+ </div>
|
|
|
|
+ <!-- 动态组件 -->
|
|
|
|
+ <component ref="comSon" :is="cut" :num.sync="num"></component>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+import All from "./All.vue";
|
|
|
|
+import Visit from "./Visit.vue";
|
|
|
|
+import Exhibitions from "./Exhibitions.vue";
|
|
|
|
+import Collections from "./Collections.vue";
|
|
|
|
+import Learn from "./Learn.vue";
|
|
|
|
+import Research from "./Research.vue";
|
|
|
|
+import Join from "./Join.vue";
|
|
|
|
+import About from "./About.vue";
|
|
|
|
+import Events from "./Events.vue";
|
|
|
|
+import Terms from "./Terms.vue";
|
|
|
|
+import Employment from "./Employment.vue";
|
|
|
|
+
|
|
|
|
+export default {
|
|
|
|
+ name: "Search",
|
|
|
|
+ components: {
|
|
|
|
+ All,
|
|
|
|
+ Visit,
|
|
|
|
+ Exhibitions,
|
|
|
|
+ Collections,
|
|
|
|
+ Learn,
|
|
|
|
+ Research,
|
|
|
|
+ Join,
|
|
|
|
+ About,
|
|
|
|
+ Events,
|
|
|
|
+ Terms,
|
|
|
|
+ Employment,
|
|
|
|
+ },
|
|
|
|
+ data() {
|
|
|
|
+ //这里存放数据
|
|
|
|
+ return {
|
|
|
|
+ num: 0,
|
|
|
|
+ menaSon: false,
|
|
|
|
+ cut: "All",
|
|
|
|
+ tabData: [
|
|
|
|
+ { id: 1, name: "All Results", cut: "All" },
|
|
|
|
+ { id: 2, name: "Visit", cut: "Visit" },
|
|
|
|
+ { id: 3, name: "Exhibitions", cut: "Exhibitions" },
|
|
|
|
+ { id: 4, name: "Collections", cut: "Collections" },
|
|
|
|
+ { id: 5, name: "Learn & Engage", cut: "Learn" },
|
|
|
|
+ { id: 6, name: "Research & Publications", cut: "Research" },
|
|
|
|
+ { id: 7, name: "Join & Support", cut: "Join" },
|
|
|
|
+ { id: 8, name: "About", cut: "About" },
|
|
|
|
+ { id: 9, name: "Events", cut: "Events" },
|
|
|
|
+ { id: 10, name: "Terms of Use", cut: "Terms" },
|
|
|
|
+ { id: 11, name: "Employment", cut: "Employment" },
|
|
|
|
+ ],
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ //监听属性 类似于data概念
|
|
|
|
+ computed: {},
|
|
|
|
+ //监控data中的数据变化
|
|
|
|
+ watch: {
|
|
|
|
+ $route() {
|
|
|
|
+ this.txtChange();
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ //方法集合
|
|
|
|
+ methods: {
|
|
|
|
+ cutCom(val, index) {
|
|
|
|
+ this.cut = val;
|
|
|
|
+ // 获取二级选中元素距离左侧的距离
|
|
|
|
+ let sonScroll = document.querySelectorAll(".rowAll .row");
|
|
|
|
+ let sonScrollAll = document.querySelector(".mainBox");
|
|
|
|
+ sonScrollAll.scrollTo({
|
|
|
|
+ left: sonScroll[index].offsetLeft - 100,
|
|
|
|
+ behavior: "smooth",
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ // 封装一个地址栏改变的方法
|
|
|
|
+ txtChange() {
|
|
|
|
+ //获取参数
|
|
|
|
+ let txt = this.$route.params.t;
|
|
|
|
+ if (txt && txt !== "null") {
|
|
|
|
+ // 给Layout搜索框赋值
|
|
|
|
+ // this.$nextTick(()=>{
|
|
|
|
+ // setTimeout(() => {
|
|
|
|
+ // let dom = document.querySelector('#myInput')
|
|
|
|
+ // dom.value=txt
|
|
|
|
+ // console.log(dom);
|
|
|
|
+ // }, 100);
|
|
|
|
+ // })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ //生命周期 - 创建完成(可以访问当前this实例)
|
|
|
|
+ created() {
|
|
|
|
+ this.txtChange();
|
|
|
|
+ },
|
|
|
|
+ //生命周期 - 挂载完成(可以访问DOM元素)
|
|
|
|
+ mounted() {
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ // 获取顶部元素ban的高度
|
|
|
|
+ let banDom = this.$refs.ban;
|
|
|
|
+ // 获取滚动的总元素
|
|
|
|
+ let scrollDom = document.querySelector(".Layout");
|
|
|
|
+ // 获取顶部固定栏
|
|
|
|
+ let LayoutTop = document.querySelector(".Layout .top");
|
|
|
|
+ scrollDom.onscroll = () => {
|
|
|
|
+ if (scrollDom.scrollTop > banDom.offsetHeight) {
|
|
|
|
+ LayoutTop.style.display = "none";
|
|
|
|
+ this.menaSon = true;
|
|
|
|
+ } else {
|
|
|
|
+ LayoutTop.style.display = "flex";
|
|
|
|
+ this.menaSon = false;
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ }, 0);
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ beforeCreate() {}, //生命周期 - 创建之前
|
|
|
|
+ beforeMount() {}, //生命周期 - 挂载之前
|
|
|
|
+ beforeUpdate() {}, //生命周期 - 更新之前
|
|
|
|
+ updated() {}, //生命周期 - 更新之后
|
|
|
|
+ beforeDestroy() {}, //生命周期 - 销毁之前
|
|
|
|
+ destroyed() {
|
|
|
|
+ // 获取滚动的总元素,删除滚动事件
|
|
|
|
+ let scrollDom = document.querySelector(".Layout");
|
|
|
|
+ scrollDom.onscroll = null;
|
|
|
|
+ // 获取顶部固定栏
|
|
|
|
+ let LayoutTop = document.querySelector(".Layout .top");
|
|
|
|
+ LayoutTop.style.display = "flex";
|
|
|
|
+ }, //生命周期 - 销毁完成
|
|
|
|
+ activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
|
|
|
|
+};
|
|
|
|
+</script>
|
|
|
|
+<style lang='less' scoped>
|
|
|
|
+::-webkit-scrollbar {
|
|
|
|
+ height: 0;
|
|
|
|
+ width: 0;
|
|
|
|
+ color: transparent;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.Search {
|
|
|
|
+ width: 100%;
|
|
|
|
+ .ban {
|
|
|
|
+ position: relative;
|
|
|
|
+ width: 100%;
|
|
|
|
+ & > img {
|
|
|
|
+ width: 100%;
|
|
|
|
+ }
|
|
|
|
+ & > h3 {
|
|
|
|
+ position: absolute;
|
|
|
|
+ font-size: 24px;
|
|
|
|
+ color: #fff;
|
|
|
|
+ left: 30px;
|
|
|
|
+ bottom: 30px;
|
|
|
|
+ border-bottom: 1px solid #fff;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ .mainBox {
|
|
|
|
+ width: 100%;
|
|
|
|
+ overflow-x: auto;
|
|
|
|
+ z-index: 10;
|
|
|
|
+ .rowAll {
|
|
|
|
+ width: 1256px;
|
|
|
|
+ padding: 20px;
|
|
|
|
+ background-color: #f7f6f3;
|
|
|
|
+ .row {
|
|
|
|
+ display: inline-block;
|
|
|
|
+ font-size: 16px;
|
|
|
|
+ height: 30px;
|
|
|
|
+ line-height: 30px;
|
|
|
|
+ margin-right: 10px;
|
|
|
|
+ padding: 0 8px;
|
|
|
|
+ }
|
|
|
|
+ .active {
|
|
|
|
+ background-color: #c1aa7b;
|
|
|
|
+ border-radius: 15px;
|
|
|
|
+ color: #fff;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ .txt {
|
|
|
|
+ width: 80%;
|
|
|
|
+ margin: 0 auto;
|
|
|
|
+ position: relative;
|
|
|
|
+ display: flex;
|
|
|
|
+ align-items: center;
|
|
|
|
+ justify-content: space-between;
|
|
|
|
+ height: 40px;
|
|
|
|
+ .inco {
|
|
|
|
+ position: absolute;
|
|
|
|
+ z-index: 10;
|
|
|
|
+ content: "";
|
|
|
|
+ display: block;
|
|
|
|
+ position: absolute;
|
|
|
|
+ top: 9px;
|
|
|
|
+ left: 10px;
|
|
|
|
+ background: url("../../assets/img/Layout/search2.png");
|
|
|
|
+ background-size: 20px, 20px;
|
|
|
|
+ width: 20px;
|
|
|
|
+ height: 20px;
|
|
|
|
+ }
|
|
|
|
+ & > input {
|
|
|
|
+ width: 100%;
|
|
|
|
+ height: 38px;
|
|
|
|
+ border-radius: 19px;
|
|
|
|
+ padding-left: 40px;
|
|
|
|
+ border: 1px solid #d2b986;
|
|
|
|
+ background-color: transparent;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ .main {
|
|
|
|
+ width: 100%;
|
|
|
|
+ padding: 30px 20px 40px;
|
|
|
|
+ .title {
|
|
|
|
+ width: calc(100% - 40px);
|
|
|
|
+ margin: 0 auto;
|
|
|
|
+ padding-left: 30px;
|
|
|
|
+ font-size: 18px;
|
|
|
|
+ background: url("../../assets/img/Layout/chosen.png") 0px center no-repeat;
|
|
|
|
+ background-size: 22px 18px;
|
|
|
|
+ & > span {
|
|
|
|
+ color: #bc1c24;
|
|
|
|
+ font-weight: 700;
|
|
|
|
+ margin-right: 10px;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ .curSorll {
|
|
|
|
+ z-index: 99;
|
|
|
|
+ position: fixed;
|
|
|
|
+ top: 0;
|
|
|
|
+ left: 0;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</style>
|