许静 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
 <template>
1
 <template>
2
   <div class="welcomePage">
2
   <div class="welcomePage">
3
     <div class="welcome-con">
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
            <div class="content flex-h">
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
             <li v-for="(user, k) in users" :key="k+'li'" class="fade-item">
9
             <li v-for="(user, k) in users" :key="k+'li'" class="fade-item">
10
               <span>{{user.name}}</span>
10
               <span>{{user.name}}</span>
11
              <span>{{user.words}}</span>
11
              <span>{{user.words}}</span>
12
             </li>
12
             </li>
13
-          </transition-group> -->
14
-          <ul class="centerLabel userList">
13
+          </transition-group>
14
+          <!-- <ul class="centerLabel userList">
15
             <li v-for="(user, k) in users" :key="k+'li'"  class="fade-item">
15
             <li v-for="(user, k) in users" :key="k+'li'"  class="fade-item">
16
               <span>{{user.name}}</span>
16
               <span>{{user.name}}</span>
17
              <span>{{user.words}}</span>
17
              <span>{{user.words}}</span>
18
             </li>
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
             <div v-for="(audio, k) in audios" :key="k+'audio'">
21
             <div v-for="(audio, k) in audios" :key="k+'audio'">
30
               <audio  @ended="audioEnd(k)" autoplay>
22
               <audio  @ended="audioEnd(k)" autoplay>
31
                 <source :src="audio.url">
23
                 <source :src="audio.url">
32
               </audio>
24
               </audio>
33
             </div>
25
             </div>
34
-          </div>
35
         </div>
26
         </div>
27
+      </div>
36
     </div>
28
     </div>
37
     </div>
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
         <ul>
31
         <ul>
40
           <li v-if="weatherDetail">
32
           <li v-if="weatherDetail">
41
             <span class="shares-name font24">{{currentDate}}</span>
33
             <span class="shares-name font24">{{currentDate}}</span>
95
   },
87
   },
