-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
105 lines (94 loc) · 3.25 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./css/reset.css">
<link rel="stylesheet" href="./css/common.css">
<link rel="stylesheet" href="./css/index.css">
</head>
<body>
<div class="index-content">
<header class="index-header white">
<div class="flex ai-center">
<h5 class="f-40">Chloe的家</h5>
<img class="down-icon ml-12" src="./images/down_2_icon.png" alt="">
</div>
<p class="f-26 show-btn mt-12"> 6台设备 </p>
<button class="add-btn">
<img src="./images//add_icon.png" alt="">
</button>
</header>
<nav class="index-nav f-28 c-gray f-weight">
<p class="nav-active">全部</p>
<p>卧室</p>
<p>书房</p>
<p>厨房</p>
<p>客厅</p>
<p>卫生间</p>
<img src="./images/down_1_icon.png" alt="">
</nav>
<div class="flex fl-wrap block-list"></div>
</div>
<!-- 底部tab -->
<div class="footer fl-ar">
<a href="#">
<img src="./images/home-a.png" alt="">
<p class="pink-1">首页</p>
</a>
<a href="./device.html">
<img src="./images/shebei-n.png" alt="">
<p>设备</p>
</a>
<a href="./mine.html">
<img src="./images/wode-n.png" alt="">
<p>我的</p>
</a>
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="./js/template-web.js"></script>
<!-- 定模模板 -->
<script id="tpl" type="text/html">
{{each data}}
<div class="block-icon">
<div class="flex f-weight j-s-b">
<p class="f-28 black-1">{{$value.title}}</p>
<p class="f-24 gray-90">{{$value.pos}}</p>
</div>
<div class="flex j-s-b al-center mt-40">
<img class="source" src="{{$value.source}}" alt="">
{{if $value.info}}
<div class="f-weight">
<p class="f-50">{{$value.info.PM2dot5}} <span class="green-1 f-30">{{$value.info.level}}</span></p>
<p class="f-24 gray-90"> PM2.5/1h</p>
</div>
{{else}}
<div class="close-btn {{$value.status ? 'is-open' : ''}}">
<img src="{{$value.status ? './images/close_1_icon.png' : './images/close_2_icon.png'}} " alt="">
</div>
{{/if}}
</div>
</div>
{{/each}}
</script>
<script>
$.ajax({
// 接口地址
url: "./data/data.json",
// q]请求方法:GET POST
method: "GET",
// 请求成功的回调函数
success: function (res) {
console.log(res)
render(res)
}
})
function render(res) {
var html = template("tpl", res)
$('.block-list').html(html)
}
</script>
</body>
</html>