Browse Source

【建筑可游玩】banner图显示最近一次查看的建筑

任一存 2 years ago
parent
commit
b78fc69b26

+ 4 - 4
yfyc/src/store/index.js

@@ -5,14 +5,14 @@ Vue.use(Vuex)
 
 export default new Vuex.Store({
   state: {
-    test: 0,
+    latestConstructId: 1,
   },
   getters: {
   },
   mutations: {
-    setTest(state) {
-      state.test = 1
-    },
+    setLatestConstructId(state, id) {
+      state.latestConstructId = id
+    }
   },
   actions: {
   },

+ 5 - 0
yfyc/src/views/Construct/components/HomeList.vue

@@ -110,7 +110,12 @@ export default {
     },
   },
   methods: {
+    ...globalMapMutations([
+      'setLatestConstructId',
+    ]),
     handlClick(id) {
+      // 记录最近一次查看的建筑
+      this.setLatestConstructId(id)
       this.myId = id;
       this.videoShow = true;
     },

+ 12 - 5
yfyc/src/views/Serve/index.vue

@@ -1,6 +1,11 @@
 <template>
   <div class="service" id="service-first-page">
-    <div class="banner" @click="onClickBanner">
+    <div
+      class="banner"
+      :style="{
+        backgroundImage: `url(${bannerImgUrl})`
+      }"
+    >
       <!-- <SearchBar class="search-bar" @search="onSearch" @click.stop></SearchBar> -->
     </div>
     
@@ -228,8 +233,14 @@ data() {
   };
 },
 computed: {
+  ...globalMapState([
+    'latestConstructId',
+  ]),
   recoPathList() {
     return serveData.pathList
+  },
+  bannerImgUrl() {
+    return require(`@/assets/img/home/${this.latestConstructId}.jpg`)
   }
 },
 watch: {},
@@ -247,9 +258,6 @@ methods: {
   //     })
   //   })
   // },
-  onClickBanner() {
-    this.pleaseWait()
-  },
   onClickBooking() {
     const loginStatus = globalUtils.checkLoginStatus()
     // const loginStatus = false
@@ -292,7 +300,6 @@ activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
   overflow: auto;
   .banner {
     height: 57.9vw;
-    background-image: url(~@/assets/img/service/banner.png);
     background-size: cover;
     background-repeat: no-repeat;
     background-position: center center;