tom
2023-12-06 9e968679ed2e6937aeb7b50a6c450d5d19251f42
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
var info={}, oAccount;
 
$(document).ready( onDocumentReady );
 
function onDocumentReady() {
    Origami.fastclick(document.body);
    $("#file_picture").change(picturePrepare);
    $("#img_headimg").click(pictureChoose);
    pageInit(showInfo);    
}
 
function onVersionResponse(res) {
    if (res.require_upgrade) {
        showConfirm("请下载更新APP至版本"+res.server_version+"<br>(当前版本"+res.client_version+")", "location.href='setting.html';");
    }
}
 
function showEmployee() {
    menuSwitch("employee");
    loadEmployee();
}
 
function loadEmployee() {
    jsonRequest("login", "load_employee_list", {}, onEmployeeResponse);
}
 
function onEmployeeResponse(res) {
    var html="";
    for (var i=0; i<res.employee_list.length; i++) {
        var t=res.employee_list[i];
        var action=t.allow_simulation?"confirmEmployeeSimulate('"+res.employee_list[i].uid+"')":"alertMessage('没有权限演示该账户')";
        html+=div("div_employee_"+(t.current_simulation?"on":"off"), 
            img("img_employee_headimg", t.headimg)+
            div("div_employee_name", t.name)+
            div("div_employee_code", t.code)+
            div("div_employee_title", t.title)+
            div("div_employee_level", t.level), action);
    }
    $("#div_employee_list").html(html);
}
 
function confirmEmployeeSimulate(uid) {
    var req={employee_uid:uid};
    jsonRequest("login", "do_employee_simulate", req, onEmployeeSimulateResponse);
}
 
function onEmployeeSimulateResponse(res) {
    alertMessage("已切换演示账户");
    sessionStorage.setItem("account", JSON.stringify(res.account));
    pageBack();
}    
 
function goLogin() {
    location.href="login.html";
}
 
function goAccount() {
    location.href="login.html?account=1";
}
 
function goDownload() {
    var iosURL='itms-services://?action=download-manifest&url=https%3A%2F%2Fwww.pgyer.com%2Fapiv1%2Fapp%2Fplist%3FaId%3D27d1c2fed38dbd7a2775d701901c348b%26_api_key%3D6eab3e0d9d8522c6efa56e1b8d28e342';
    var androidURL='http://www.pgyer.com/apiv1/app/install?aId=509769215fd4762fffe7778c67e8d21d&_api_key=6eab3e0d9d8522c6efa56e1b8d28e342';
    var downloadURL="";
    if (isAgent("android")) {
        downloadURL=androidURL;
    } else if (isAgent("iphone os") || isAgent("ipad")) {
        downloadURL=iosURL;
    } else {
        alertMessage("请在移动设备上下载APP");
        return;
    }
 
    if (window.device) {
        loadMessage("正在连接应用商店");
        window.open(downloadURL, '_system', 'location=yes');
    } else if (isAgent("micromessenger")) {
        weixinGuide();
    } else {
        if (isAgent("iphone os") || isAgent("ipad")) {
            $("#page_ios").fadeIn();
        }
        location.href=downloadURL;
    }    
}
 
function clearStorage() {
    localStorage.clear();
    sessionStorage.clear();
    alertMessage("手机存储参数已清除");
}
 
function toggleOption(name) {
    var s=localStorage.getItem(name);
    if (s) {
        localStorage.removeItem(name);
    } else {
        localStorage.setItem(name, "1");
    }
}
 
function showInfo() {
    menuSwitch("info");
    loadInfo();
}
 
function refreshInfo() {
    var html="";
    for (var i in info) {
        html+=div("div_property_title", info[i].title);
        for (var j in info[i].property) {
            html+=div("div_property_row",
                div("div_property_label", info[i].property[j].label)+div("div_property_content", info[i].property[j].content));
        }
    }
    html+=div("div_property_title", "系统选项");
    html+=div("div_property_row",
            div("div_property_label", "手机存储") + div("div_property_content", "清除"), "clearStorage(); loadInfo();");
    var visual=localStorage.getItem("visual_aid")=="1"?"已启用":"已关闭";
    html+=div("div_property_row",
            div("div_property_label", "点击效果") + div("div_property_content", visual), "toggleOption('visual_aid'); loadInfo(); ");
    var local=localStorage.getItem("local_server")=="1"?"本地调试服务器":"远程生产服务器";
    html+=div("div_property_row",
            div("div_property_label", "服务器") + div("div_property_content", local), "toggleOption('local_server'); loadInfo(); ");
    $("#div_info").html(html);
}
 
