许静 пре 6 година
родитељ
комит
f0c78b3e56
3 измењених фајлова са 72 додато и 50 уклоњено
  1. 47
    49
      src/pages/welcome.vue
  2. 21
    1
      src/store/newIndex/index.js
  3. 4
    0
      src/util/api.js

+ 47
- 49
src/pages/welcome.vue Прегледај датотеку

@@ -1,41 +1,33 @@
1 1
 <template>
2 2
   <div class="welcomePage">
3 3
     <div class="welcome-con">
4
-          <img  v-if="!users.length" class="welcome-img" src="../assets/images/welcome/text.png" alt="">
4
+          <img  :hidden="!!users.length" class="welcome-img" src="../assets/images/welcome/text.png" alt="">
5 5
            <div class="content flex-h">
6
-              <div class="flex-item">
7
-              <div v-if="users.length">
8
-          <!-- <transition-group class="centerLabel userList" tag="ul" name="fade">
6
+             <!-- <p class="font">黄先生,欢迎光临银城.原溪</p> -->
7
+          <div :hidden="!users.length" >
8
+          <transition-group class="centerLabel userList" tag="ul" name="fade">
9 9
             <li v-for="(user, k) in users" :key="k+'li'" class="fade-item">
10 10
               <span>{{user.name}}</span>
11 11
              <span>{{user.words}}</span>
12 12
             </li>
13
-          </transition-group> -->
14
-          <ul class="centerLabel userList">
13
+          </transition-group>
14
+          <!-- <ul class="centerLabel userList">
15 15
             <li v-for="(user, k) in users" :key="k+'li'"  class="fade-item">
16 16
               <span>{{user.name}}</span>
17 17
              <span>{{user.words}}</span>
18 18
             </li>
19
-          </ul>
20
-           </div>
21
-          <!-- <div v-if="audios.length > 0" :hidden="true">
22
-            <div v-for="(audio, k) in audios" :key="k+'audio'">
23
-              <audio v-if="audio.isShow" @ended="audioEnd(k)" autoplay>
24
-                <source :src="audio.url">
25
-              </audio>
26
-            </div>
27
-          </div> -->
28
-          <div >
19
+          </ul> -->
20
+          <div v-if="audios" :hidden="true">
29 21
             <div v-for="(audio, k) in audios" :key="k+'audio'">
30 22
               <audio  @ended="audioEnd(k)" autoplay>
31 23
                 <source :src="audio.url">
32 24
               </audio>
33 25
             </div>
34
-          </div>
35 26
         </div>
27
+      </div>
36 28
     </div>
37 29
     </div>
38
-      <x-maquee class="marquee" v-if="pageDetail !== null && (pageDetail.detail.noticeShow || pageDetail.detail.weatherShow)">
30
+      <x-maquee class="marquee" v-if="weatherInfo !== null">
39 31
         <ul>
40 32
           <li v-if="weatherDetail">
41 33
             <span class="shares-name font24">{{currentDate}}</span>
@@ -95,10 +87,10 @@ export default {
95 87
   },
