管灌系统农户端微信小程序(嘉峪关应用)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
<!--pages/stationMonitor/stationMonitor.wxml-->
<view class="container">
  <!-- 顶部选项卡 -->
  <view class="tabs">
    <view class="tab {{activeTab === 'weather' ? 'active' : ''}}" bind:tap="switchTab" data-tab="weather">
      <image class="tab-icon" src="/images/weather.svg" />
      <text class="tab-name">气象站</text>
    </view>
 
    <view class="tab {{activeTab === 'soil' ? 'active' : ''}}" bind:tap="switchTab" data-tab="soil">
      <image class="tab-icon" src="/images/soil.svg" />
      <text class="tab-name">土壤墒情站</text>
    </view>
 
    <view class="tab {{activeTab === 'fertilizer' ? 'active' : ''}}" bind:tap="switchTab" data-tab="fertilizer">
      <image class="tab-icon" src="/images/fertilizer.svg" />
      <text class="tab-name">水肥机</text>
    </view>
 
    <view class="tab {{activeTab === 'camera' ? 'active' : ''}}" bind:tap="switchTab" data-tab="camera">
      <image class="tab-icon" src="/images/camera.svg" />
      <text class="tab-name">摄像头</text>
    </view>
  </view>
 
  <!-- 内容区域 -->
  <view class="content-area">
    <!-- 气象站内容 -->
    <view wx:if="{{activeTab === 'weather'}}" class="tab-content">
      <!-- <text class="content-title">气象站监测</text> -->
 
      <!-- 气象站选择下拉框 -->
      <view class="weather-station-selector">
        <picker bindchange="onWeatherStationChange" value="{{selectedWeatherStationIndex}}" range="{{weatherStationList}}" range-key="name">
          <view class="picker-container">
            <text class="picker-label">选择气象站:</text>
            <view class="picker-value">
              <text>{{weatherStationList[selectedWeatherStationIndex].name || '请选择气象站'}}</text>
              <image class="picker-arrow" src="/images/arrow-down.svg" />
            </view>
          </view>
        </picker>
      </view>
 
      <!-- 气象站信息卡片 -->
      <view wx:if="{{currentWeatherStation}}" class="weather-info-card">
        <!-- 状态栏 -->
        <view class="status-bar">
          <view class="status-item">
            <view class="status-indicator {{currentWeatherStation.onLine === true ? 'online' : 'offline'}}"></view>
            <text class="status-text">{{currentWeatherStation.onLine === true ? '在线' : '离线'}}</text>
          </view>
          <view class="refresh-btn" bind:tap="refreshWeatherData">
            <image class="refresh-icon" src="/images/refresh.svg" />
            <text class="refresh-text">刷新</text>
          </view>
        </view>
 
        <!-- 气象数据网格 -->
        <view class="weather-data-grid">
          <!-- 空气湿度 -->
          <view class="weather-data-item humidity">
            <view class="data-icon">
              <image src="/images/humidity.svg" />
            </view>
            <view class="data-content">
              <text class="data-label">空气湿度(%)</text>
              <text class="data-value">{{currentWeatherStation.humidity !== null && currentWeatherStation.humidity !== undefined ? currentWeatherStation.humidity : '--'}}%</text>
            </view>
          </view>
 
          <!-- 空气温度 -->
          <view class="weather-data-item temperature">
            <view class="data-icon">
              <image src="/images/temperature.svg" />
            </view>
            <view class="data-content">
              <text class="data-label">空气温度(℃)</text>
              <text class="data-value">{{currentWeatherStation.temperature !== null && currentWeatherStation.temperature !== undefined ? currentWeatherStation.temperature : '--'}}°C</text>
            </view>
          </view>
 
          <!-- 紫外线 -->
          <view class="weather-data-item uv">
            <view class="data-icon">
              <image src="/images/uv.svg" />
            </view>
            <view class="data-content">
              <text class="data-label">紫外线(mW/m²)</text>
              <text class="data-value">{{currentWeatherStation.uv !== null && currentWeatherStation.uv !== undefined ? currentWeatherStation.uv : '--'}}</text>
            </view>
          </view>
 
          <!-- 光照强度 -->
          <view class="weather-data-item light">
            <view class="data-icon">
              <image src="/images/light.svg" />
            </view>
            <view class="data-content">
              <text class="data-label">光照强度(lm/㎡)</text>
              <text class="data-value">{{currentWeatherStation.light !== null && currentWeatherStation.light !== undefined ? currentWeatherStation.light : '--'}} lux</text>
            </view>
          </view>
 
          <!-- 雨量 -->
          <view class="weather-data-item rainfall">
            <view class="data-icon">
              <image src="/images/rainfall.svg" />
            </view>
            <view class="data-content">
              <text class="data-label">雨量(mm)</text>
              <text class="data-value">{{currentWeatherStation.rainfall !== null && currentWeatherStation.rainfall !== undefined ? currentWeatherStation.rainfall : '--'}} mm</text>
            </view>
          </view>
 
          <!-- 风速 -->
          <view class="weather-data-item wind-speed">
            <view class="data-icon">
              <image src="/images/wind-speed.svg" />
            </view>
            <view class="data-content">
              <text class="data-label">风速(m/s)</text>
              <text class="data-value">{{currentWeatherStation.windSpeed !== null && currentWeatherStation.windSpeed !== undefined ? currentWeatherStation.windSpeed : '--'}} m/s</text>
            </view>
          </view>
 
          <!-- 风向 -->
          <view class="weather-data-item wind-direction">
            <view class="data-icon">
              <image src="/images/wind-direction.svg" />
            </view>
            <view class="data-content">
              <text class="data-label">风向</text>
              <view class="wind-direction-display">
                <!-- <image class="wind-arrow" src="/images/wind-arrow.svg" style="transform: rotate({{currentWeatherStation.windDirectionAngle || 0}}deg)" /> -->
                <text class="data-value">{{currentWeatherStation.windDirection !== null && currentWeatherStation.windDirection !== undefined ? currentWeatherStation.windDirection : '--'}}</text>
              </view>
            </view>
          </view>
        </view>
 
        <!-- 最后更新时间 -->
        <view class="last-update">
          <text class="update-text">最后更新:{{currentWeatherStation.lastUpdate || '--'}}</text>
        </view>
      </view>
 
      <!-- 无数据提示 -->
      <view wx:if="{{!currentWeatherStation}}" class="no-data">
        <image class="no-data-icon" src="/images/no-data.svg" />
        <text class="no-data-text">请选择气象站查看数据</text>
      </view>
    </view>
 
    <!-- 土壤墒情站内容 -->
    <view wx:elif="{{activeTab === 'soil'}}" class="tab-content">
      <!-- 土壤墒情站选择下拉框 -->
      <view class="weather-station-selector">
        <picker bindchange="onSoilStationChange" value="{{selectedSoilStationIndex}}" range="{{soilStationList}}" range-key="name">
          <view class="picker-container">
            <text class="picker-label">选择土壤墒情站:</text>
            <view class="picker-value">
              <text>{{soilStationList[selectedSoilStationIndex].name || '请选择土壤墒情站'}}</text>
              <image class="picker-arrow" src="/images/arrow-down.svg" />
            </view>
          </view>
        </picker>
      </view>
 
      <!-- 土壤墒情信息卡片 -->
      <view wx:if="{{currentSoilStation}}" class="weather-info-card">
        <!-- 状态栏 -->
        <view class="status-bar">
          <view class="status-item">
            <view class="status-indicator {{currentSoilStation.onLine === true ? 'online' : 'offline'}}"></view>
            <text class="status-text">{{currentSoilStation.onLine === true ? '在线' : '离线'}}</text>
          </view>
          <view class="refresh-btn" bind:tap="refreshSoilData">
            <image class="refresh-icon" src="/images/refresh.svg" />
            <text class="refresh-text">刷新</text>
          </view>
        </view>
 
        <!-- 土壤墒情数据网格 -->
        <view class="weather-data-grid">
          <!-- 土壤层1 -->
          <view class="weather-data-item soil-item">
            <view class="data-icon">
              <image src="/images/one.svg" />
            </view>
            <view class="data-content">
              <text class="data-label">土壤湿度1(%)</text>
              <text class="data-value">{{currentSoilStation.soilHumidity1 !== null && currentSoilStation.soilHumidity1 !== undefined ? currentSoilStation.soilHumidity1 : '--'}}%</text>
            </view>
          </view>
 
          <view class="weather-data-item soil-item">
            <view class="data-icon">
              <image src="/images/one.svg" />
            </view>
            <view class="data-content">
              <text class="data-label">土壤温度1(℃)</text>
              <text class="data-value">{{currentSoilStation.soilTemperature1 !== null && currentSoilStation.soilTemperature1 !== undefined ? currentSoilStation.soilTemperature1 : '--'}}°C</text>
            </view>
          </view>
 
          <!-- 土壤层2 -->
          <view class="weather-data-item soil-item">
            <view class="data-icon">
              <image src="/images/two.svg" />
            </view>
            <view class="data-content">
              <text class="data-label">土壤湿度2(%)</text>
              <text class="data-value">{{currentSoilStation.soilHumidity2 !== null && currentSoilStation.soilHumidity2 !== undefined ? currentSoilStation.soilHumidity2 : '--'}}%</text>
            </view>
          </view>
 
          <view class="weather-data-item soil-item">
            <view class="data-icon">
              <image src="/images/two.svg" />
            </view>
            <view class="data-content">
              <text class="data-label">土壤温度2(℃)</text>
              <text class="data-value">{{currentSoilStation.soilTemperature2 !== null && currentSoilStation.soilTemperature2 !== undefined ? currentSoilStation.soilTemperature2 : '--'}}°C</text>
            </view>
          </view>
 
          <!-- 土壤层3 -->
          <view class="weather-data-item soil-item">
            <view class="data-icon">
              <image src="/images/three.svg" />
            </view>
            <view class="data-content">
              <text class="data-label">土壤湿度3(%)</text>
              <text class="data-value">{{currentSoilStation.soilHumidity3 !== null && currentSoilStation.soilHumidity3 !== undefined ? currentSoilStation.soilHumidity3 : '--'}}%</text>
            </view>
          </view>
 
          <view class="weather-data-item soil-item">
            <view class="data-icon">
              <image src="/images/three.svg" />
            </view>
            <view class="data-content">
              <text class="data-label">土壤温度3(℃)</text>
              <text class="data-value">{{currentSoilStation.soilTemperature3 !== null && currentSoilStation.soilTemperature3 !== undefined ? currentSoilStation.soilTemperature3 : '--'}}°C</text>
            </view>
          </view>
 
          <!-- 土壤层4 -->
          <view class="weather-data-item soil-item">
            <view class="data-icon">
              <image src="/images/four.svg" />
            </view>
            <view class="data-content">
              <text class="data-label">土壤湿度4(%)</text>
              <text class="data-value">{{currentSoilStation.soilHumidity4 !== null && currentSoilStation.soilHumidity4 !== undefined ? currentSoilStation.soilHumidity4 : '--'}}%</text>
            </view>
          </view>
 
          <view class="weather-data-item soil-item">
            <view class="data-icon">
              <image src="/images/four.svg" />
            </view>
            <view class="data-content">
              <text class="data-label">土壤温度4(℃)</text>
              <text class="data-value">{{currentSoilStation.soilTemperature4 !== null && currentSoilStation.soilTemperature4 !== undefined ? currentSoilStation.soilTemperature4 : '--'}}°C</text>
            </view>
          </view>
 
          <!-- 土壤层5 -->
          <view class="weather-data-item soil-item">
            <view class="data-icon">
              <image src="/images/five.svg" />
            </view>
            <view class="data-content">
              <text class="data-label">土壤湿度5(%)</text>
              <text class="data-value">{{currentSoilStation.soilHumidity5 !== null && currentSoilStation.soilHumidity5 !== undefined ? currentSoilStation.soilHumidity5 : '--'}}%</text>
            </view>
          </view>
 
          <view class="weather-data-item soil-item">
            <view class="data-icon">
              <image src="/images/five.svg" />
            </view>
            <view class="data-content">
              <text class="data-label">土壤温度5(℃)</text>
              <text class="data-value">{{currentSoilStation.soilTemperature5 !== null && currentSoilStation.soilTemperature5 !== undefined ? currentSoilStation.soilTemperature5 : '--'}}°C</text>
            </view>
          </view>
        </view>
 
        <!-- 最后更新时间 -->
        <view class="last-update">
          <text class="update-text">最后更新:{{currentSoilStation.lastUpdate || '--'}}</text>
        </view>
      </view>
 
      <!-- 无数据提示 -->
      <view wx:if="{{!currentSoilStation}}" class="no-data">
        <image class="no-data-icon" src="/images/no-data.svg" />
        <text class="no-data-text">请选择土壤墒情站查看数据</text>
      </view>
    </view>
 
    <!-- 水肥机内容 -->
    <view wx:elif="{{activeTab === 'fertilizer'}}" class="tab-content">
      <!-- <text class="content-title">水肥机监测</text> -->
 
      <!-- 水肥机选择下拉框 -->
      <view class="fertilizer-station-selector">
        <picker bindchange="onFertilizerStationChange" value="{{selectedFertilizerStationIndex}}" range="{{fertilizerStationList}}" range-key="name">
          <view class="picker-container">
            <text class="picker-label">选择水肥机:</text>
            <view class="picker-value">
              <text>{{fertilizerStationList[selectedFertilizerStationIndex].name || '请选择水肥机'}}</text>
              <image class="picker-arrow" src="/images/arrow-down.svg" />
            </view>
          </view>
        </picker>
      </view>
 
      <!-- 水肥机信息卡片 -->
      <view wx:if="{{currentFertilizerStation}}" class="fertilizer-info-card">
        <!-- 状态栏 -->
        <view class="status-bar">
          <view class="status-item">
            <view class="status-indicator {{currentFertilizerStation.onLine === true ? 'online' : 'offline'}}"></view>
            <text class="status-text">{{currentFertilizerStation.onLine === true ? '在线' : '离线'}}</text>
          </view>
          <view class="refresh-btn" bind:tap="refreshFertilizerData">
            <image class="refresh-icon" src="/images/refresh.svg" />
            <text class="refresh-text">刷新</text>
          </view>
        </view>
 
        <!-- 控制开关区域 -->
        <view class="control-switches">
          <text class="section-title">控制开关</text>
          <view class="switch-container">
            <!-- 搅拌开关 -->
            <view class="switch-item">
              <text class="switch-label">搅拌</text>
              <switch class="custom-switch" checked="{{currentFertilizerStation.mixingEnabled}}" bindchange="toggleMixing" disabled="{{currentFertilizerStation.onLine !== true}}" color="#07c160" />
            </view>
 
            <!-- 注肥开关 -->
            <view class="switch-item">
              <text class="switch-label">注肥</text>
              <switch class="custom-switch" checked="{{currentFertilizerStation.fertilizingEnabled}}" bindchange="toggleFertilizing" disabled="{{currentFertilizerStation.onLine !== true}}" color="#07c160" />
            </view>
          </view>
        </view>
 
        <!-- 监测数据区域 -->
        <view class="monitoring-data">
          <text class="section-title">监测数据</text>
          <view class="data-grid">
            <!-- 注肥泵状态 -->
            <view class="data-item pump-status custom-pump-row">
              <view class="data-icon">
                <image src="/images/custompump.svg" />
              </view>
              <view class="data-content">
                <text class="data-label">注肥泵状态</text>
                <text class="data-value {{currentFertilizerStation.alarm === 1 ? 'alarm' : 'normal'}}">
                  {{currentFertilizerStation.alarm === 1 ? '报警' : '正常'}}
                </text>
              </view>
              <button wx:if="{{currentFertilizerStation.alarm === 1}}" 
                      class="clear-fault-btn" 
                      bind:tap="clearAlarm" 
                      size="mini">
                清除报警
              </button>
            </view>
 
            <!-- 肥料流量 -->
            <view class="data-item waste-flow">
              <view class="data-icon">
                <image src="/images/flow.svg" />
              </view>
              <view class="data-content">
                <text class="data-label">肥料流量(升)</text>
                <text class="data-value">{{currentFertilizerStation.manureFlow !== null && currentFertilizerStation.manureFlow !== undefined ? currentFertilizerStation.manureFlow : '--'}} L</text>
              </view>
            </view>
 
            <!-- 注肥时长 -->
            <view class="data-item fertilizing-duration">
              <view class="data-icon">
                <image src="/images/timer.svg" />
              </view>
              <view class="data-content">
                <text class="data-label">注肥时长(秒)</text>
                <text class="data-value">{{currentFertilizerStation.manureTime !== null && currentFertilizerStation.manureTime !== undefined ? currentFertilizerStation.manureTime : '--'}} s</text>
              </view>
            </view>
 
            <!-- 搅拌时长 -->
            <view class="data-item mixing-duration">
              <view class="data-icon">
                <image src="/images/mixing.svg" />
              </view>
              <view class="data-content">
                <text class="data-label">搅拌时长(秒)</text>
                <text class="data-value">{{currentFertilizerStation.stirTime !== null && currentFertilizerStation.stirTime !== undefined ? currentFertilizerStation.stirTime : '--'}} s</text>
              </view>
            </view>
 
            <!-- 搅拌设定时间 -->
            <view class="data-item mixing-set-time">
              <view class="data-icon">
                <image src="/images/settings.svg" />
              </view>
              <view class="data-content">
                <text class="data-label">搅拌设定时间(秒)</text>
                <text class="data-value">{{currentFertilizerStation.stirDuration !== null && currentFertilizerStation.stirDuration !== undefined ? currentFertilizerStation.stirDuration : '--'}} s</text>
              </view>
            </view>
 
            <!-- 注肥设定时间 -->
            <view class="data-item fertilizing-set-time">
              <view class="data-icon">
                <image src="/images/settings-time.svg" />
              </view>
              <view class="data-content">
                <text class="data-label">注肥设定时间(秒)</text>
                <text class="data-value">{{currentFertilizerStation.injectDuration !== null && currentFertilizerStation.injectDuration !== undefined ? currentFertilizerStation.injectDuration : '--'}} s</text>
              </view>
            </view>
          </view>
        </view>
 
        <!-- 最后更新时间 -->
        <view class="last-update">
          <text class="update-text">最后更新:{{currentFertilizerStation.dt || currentFertilizerStation.lastUpdate || '--'}}</text>
        </view>
      </view>
 
      <!-- 无数据提示 -->
      <view wx:if="{{!currentFertilizerStation}}" class="no-data">
        <image class="no-data-icon" src="/images/no-data.svg" />
        <text class="no-data-text">请选择水肥机查看数据</text>
      </view>
    </view>
 
    <!-- 摄像头内容 -->
    <view wx:elif="{{activeTab === 'camera'}}" class="tab-content">
      <!-- <text class="content-title">摄像头监控</text> -->
 
      <!-- 摄像头列表 -->
      <view class="camera-list">
        <view wx:for="{{cameraList}}" wx:key="id" class="camera-item">
          <!-- 摄像头名称 -->
          <view class="camera-header">
            <text class="camera-name">{{item.name}}</text>
            <view class="camera-status {{item.onLine === true ? 'online' : 'offline'}}">
              <text>{{item.onLine === true ? '在线' : '离线'}}</text>
            </view>
          </view>
 
          <!-- 摄像头视频 -->
          <view class="camera-video-container" >
            <!-- 加载状态 -->
            <view wx:if="{{item.isLoadingUrl}}" class="video-loading">
              <view class="loading-spinner"></view>
              <text class="loading-text">正在获取播放地址...</text>
            </view>
 
            <!-- 错误状态 -->
            <view wx:elif="{{item.urlError}}" class="video-error">
              <image class="error-icon" src="/images/error.svg" />
              <text class="error-text">设备离线</text>
              <!-- <button class="retry-btn" bind:tap="retryGetHlsUrl" data-camera="{{item}}">
                <image class="retry-icon" src="/images/refresh.svg" />
                <text>重试</text>
              </button> -->
            </view>
 
            <!-- 正常播放状态 -->
            <view wx:elif="{{item.onLine && item.hslUrl}}" class="video-wrapper">
              <!-- 直播播放器组件 -->
              <ezplayer class="video-wrapper-ezplayer" id="ezplayer-{{item.id}}" accessToken="{{item.accessToken}}" url="{{item.hslUrl}}" deviceSerial="{{item.deviceSerial}}" channelNo="1" plugins="capture,ptz,mirror" watermark="大禹" autoPlay="{{true}}" theme="{{ { showFullScreenBtn: true, showHdBtn: true, showTimeLine: true } }}" bind:handleError="handleError" bind:onControlEvent="onControlEvent" />
            </view>
 
            <!-- 离线状态显示 -->
            <view wx:elif="{{!item.onLine}}" class="video-offline">
              <image class="offline-icon" src="/images/camera.svg" />
              <text class="offline-text">设备离线</text>
            </view>
 
            <!-- 无播放地址状态 -->
            <view wx:else class="video-no-url">
              <image class="no-url-icon" src="/images/camera.svg" />
              <text class="no-url-text">暂无播放地址</text>
            </view>
          </view>
 
 
        </view>
      </view>
 
      <!-- 无数据提示 -->
      <view wx:if="{{cameraList.length === 0}}" class="no-data">
        <image class="no-data-icon" src="/images/no-data.svg" />
        <text class="no-data-text">暂无摄像头设备</text>
      </view>
    </view>
  </view>
</view>