function addInfo(i, s, v) {
    if (v) {
        info[i].property.push({label:s, content:v});
    } else {
        info[i]={};
        info[i].title=s;
        info[i].property=[];
    }
}
            
function loadInfo() {
    addInfo("account", "账户信息");
    addInfo("employee", "员工信息");
    addInfo("app", "应用信息");
    addInfo("app", "发布日期", clientDate);
    addInfo("app", "当前版本", clientVersion);
    
    addInfo("device", "设备信息");
    var screen=$(window).width()+" x "+$(window).height();
    addInfo("device", "屏幕", screen);
    if (window.device) {
        addInfo("device", "系统", device.platform);
        addInfo("device", "版本", device.version);
        addInfo("device", "型号", device.model);
        addInfo("device", "序号", device.uuid);
    } else {
        addInfo("device", "系统", navigator.platform);
    }
    var agent=navigator.userAgent.replace(/\)/g, ")<br>");
    addInfo("device", "浏览器", agent);
    
    addInfo("network", "网络信息");
    var status=navigator.onLine?"已连接":"未连接";
    addInfo("network", "状态", status);
    if (navigator.connection) {
        addInfo("network", "类型", navigator.connection.type);
    }
    addInfo("network", "界面", location.href);
    addInfo("network", "服务器", jsonURL);
    var access="网页版";
    if (isAgent("micromessenger")) {
        access="微信版";
    } else if (window.device) {
        access="APP版";
    }
    addInfo("network", "访问方式", access);
 
    addInfo("location", "地理位置信息");
    addInfo("storage", "手机存储信息");
    for(var i=0; i<localStorage.length; i++){
        if (localStorage.key(i).substr(0,4)!="BMap") {
            addInfo("storage", "L." + localStorage.key(i), localStorage.getItem(localStorage.key(i)));
        }
    }
    for(var i=0; i<sessionStorage.length; i++){
        addInfo("storage", "S." + sessionStorage.key(i), sessionStorage.getItem(sessionStorage.key(i)));
    }
    refreshInfo();
    loadPosition(showPosition);
 
    jsonRequest("login", "load_info", {}, onInfoResponse);
}
 
function showPosition () {
    var pos=getPosition();
    addInfo("location", "经度", pos.longitude || "未知");
    addInfo("location", "纬度", pos.latitude || "未知");
    addInfo("location", "高度", pos.altitude || "未知");
    addInfo("location", "精度", pos.accuracy || "未知");
    refreshInfo();
}
 
function onInfoResponse(res) {
    addInfo("account", "手机号", res.phone);
    addInfo("account", "注册时间", res.register_time);
    addInfo("account", "登录次数", res.login_freq);
    addInfo("account", "最近登录", res.login_time);
    addInfo("account", "访问次数", res.visit_freq);
    addInfo("account", "最近访问", res.visit_time);
    addInfo("account", "来源地址", res.visit_addr);
 
    addInfo("employee", "员工代码", res.code);
    addInfo("employee", "员工姓名", res.name);
    addInfo("employee", "员工性别", res.gender==1?"男":"女");
    addInfo("employee", "员工职位", res.title);
    addInfo("employee", "职位级别", res.level);
 
    addInfo("app", "最新版本", res.server_version);
    refreshInfo();
}
 
function showAccountInfo() {
    menuSwitch("account");
    loadAccountInfo();
}
 
function loadAccountInfo() {
    jsonRequest("login", "load_account_info", {}, onAccountInfoResponse);
}
 
function onAccountInfoResponse(res) {
    oAccount=res;
    $("#img_headimg").attr("src", imgURL+res.headimg);
    $("#div_account_phone").html(res.phone);
    $("#input_account_name").val(res.name);
    $("#input_account_code").val(res.code);
    $("#input_account_title").val(res.title);
    setGender(res.gender);
    setLevel(res.level);
}
 
function confirmAccountUpdate() {
    oAccount.name=$("#input_account_name").val();    
    oAccount.code=$("#input_account_code").val();
    oAccount.title=$("#input_account_title").val();
    jsonRequest("login", "do_account_update", oAccount, onAccountUpdateResponse);
}    
 
function onAccountUpdateResponse() {
    alertMessage("成功更新用户信息");
    pageBack();
}
 
function setGender(i) {
    toggleSwitch("gender", i);
    oAccount.gender=i;
}
 
function setLevel(i) {
    toggleSwitch("level", i);
    oAccount.level=i;
}
 
function pictureReady() {
    oAccount.headimg=aPicture[aPicture.length-1].pre_name;
    $("#img_headimg").attr("src", imgURL+oAccount.headimg);
}