96 88
   computed: {
97 89
     ...mapPageState({
98
-      pageDetail: x => x.pageDetail
90
+      weatherInfo: x => x.weatherInfo
99 91
     }),
100 92
     weatherDetail () {
101
-      let target = this.pageDetail.weather ? JSON.parse(this.pageDetail.weather) : undefined
93
+      let target = this.weatherInfo
102 94
 
103 95
       if (!target) return undefined
104 96
 
@@ -121,7 +113,6 @@ export default {
121 113
   created () {
122 114
     this.assetdir = this.$route.query.assets || this.assetdir
123 115
     this.city = this.$route.query.city || this.city
124
-
125 116
     getShares().then(dt => (this.sharesData = dt))
126 117
     window.setInterval(() => {
127 118
       getShares().then(dt => (this.sharesData = dt))
@@ -146,8 +137,6 @@ export default {
146 137
       autoConnect: true
147 138
     })
148 139
 
149
-    // window.console.log(this.$route.query.id, this.$route.query)
150
-
151 140
     // const wsURI = `${window.location.origin.replace('http', 'ws')}/api/ws/${this.$route.query.id}`
152 141
     this.ws.connect('ws://192.168.0.67:8080/ws/screen/113')
153 142
     this.init()
@@ -172,28 +161,11 @@ export default {
172 161
   },
173 162
   methods: {
174 163
     ...mapPageActions([
175
-      'getNewIndex'
164
+      'getWeather'
176 165
     ]),
177 166
     ...mapPageMutations([
178
-      'emptyPageDetail'
167
+      'emptyWeatherInfo'
179 168
     ]),
180
-    newData (info) {
181
-      if (info.classId - 0 === 1 && this.users.filter(x => x.classId - 0 === 1).length > 0) {
182
-        this.users = this.users.map((x) => {
183
-          if (x.classId - 0 === 1) {
184
-            return { ...x, createdata: Date.parse(new Date()) }
185
-          } else {
186
-            return x
187
-          }
188
-        })
189
-      } else {
190
-        if (this.users.length >= 3) {
191
-          this.users.splice(0, 1)
192
-        }
193
-        this.users = [...this.users, { ...info, createdata: Date.parse(new Date()) }]
194
-        this.audios = [...this.audios, { ...info, isShow: true, createdata: Date.parse(new Date()) }]
195
-      }
196
-    },
197 169
     audioEnd (index) {
198 170
       this.audios = this.audios.slice().map((x, i) => {
199 171
         if (i === index) {
@@ -208,6 +180,7 @@ export default {
208 180
         return
209 181
       }
210 182
       const res = JSON.parse(e.data)
183
+      console.log(res, 'res11111')
211 184
       if (res.type && res.type === 'cmd') {
212 185
         // 如果这种类型的消息, 说明是行为控制
213 186
         switch (res.data) {
@@ -219,6 +192,7 @@ export default {
219 192
             break
220 193
         }
221 194
       } else {
195
+        console.log(res, 'res2222')
222 196
         this.newData({
223 197
           name: !res.person.words ? '' : res.person.words,
224 198
           classId: res.person.typeId,
@@ -227,10 +201,28 @@ export default {
227 201
         })
228 202
       }
229 203
     },
204
+    newData (info) {
205
+      if (info.classId - 0 === 1) {
206
+      // if (info.classId - 0 === 1 && this.users.filter(x => x.classId - 0 === 1).length > 0) {
207
+        this.users = this.users.map((x) => {
208
+          if (x.classId - 0 === 1) {
209
+            return { ...x, createdata: Date.parse(new Date()) }
210
+          } else {
211
+            return x
212
+          }
213
+        })
214
+      } else {
215
+        if (this.users.length >= 3) {
216
+          this.users.splice(0, 1)
217
+        }
218
+        this.users = [...this.users, { ...info, createdata: Date.parse(new Date()) }]
219
+        this.audios = [...this.audios, { ...info, isShow: true, createdata: Date.parse(new Date()) }]
220
+      }
221
+    },
230 222
     init () { // 初始化
231
-      this.emptyPageDetail()
223
+      this.emptyWeatherInfo()
232 224
       this.getDate()
233
-      this.getNewIndex({ id: this.$route.query.id, city: this.city })
225
+      this.getWeather({ city: this.city })
234 226
     },
235 227
     getDate () { // 获取当前时间
236 228
       let currentTime = Date.now()
@@ -257,15 +249,16 @@ export default {
257 249
   background: url('../assets/images/welcome/bg.jpg') no-repeat center ;
258 250
   background-size: 100% 100%;
259 251
    .fade-item {
260
-    transition: all 0.5s;
261 252
     display: inline-block;
262 253
   }
263
-  .fade-enter,
264
-  .fade-leave-to {
254
+  .fade-enter,.fade-leave-to{
265 255
     opacity: 0;
256
+   }
257
+  .fade-enter-to,.fade-leave{
258
+    opacity: 1;
266 259
   }
267
-  .fade-leave-active {
268
-    position: absolute;
260
+  .fade-enter-active,.fade-leave-active{
261
+    transition: all 0.5s;
269 262
   }
270 263
   .welcome-con{
271 264
    width: 100%;
@@ -281,6 +274,11 @@ export default {
281 274
     .content{
282 275
       width: 100%;
283 276
       height: 100%;
277
+      .font{
278
+        font-size: 5vw;
279
+        font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
280
+        font-weight: 900;
281
+      }
284 282
        .userList{
285 283
         width: 100%;
286 284
         height: 100%;

+ 21
- 1
src/store/newIndex/index.js Прегледај датотеку

@@ -4,14 +4,21 @@ import api from '../../util/api'
4 4
 export default {
5 5
   namespaced: true,
6 6
   state: {
7
-    pageDetail: null
7
+    pageDetail: null,
8
+    weatherInfo: null
8 9
   },
9 10
   mutations: {
11
+    updateWeatherInfo (state, payload) {
12
+      state.weatherInfo = JSON.parse(payload.data)
13
+    },
10 14
     updatePageDetail (state, payload) {
11 15
       state.pageDetail = { ...payload.data }
12 16
     },
13 17
     emptyPageDetail (state) {
14 18
       state.pageDetail = null
19
+    },
20
+    emptyWeatherInfo (state) {
21
+      state.weatherInfo = null
15 22
     }
16 23
   },
17 24
   actions: {
@@ -28,6 +35,19 @@ export default {
28 35
           reject(res)
29 36
         })
30 37
       })
38
+    },
39
+    getWeather ({ commit }, payload) {
40
+      return new Promise((resolve, reject) => {
41
+        Ajax(api.getWeather.url, {
42
+          method: api.getWeather.method,
43
+          queryData: { city: payload.city }
44
+        }).then(res => {
45
+          commit('updateWeatherInfo', res)
46
+          resolve(res)
47
+        }).catch((res) => {
48
+          reject(res)
49
+        })
50
+      })
31 51
     }
32 52
   }
33 53
 }

+ 4
- 0
src/util/api.js Прегледај датотеку

@@ -23,6 +23,10 @@ const $api = {
23 23
   newIndex: {
24 24
     method: 'get',
25 25
     url: `/api/screen/fristpage/device/:id`
26
+  },
27
+  getWeather: {
28
+    method: 'get',
29
+    url: `/api/screen/weather`
26 30
   }
27 31
 }
28 32