detailAlert_frm.html
16.4 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>设备详情弹窗</title>
<link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/api.css"/>
<link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/aui.css"/>
<link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/home.css"/>
<link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/element.css"/>
<link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/style.css"/>
<style>
html,
body{
background: rgba(0, 0, 0, 0);
}
</style>
</head>
<body>
<div id="app" >
<div class="device-detail-white-area">
<el-row class="device-alert-title">
<el-col :span=20>
<span class="store-name" >设备编号:{{ pageInfos.imei }}</span>
</el-col>
<el-col :span=4>
<div class="device-status-online" v-if="pageInfos.status">
<span>在线</span>
</div>
<div class="device-status-offline" v-if="!pageInfos.status">
<span>离线</span>
</div>
</el-col>
</el-row>
<div style="background:rgba(247,249,252,1);">
<el-row class="device-alert-params-area">
<div v-if="bind_list_data_params.length > 0" class="device-alert-params-inside-area" v-for="(list_d, list_i) in bind_list_data_params">
<el-col v-if="list_d.name.length <= 6" :span=10 class="device-alert-params-details">
{{ list_d.name }} <span style="color:rgba(51,51,51,1);">{{ list_d.value }}</span>
</el-col>
<el-col v-else :span=22 class="device-alert-params-details">
{{ list_d.name }} <span style="color:rgba(51,51,51,1);">{{ list_d.value }}</span>
</el-col>
<el-col :span=2>
<div v-show="editVisable">
<!-- fix bug -->
<img :id= "'selectPic_'+list_i" :src="list_d.showPicUrl" class="devie-alert-detail-img" @click="handleIndexParams(list_d.type, list_d.id, list_d.showing, list_i)"/>
</div>
<!-- <div v-if="!editVisable"> </div> -->
</el-col>
<!-- <el-col :span=10 class="device-alert-params-details">
电流 <span style="color:rgba(51,51,51,1);">12.8A</span>
</el-col>
<el-col :span=2>
<img src="../../image/icon_unselected_sm.png" class="devie-alert-detail-img" />
</el-col> -->
</div>
</el-row>
<div class="device-alert-params-line"></div>
<el-row style="padding-bottom: 10.5px;">
<el-col :span=18 :offset=2><span v-if="editVisable" tapmode class="device-alert-params-submit-info">勾选需要在首页展示的信息</span> </el-col>
<el-col :span=4>
<span v-if="editVisable" class="device-alert-params-submit-text" tapmode @click="editParams(false)">确定</span>
<span v-else class="device-alert-params-submit-text" tapmode @click="editParams(true)">编辑</span>
</el-col>
</el-row>
</div>
<div id="device_other_area"></div>
<div id="bottom_text" class="detail-alert-botton-text" tapmode @click="showProductPage">查看更多信息→</div>
</div>
</div>
<!-- <script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/element.js"></script>
<script type="text/javascript" src="../../script/ctrl.js"></script>
<script type="text/javascript" src="../../script/fastclick.js "></script> -->
<script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/api.js"></script>
<script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/vue.min.js"></script>
<script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/common.js"></script>
<script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/element.js"></script>
<script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/ctrl.js"></script>
<script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/fastclick.js "></script>
</body>
<script type="text/javascript">
var vm;
apiready = function(){
$(function() {
FastClick.attach(document.body);
});
$api.css($api.byId('app'), 'height:'+api.frameHeight+'px;')
api.parseTapmode();
//---------初始化vue
vm = new Vue({
el: '#app',
data: {
pageInfos: {},
userId: api.getPrefs({sync: true,key: 'userID'}),
token: api.getPrefs({sync: true,key: 'userToken'}),
userPreferenceList: [],
bind_list: {
user_id: "",
params: {},
type: "",
imei: "",
limit: 1,
page: 1
},
bind_list_data: [],
bind_list_data_params: [],
editVisable: false,
selectedPic: "http://iot.uccc.cc:9090/product/01001/icon_selected_sm.png",
unselectPic: "http://iot.uccc.cc:9090/product/01001/icon_unselected_sm.png",
indexParamsTemp: {},
product_id: "",
},
mounted() {
//window.chooseProduct = this.chooseProduct;
},
created() {
this.pageInfos = api.pageParam.value
this.initPages() //一定在initDetailParams执行完毕后执行openOperaterAndAlarm
},
methods: {
initPages() {
this.initDetailParams().then(val => {
this.openOperaterAndAlarm()
})
//调试
// setTimeout(() => {
// this.showProductPage()
// }, 4000);
//-----
},
async initDetailParams() {
var user_perference = await get_product_perference(this.userId)
console.log(JSON.stringify(user_perference));
this.userPreferenceList = user_perference.data
this.bind_list_data = []
for (let i = 0; i < this.userPreferenceList.length; i++) {
const productPref = JSON.parse(this.userPreferenceList[i]);
const prefList = []
productPref.data_detail.forEach(d => {
prefList.push('"'+d+'"')
});
eval('this.bind_list.params["' + productPref.name +'"]=[' + prefList + ']')
}
this.bind_list.user_id = this.userId
this.bind_list.imei = this.pageInfos.imei
this.bind_list.token = this.token
// console.log(JSON.stringify(this.bind_list));
let bind_list_data_ = await get_bind_list_data(this.bind_list)
let props_ = api.getPrefs({sync: true,key: 'props'})
let props = eval('(' + props_ + ')');
list_rows = bind_list_data_.data.list.rows
this.product_id = list_rows[0].store.storeType.id
list_rows.forEach(d => {
if (d.store.storeType.id === '01001') {
let deviceInfos = {
pic_url: d.store.storeType.pic_url,
imei: d.imei,
name: d.store.storeType.name,
storename: d.storename,
detailParams: [{name: "电流", type: "etc_current", value: d.store.etc_current+"A"},
{name: "剩余电流", type: "etc_rest_current", value: d.store.etc_rest_current+"mA"},
{name: "电压", type: "etc_voltage", value: d.store.etc_voltage+"V"},
{name: "频率", type:"etc_rate", value: d.store.etc_rate+"Hz"},
{name: "线缆温度", type:"etc_line_temp", value: d.store.etc_line_temp+"℃"},
{name: "内部温度", type:"etc_temp1", value: d.store.etc_temp1+"℃"}],
status: d.online,
}
if (d.store.gate_status === "1") {
deviceInfos.gate_status = true
}else if (d.store.gate_status === "0") {
deviceInfos.gate_status = false
}else{
deviceInfos.gate_status = null
}
this.bind_list_data.push(deviceInfos)
}else {
const detailParams_ = []
let json_ = eval('d.store.store' + d.store.storeType.id )
// for (let i = 0; i < json_.length; i++) {
for(var key in json_){
props.forEach(p => {
if (d.store.storeType.id === p.type_id && key === p.col_name) {
let v_ = eval('d.store.store' + d.store.storeType.id + '.' + key)
detailParams_.push({name: p.title, type: key, value: v_ + p.unit, id: p.id})
}
});
}
const gate_status = eval('d.store.store' + d.store.storeType.id + '.switch')
let normalInfos = {
pic_url: d.store.storeType.pic_url,
imei: d.imei,
name: d.store.storeType.name,
storename: d.storename,
detailParams: detailParams_,
status: d.online,
gate_status: gate_status,
}
this.bind_list_data.push(normalInfos)
}
})
this.bind_list_data_params = this.bind_list_data[0].detailParams
indexParams_ = this.pageInfos.indexParams
this.bind_list_data_params.forEach(d => {
d.showing = false
d.showPicUrl = this.unselectPic
indexParams_.forEach(e => {
if (d.type === e.type) {
d.showing = true
d.showPicUrl = this.selectedPic
eval('this.indexParamsTemp["' + d.id + '"] = "' + d.type + '"')
}
})
})
},
async editParams(bool) {
this.editVisable = bool
if (!bool) { //保存首页偏好
if (this.product_id != '01001') {
const params = {
user_id: this.userId,
product_id: this.product_id,
show_counts: Object.keys(this.indexParamsTemp).length,
params: this.indexParamsTemp,
detail_show_counts: -1,
detail_params: {}
}
// console.log(JSON.stringify(params));
var result = await post_create_update_user_perference(params)
api.toast({msg: '修改成功!',duration: 2000,location: 'bottom'});
api.sendEvent({
name: 'change_device',
});
}else {
api.toast({msg: '无效操作,当前产品不支持修改!',duration: 2000,location: 'bottom'});
}
}else {
this.initDetailParams()
}
},
handleIndexParams(type, id, showing, index) {
if (!showing) { //点击未选择的图片,即为 选择
this.bind_list_data_params[index].showing = true
this.bind_list_data_params[index].showPicUrl = this.selectedPic
$api.byId('selectPic_' + index).src = this.selectedPic
eval('this.indexParamsTemp["' + id + '"] = "' + type + '"')
const param = {
name: this.bind_list_data_params[index].name,
type: type,
value: this.bind_list_data_params[index].value
}
this.pageInfos.indexParams.push(param)
}else {
this.bind_list_data_params[index].showing = false
this.bind_list_data_params[index].showPicUrl = this.unselectPic
$api.byId('selectPic_' + index).src = this.unselectPic;
delete this.indexParamsTemp[id];
for (let i = 0; i < this.pageInfos.indexParams.length; i++) {
const element = this.pageInfos.indexParams[i];
if (element.type === type) {
this.pageInfos.indexParams.splice(i, 1);
}
}
}
},
openOperaterAndAlarm() {
setTimeout(() => {
let offset = $api.offset($api.byId('device_other_area'));
let top = offset.t;
let left = offset.l;
let width = offset.w;
let height = offset.h;
api.sendEvent({
name: 'operate_and_alert_page',
extra: {url: 'store_'+this.product_id+'operateHtml'}
});
//这里以后全部是配置对应的http地址...
let url_ = ''
if (this.product_id === '01001' || this.product_id === '02001') {
url_ = 'http://iot.uccc.cc:9090/app_html/store'+this.product_id+'/operateFun.html'
}else {
url_ = '../projects/store_' + this.product_id + '/' + 'operateFun.html'
}
api.openFrame({
name: 'store_'+this.product_id+'operateHtml',
url: url_,
bounces: false,
rect: {
x: api.winWidth/11,
y: api.winHeight/8 + top ,
w: api.winWidth- (api.winWidth/11) *2,
h: api.frameHeight- top - 30,
},
pageParam: {
imei: this.pageInfos.imei,
userId: this.userId,
token: this.token,
status: this.pageInfos.status,
deviceType: this.pageInfos.name,
},
vScrollBarEnabled: true,
animation: {
type:"push",
subType:"from_right",
duration:300
}
});
}, 300);
},
showProductPage() {
// let res = await get_alert_html_str(api.pageParam.value.storeType)
//这里以后全部是配置对应的http地址...
//测试写法--start
let url_ = ''
// if (this.product_id === '01001' || this.product_id === '02001') {
url_ = 'http://iot.uccc.cc:9090/app_html/store'+this.product_id+'/index_win.html'
// }else {
// url_ = '../projects/store_' + this.product_id + '/' + 'index_win.html'
// }
//测试写法--end
//正式写法--start
// url_ = 'http://iot.uccc.cc:9090/app_html/store'+this.product_id+'/index_win.html'
//正式写法--end
api.openWin({
name: 'store_' + this.product_id + '_indexWin',
url: url_,
// url: 'http://iot.uccc.cc:9090/app_html/store01001/index_win.html',
bounces: false,
pageParam: {imei : this.pageInfos.imei,
productId: this.product_id}
});
}
}
})
};
</script>
</html>