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); }