许静 6 년 전
부모
커밋
1b49c4c27c

+ 2
- 2
config/index.js 파일 보기

@@ -19,14 +19,14 @@ module.exports = {
19 19
         },
20 20
       },
21 21
       '/api': {
22
-        target: 'http://192.168.0.11:8080', 
22
+        target: 'http://192.168.0.67:8080', 
23 23
         changeOrigin: true,
24 24
         pathRewrite: {
25 25
           '^/api': '/',
26 26
         },
27 27
       },
28 28
       '/api/ws': {
29
-        target: 'http://192.168.0.11:8081', 
29
+        target: 'http://192.168.0.67:8081', 
30 30
         changeOrigin: true,
31 31
         ws: true,
32 32
         pathRewrite: {

BIN
src/assets/images/welcome/bg.jpg 파일 보기


BIN
src/assets/images/welcome/text.png 파일 보기


BIN
src/assets/images/welcome/画板 113.jpg 파일 보기


BIN
src/assets/images/welcome/画板 143.jpg 파일 보기


BIN
src/assets/images/welcome/画板 193.jpg 파일 보기


BIN
src/assets/images/welcome/画板 203.jpg 파일 보기


BIN
src/assets/images/welcome/画板 223.jpg 파일 보기


BIN
src/assets/images/welcome/画板 93.jpg 파일 보기


+ 2
- 2
src/pages/page3.vue 파일 보기

@@ -60,13 +60,13 @@
60 60
         </div>
61 61
         <div :hidden="!users.length">
62 62
           <transition-group class="centerLabel userList" tag="ul" name="fade">
63
-            <li v-for="(user, k) in users" :key="k" class="fade-item">
63
+            <li v-for="(user, k) in users" :key="k+'li'" class="fade-item">
64 64
               <!-- <span>{{user.name}}</span> -->
65 65
               <span>{{user.words}}</span>
66 66
             </li>
67 67
           </transition-group>
68 68
           <div v-if="audios.length > 0" :hidden="true">
69
-            <div v-for="(audio, k) in audios" :key="k">
69
+            <div v-for="(audio, k) in audios" :key="k+'audio'">
70 70
               <audio v-if="audio.isShow" @ended="audioEnd(k)" autoplay>
71 71
                 <source :src="audio.url">
72 72
               </audio>

+ 340
- 0
src/pages/welcome.vue 파일 보기

@@ -0,0 +1,340 @@
1
+<template>
2
+  <div class="welcomePage">
3
+    <div class="welcome-con">
4
+          <img  v-if="!users.length" class="welcome-img" src="../assets/images/welcome/text.png" alt="">
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">
9
+            <li v-for="(user, k) in users" :key="k+'li'" class="fade-item">
10
+              <span>{{user.name}}</span>
11
+             <span>{{user.words}}</span>
12
+            </li>
13
+          </transition-group> -->
14
+          <ul class="centerLabel userList">
15
+            <li v-for="(user, k) in users" :key="k+'li'"  class="fade-item">
16
+              <span>{{user.name}}</span>
17
+             <span>{{user.words}}</span>
18
+            </li>
19
+          </ul>
20
+          <div v-if="audios.length > 0" :hidden="true">
21
+            <div v-for="(audio, k) in audios" :key="k+'audio'">
22
+              <audio v-if="audio.isShow" @ended="audioEnd(k)" autoplay>
23
+                <source :src="audio.url">
24
+              </audio>
25
+            </div>
26
+          </div>
27
+        </div>
28
+      </div>
29
+    </div>
30
+    </div>
31
+      <x-maquee class="marquee" v-if="pageDetail !== null && (pageDetail.detail.noticeShow || pageDetail.detail.weatherShow)">
32
+        <ul>
33
+          <li v-if="weatherDetail">
34
+            <span class="shares-name font24">{{currentDate}}</span>
35
+            <span class="shares-price font24">{{currentWeek}}</span>
36
+            <span class="shares-price font24">{{currentChineseDate}}</span>
37
+            <span class="shares-price font24">{{tempRange}}</span>
38
+            <span class="shares-price font24">今日 {{ weatherDetail.day_weather }} {{weatherDetail.index.gj.title}}外出</span>
39
+            <span class="shares-price font24">{{weatherDetail.wind_direction}}{{weatherDetail.wind_power}}</span>
40
+            <span class="shares-price font24">空气湿度: {{weatherDetail.sd}}</span>
41
+            <span class="shares-price font24">体感温度: {{weatherDetail.temperature}}</span>
42
+            <span class="shares-price font24">空气指数: {{weatherDetail.aqi}}</span>
43
+            <span class="shares-price font24">PM2.5: {{weatherDetail.aqiDetail.pm2_5}}</span>
44
+            <span class="shares-price font24">穿衣指数: {{weatherDetail.index.clothes.title}}</span>
45
+          </li>
46
+        </ul>
47
+      </x-maquee>
48
+  </div>
49
+</template>
50
+
51
+<script>
52
+import { createNamespacedHelpers } from 'vuex'
53
+import solarLunar from 'solarLunar'
54
+import XWebSocket from '../util/websocket'
55
+import getShares from '../util/shares'
56
+
57
+const { mapState: mapPageState, mapActions: mapPageActions, mapMutations: mapPageMutations } = createNamespacedHelpers('newIndex')
58
+export default {
59
+  name: 'welcomePage',
60
+  data () {
61
+    return {
62
+      ws: null,
63
+      users: [],
64
+      audios: [],
65
+      diffM: 5000,
66
+      currentDate: '',
67
+      currentWeek: '',
68
+      currentChineseDate: '',
69
+      showSlide: false,
70
+      currentTimeTamp: Date.now(),
71
+      activeIndex: 0,
72
+      timer: null,
73
+      timeNum: 0,
74
+      swiperOption: {
75
+        speed: 1000,
76
+        autoplay: {
77
+          delay: 6000,
78
+          disableOnInteraction: false
79
+        }
80
+      },
81
+      num: 1,
82
+      personDelay: null,
83
+      pageTimer: null,
84
+      assetdir: undefined,
85
+      city: '',
86
+      sharesData: []
87
+    }
88
+  },
89
+  computed: {
90
+    ...mapPageState({
91
+      pageDetail: x => x.pageDetail
92
+    }),
93
+    weatherDetail () {
94
+      let target = this.pageDetail.weather ? JSON.parse(this.pageDetail.weather) : undefined
95
+
96
+      if (!target) return undefined
97
+
98
+      const { f1, now } = target.showapi_res_body
99
+      return { ...f1, ...now }
100
+    },
101
+    tempRange () {
102
+      if (!this.weatherDetail) return ''
103
+      let min, max
104
+      const f = () => (this.weatherDetail.day_air_temperature) - 0 > (this.weatherDetail.night_air_temperature - 0)
105
+        ? ((min = this.weatherDetail.night_air_temperature) | (max = this.weatherDetail.day_air_temperature))
106
+        : ((max = this.weatherDetail.night_air_temperature) | (min = this.weatherDetail.day_air_temperature))
107
+      f()
108
+      return `${min}℃ ~ ${max}℃`
109
+    }
110
+  },
111
+  components: {
112
+    XMaquee: () => import('../components/XMaquee')
113
+  },
114
+  created () {
115
+    this.assetdir = this.$route.query.assets || this.assetdir
116
+    this.city = this.$route.query.city || this.city
117
+
118
+    getShares().then(dt => (this.sharesData = dt))
119
+    window.setInterval(() => {
120
+      getShares().then(dt => (this.sharesData = dt))
121
+    }, 60000)
122
+
123
+    // const _that = this
124
+    window.setInterval(() => {
125
+      let dels = this.users.filter(x => Date.parse(new Date()) - x.createdata > this.diffM)
126
+      dels.forEach(x => {
127
+        const inx = this.users.findIndex(i => i.createdata === x.createdata)
128
+        this.users.splice(inx, 1)
129
+      })
130
+      let delaudios = this.audios.filter(x => Date.parse(new Date()) - x.createdata > this.diffM)
131
+      delaudios.forEach(x => {
132
+        const inx = this.audios.findIndex(i => i.createdata === x.createdata)
133
+        this.audios.splice(inx, 1)
134
+      })
135
+    }, 100)
136
+    this.ws = new XWebSocket({
137
+      message: this.receviedMsg.bind(this),
138
+      delay: 10,
139
+      autoConnect: true
140
+    })
141
+
142
+    // window.console.log(this.$route.query.id, this.$route.query)
143
+
144
+    const wsURI = `${window.location.origin.replace('http', 'ws')}/api/ws/${this.$route.query.id}`
145
+    this.ws.connect(wsURI)
146
+    this.init()
147
+    this.pageTimer = window.setInterval(() => {
148
+      let curMin = new Date().getMinutes() - 0
149
+      let curHour = new Date().getHours() - 0
150
+      let curSec = new Date().getSeconds() - 0
151
+      if (!curMin && !curSec) { // 整点刷新请求
152
+        if (curHour === 1 && !curSec) { // 1点刷新页面
153
+          window.clearInterval(this.pageTimer)
154
+          window.location.reload()
155
+        }
156
+        // this.init()
157
+      }
158
+    }, 1000)
159
+  },
160
+  mounted () {
161
+    console.log(this.users, 'this.users')
162
+  },
163
+  updated () {
164
+    this.$nextTick(() => {
165
+    })
166
+  },
167
+  methods: {
168
+    ...mapPageActions([
169
+      'getNewIndex'
170
+    ]),
171
+    ...mapPageMutations([
172
+      'emptyPageDetail'
173
+    ]),
174
+    newData (info) {
175
+      if (info.classId - 0 === 1 && this.users.filter(x => x.classId - 0 === 1).length > 0) {
176
+        this.users = this.users.map((x) => {
177
+          if (x.classId - 0 === 1) {
178
+            return { ...x, createdata: Date.parse(new Date()) }
179
+          } else {
180
+            return x
181
+          }
182
+        })
183
+      } else {
184
+        if (this.users.length >= 3) {
185
+          this.users.splice(0, 1)
186
+        }
187
+        this.users = [...this.users, { ...info, createdata: Date.parse(new Date()) }]
188
+        this.audios = [...this.audios, { ...info, isShow: true, createdata: Date.parse(new Date()) }]
189
+      }
190
+    },
191
+    audioEnd (index) {
192
+      this.audios = this.audios.slice().map((x, i) => {
193
+        if (i === index) {
194
+          x.isShow = false
195
+        }
196
+        return x
197
+      })
198
+    },
199
+    receviedMsg (e) {
200
+      const msg = e.data
201
+      if (!msg) {
202
+        return
203
+      }
204
+
205
+      const res = JSON.parse(e.data)
206
+      if (res.type && res.type === 'cmd') {
207
+        // 如果这种类型的消息, 说明是行为控制
208
+        switch (res.data) {
209
+          // 刷新数据
210
+          case 'refresh':
211
+            window.location.reload()
212
+            break
213
+          default:
214
+            break
215
+        }
216
+      } else {
217
+        this.newData({
218
+          name: !res.person.name ? '' : res.person.name,
219
+          classId: res.person.typeId,
220
+          words: res.taVisitingWords.words,
221
+          url: res.audio
222
+        })
223
+      }
224
+    },
225
+    init () { // 初始化
226
+      this.emptyPageDetail()
227
+      this.getDate()
228
+      this.getNewIndex({ id: this.$route.query.id, city: this.city })
229
+    },
230
+    getDate () { // 获取当前时间
231
+      let currentTime = Date.now()
232
+      let weekday = ['日', '一', '二', '三', '四', '五', '六']
233
+      let ChineseDate = solarLunar.lunar2solar(new Date(currentTime).getFullYear(), new Date(currentTime).getMonth(), new Date(currentTime).getDate())
234
+      this.currentWeek = `星期${weekday[new Date(currentTime).getDay()]}`
235
+      this.currentTime = `${new Date(currentTime).getHours().toString().padStart(2, '0')} : ${new Date(currentTime).getMinutes().toString().padStart(2, '0')} : ${new Date(currentTime).getSeconds().toString().padStart(2, '0')}`
236
+      this.currentDate = `${new Date(currentTime).getFullYear()}年${(new Date(currentTime).getMonth() + 1).toString().padStart(2, '0')}月${new Date(currentTime).getDate().toString().padStart(2, '0')}日`
237
+      this.currentChineseDate = `${ChineseDate.monthCn}${ChineseDate.dayCn}`
238
+    }
239
+  }
240
+}
241
+</script>
242
+
243
+<!-- Add "scoped" attribute to limit CSS to this component only -->
244
+<style lang="scss" scoped>
245
+.welcomePage {
246
+  $mainfontcolor: #000;
247
+  width: 100%;
248
+  height: 100%;
249
+  position: relative;
250
+  overflow: hidden;
251
+  background: url('../assets/images/welcome/bg.jpg') no-repeat center ;
252
+  background-size: 100% 100%;
253
+   .fade-item {
254
+    transition: all 1s;
255
+    display: inline-block;
256
+  }
257
+  .fade-enter,
258
+  .fade-leave-to {
259
+    opacity: 0;
260
+  }
261
+  .fade-leave-active {
262
+    position: absolute;
263
+  }
264
+  .welcome-con{
265
+   width: 100%;
266
+   height: 100%;
267
+   position: relative;
268
+    .welcome-img{
269
+      position: absolute;
270
+      width: 40vw;
271
+      height: 30vh;
272
+      top:40%;
273
+      margin-left: 12%;
274
+    }
275
+    .content{
276
+      width: 100%;
277
+      height: 100%;
278
+       .userList{
279
+        width: 100%;
280
+        height: 100%;
281
+        position: absolute;
282
+        top:88vh;
283
+        margin-left: 5vw;
284
+        li{
285
+          span{
286
+            width: 60%;
287
+            font-size: 6vw;
288
+            display: block;
289
+            text-align: center;
290
+          }
291
+        }
292
+    }
293
+    }
294
+  }
295
+}
296
+
297
+.marquee {
298
+  width: 100%;
299
+  position: absolute !important;
300
+  top: 0;
301
+  left: 0;
302
+  height: 48px !important;
303
+  z-index: 999 !important;
304
+  color: #fff;
305
+  letter-spacing: 0.05em;
306
+  line-height: 48px;
307
+  background-color: rgba(0, 0, 0, 0.7);
308
+  font-weight: 700;
309
+  border: none !important;
310
+  li{
311
+    span{
312
+      margin-right: 15px;
313
+    }
314
+  }
315
+
316
+  .font24 {
317
+    font-size: 24px;
318
+  }
319
+
320
+  ul {
321
+    list-style: none;
322
+    background: transparent;
323
+    width: max-content;
324
+  }
325
+
326
+  li {
327
+    display: inline;
328
+    & + li {
329
+      margin-left: 20px;
330
+      padding-left: 20px;
331
+      border-left: 1px solid #fff;
332
+    }
333
+  }
334
+
335
+  .shares-name {
336
+    color: #b49076;
337
+  }
338
+
339
+}
340
+</style>

+ 11
- 2
src/router/index.js 파일 보기

@@ -3,16 +3,25 @@ import Vue from 'vue'
3 3
 import Router from 'vue-router'
4 4
 // import test from '../pages/test'
5 5
 import page3 from '../pages/page3'
6
+import welcome from '../pages/welcome'
6 7
 
7 8
 Vue.use(Router)
8 9
 
9 10
 let router = new Router({
10
-  routes: [{
11
+  routes: [
12
+    {
11 13
     path: '/',
12 14
     name: 'index',
13 15
     component: page3,
14 16
     children: []
15
-  }]
17
+  },
18
+    {
19
+    path: '/welcome',
20
+    name: 'welcome',
21
+    component: welcome,
22
+    children: []
23
+  },
24
+]
16 25
 })
17 26
 
18 27
 router.beforeEach((to, from, next) => {