|
-
- //设置字符串类型的本地缓存
- function setStorage(objName, objValue){
- var sto = window.localStorage;
- if (sto)
- sto.setItem(objName, objValue);
- }
- //读取字符串类型的本地缓存
- function getStorage(objName){
- var ret = '';
- var sto = window.localStorage;
- if (sto)
- ret = sto.getItem(objName);
- return ret;
- }
-
- //清除本地缓存,如没指定名称则为清空所有缓存
- function clearStorage(objName){
- var sto = window.localStorage;
- if (sto) {
- if (objName)
- sto.removeItem(objName);
- else
- sto.clear();
- }
- }
- //设置Json类型的本地缓存
- function setStorJson(objName, json){
- if (json)
- setStorage(objName, JSON.stringify(json));
- }
- //读取Json类型的本地缓存
- function getStorJson(objName){
- var ret = null;
- var str = getStorage(objName);
- if (str)
- ret = JSON.parse(str);
- return ret;
- }
- function iflogin(){
- $.ajax({
- type:"post",
- url:"./zz-fx/control.php",
- data:{type:"distribut_iflogin"},
- dataType: "json",
- success: function (data) {
- console.log(data);
- if(data.iflogin == 1){
- //alert("用户未登录,请先登录");
- window.wxc.xcConfirm("用户未登录,请先登录", window.wxc.xcConfirm.typeEnum.info,{
- onOk:function(){
- window.location.href="login.html"
- }
- });
-
-
- }else{
- return;
- }
- },
- fail: function (date) {
-
- // 此处放失败后执行的代码
- }
- });
- }
|