96
   computed: {
88
   computed: {
97
     ...mapPageState({
89
     ...mapPageState({
98
-      pageDetail: x => x.pageDetail
90
+      weatherInfo: x => x.weatherInfo
99
     }),
91
     }),
100
     weatherDetail () {
92
     weatherDetail () {
101
-      let target = this.pageDetail.weather ? JSON.parse(this.pageDetail.weather) : undefined
93
+      let target = this.weatherInfo
102
 
94
 
103
       if (!target) return undefined
95
       if (!target) return undefined
104
 
96
 
121
   created () {
113
   created () {
122
     this.assetdir = this.$route.query.assets || this.assetdir
114
     this.assetdir = this.$route.query.assets || this.assetdir
123
     this.city = this.$route.query.city || this.city
115
     this.city = this.$route.query.city || this.city
124
-
125
     getShares().then(dt => (this.sharesData = dt))
116
     getShares().then(dt => (this.sharesData = dt))
126
     window.setInterval(() => {
117
     window.setInterval(() => {
127
       getShares().then(dt => (this.sharesData = dt))
118
       getShares().then(dt => (this.sharesData = dt))
146
       autoConnect: true
137
       autoConnect: true
147
     })
138
     })
148
 
139
 
149
-    // window.console.log(this.$route.query.id, this.$route.query)
150
-
151
     // const wsURI = `${window.location.origin.replace('http', 'ws')}/api/ws/${this.$route.query.id}`
140
     // const wsURI = `${window.location.origin.replace('http', 'ws')}/api/ws/${this.$route.query.id}`
152
     this.ws.connect('ws://192.168.0.67:8080/ws/screen/113')
141
     this.ws.connect('ws://192.168.0.67:8080/ws/screen/113')
153
     this.init()
142
     this.init()
172
   },
161
   },
173
   methods: {
162
   methods: {
174
     ...mapPageActions([
163
     ...mapPageActions([
175
-      'getNewIndex'
164
+      'getWeather'
176
     ]),
165
     ]),
177
     ...mapPageMutations([
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
     audioEnd (index) {
169
     audioEnd (index) {
198
       this.audios = this.audios.slice().map((x, i) => {
170
       this.audios = this.audios.slice().map((x, i) => {
199
         if (i === index) {
171
         if (i === index) {
208
         return
180
         return
209
       }
181
       }
210
       const res = JSON.parse(e.data)
182
       const res = JSON.parse(e.data)
183
+      console.log(res, 'res11111')
211
       if (res.type && res.type === 'cmd') {
184
       if (res.type && res.type === 'cmd') {
212
         // 如果这种类型的消息, 说明是行为控制
185
         // 如果这种类型的消息, 说明是行为控制
213
         switch (res.data) {
186
         switch (res.data) {
219
             break
192
             break
220
         }
193
         }
221
       } else {
194
       } else {
195
+        console.log(res, 'res2222')
222
         this.newData({
196
         this.newData({
223
           name: !res.person.words ? '' : res.person.words,
197
           name: !res.person.words ? '' : res.person.words,
224
           classId: res.person.typeId,
198
           classId: res.person.typeId,
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
     init () { // 初始化
222
     init () { // 初始化
231
-      this.emptyPageDetail()
223
+      this.emptyWeatherInfo()
232
       this.getDate()
224
       this.getDate()
233
-      this.getNewIndex({ id: this.$route.query.id, city: this.city })
225
+      this.getWeather({ city: this.city })
234
     },
226
     },
235
     getDate () { // 获取当前时间
227
     getDate () { // 获取当前时间
236
       let currentTime = Date.now()
228
       let currentTime = Date.now()
257
   background: url('../assets/images/welcome/bg.jpg') no-repeat center ;
249
   background: url('../assets/images/welcome/bg.jpg') no-repeat center ;
258
   background-size: 100% 100%;
250
   background-size: 100% 100%;
259
    .fade-item {
251
    .fade-item {
260
-    transition: all 0.5s;
261
     display: inline-block;
252
     display: inline-block;
262
   }
253
   }
263
-  .fade-enter,
264
-  .fade-leave-to {
254
+  .fade-enter,.fade-leave-to{
265
     opacity: 0;
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
   .welcome-con{
263
   .welcome-con{
271
    width: 100%;
264
    width: 100%;
281
     .content{
274
     .content{
282
       width: 100%;
275
       width: 100%;
283
       height: 100%;
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
        .userList{
282
        .userList{
285
         width: 100%;
283
         width: 100%;
286
         height: 100%;
284
         height: 100%;

+ 21
- 1
src/store/newIndex/index.js 查看文件

4
 export default {
4
 export default {
5
   namespaced: true,
5
   namespaced: true,
6
   state: {
6
   state: {
7
-    pageDetail: null
7
+    pageDetail: null,
8
+    weatherInfo: null
8
   },
9
   },
9
   mutations: {
10
   mutations: {
11
+    updateWeatherInfo (state, payload) {
12
+      state.weatherInfo = JSON.parse(payload.data)
13
+    },
10
     updatePageDetail (state, payload) {
14
     updatePageDetail (state, payload) {
11
       state.pageDetail = { ...payload.data }
15
       state.pageDetail = { ...payload.data }
12
     },
16
     },
13
     emptyPageDetail (state) {
17
     emptyPageDetail (state) {
14
       state.pageDetail = null
18
       state.pageDetail = null
19
+    },
20
+    emptyWeatherInfo (state) {
21
+      state.weatherInfo = null
15
     }
22
     }
16
   },
23
   },
17
   actions: {
24
   actions: {
28
           reject(res)
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
   newIndex: {
23
   newIndex: {
24
     method: 'get',
24
     method: 'get',
25
     url: `/api/screen/fristpage/device/:id`
25
     url: `/api/screen/fristpage/device/:id`
26
+  },
27
+  getWeather: {
28
+    method: 'get',
29
+    url: `/api/screen/weather`
26
   }
30
   }
27
 }
31
 }
28
 
32