-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.php
192 lines (170 loc) · 6.76 KB
/
home.php
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>主页</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="css/sm.min.css">
<link rel="stylesheet" href="css/sm-extend.min.css">
<link rel="stylesheet" href="css/common.css">
<link rel="stylesheet" href="css/home.css">
<script src="js/jquery-3.0.0.js"></script>
<script src="js/vue.min.js"></script>
<link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
</head>
<body>
<div class="page">
<header class="bar bar-nav">
<h1 class="title">主页</h1>
</header>
<?php
$cookie = isset($_COOKIE['identity'])?$_COOKIE['identity']:null;
if($cookie == null){
echo '<script>alert("请先登录!");location.href="login.html"</script>';
}
else if($cookie == 1){
echo '<nav class="bar bar-tab">
<a class="tab-item external active" href="home.php">
<span class="icon icon-home"></span>
<span class="tab-label">主页</span>
</a>
<a class="tab-item external" href="account-management.php">
<span class="icon icon-edit"></span>
<span class="tab-label">账目</span>
</a>
<a class="tab-item external" href="both-management.php">
<span class="icon icon-settings"></span>
<span class="tab-label">管理</span>
</a>
<a class="tab-item external" href="me.php">
<span class="icon icon-me"></span>
<span class="tab-label">我</span>
</a>
</nav>';
}
else if($cookie == 2){
echo '<nav class="bar bar-tab">
<a class="tab-item external active" href="home.php">
<span class="icon icon-home"></span>
<span class="tab-label">主页</span>
</a>
<a class="tab-item external" href="account-management.php">
<span class="icon icon-edit"></span>
<span class="tab-label">账目</span>
</a>
<a class="tab-item external" href="admin-management.php">
<span class="icon icon-settings"></span>
<span class="tab-label">管理</span>
</a>
<a class="tab-item external" href="me.php">
<span class="icon icon-me"></span>
<span class="tab-label">我</span>
</a>
</nav>';
}
else if($cookie == 3){
echo '<nav class="bar bar-tab">
<a class="tab-item external active" href="home.php">
<span class="icon icon-home"></span>
<span class="tab-label">主页</span>
</a>
<a class="tab-item external" href="me.php">
<span class="icon icon-me"></span>
<span class="tab-label">我</span>
</a>
</nav>';
}
?>
<div class="content">
<div class="card">
<div class="card-content">
<div class="card-content-inner">
<i class="fa fa-shopping-bag"></i>
账户余额
<span class="money-rest">¥ <span id="restMoney"></span></span>
</div>
</div>
</div>
<div class="content-block-title">最近账单</div>
<div class="list-block media-list">
<ul id="list">
<li v-for="item in items">
<form action="account-detail.php" method="post">
<a class="item-link item-content submit">
<input type="hidden" :value="item.id" name="id">
<div class="item-inner">
<div class="item-subtitle">{{item.time}}</div>
<div class="item-title-row">
<div class="item-title">{{item.title}}</div>
<input type="hidden" :value="item.type">
<div class="item-after">¥<span class="money">{{item.money}}</span></div>
</div>
<div class="item-text detail">{{item.detail}}</div>
</div>
</a>
</form>
</li>
</ul>
</div>
</div>
<script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
<script type='text/javascript' src='js/sm.min.js' charset='utf-8'></script>
<script type='text/javascript' src='js/sm-extend.min.js' charset='utf-8'></script>
<script>
//获取余额并显示
jQuery('#restMoney').load('management-account.php?action=getRest');
//获取总览信息
jQuery.get('management-account.php?action=getTotal',function (data) {
if(data==='SQL执行失败0'){
return false;
}
console.log(data);
var totalData=JSON.parse(data);
console.log(totalData);
var getData=new Vue({
el:'#list',
data:{
items:totalData
}
});
//过滤金额颜色及正负
function filter() {
var items=document.getElementsByClassName('money');
for(var i=0;i<items.length;i++){
if(items[i].parentNode.previousSibling.previousSibling.value==='1'){
items[i].className='money money-income';
items[i].innerText='+ '+items[i].innerText;
}
else{
items[i].className='money money-expend';
items[i].innerText='- '+items[i].innerText;
}
}
}
filter();
//简介截取一定字符显示
(function () {
var items = document.getElementsByClassName('detail');
for(var i = 0;i<items.length;i++){
if(items[i].innerText.length>12){
items[i].innerText=items[i].innerText.substring(0,12)+'....';
}
}
})();
//给所有项目加上提交功能
(function () {
var items = document.getElementsByClassName('submit');
for(var i = 0;i<items.length;i++){
items[i].onclick=function () {
console.log("in");
this.parentNode.submit();
}
}
})();
});
</script>
</body>
</html>