You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

67 lines
1.5 KiB

  1. //设置字符串类型的本地缓存
  2. function setStorage(objName, objValue){
  3. var sto = window.localStorage;
  4. if (sto)
  5. sto.setItem(objName, objValue);
  6. }
  7. //读取字符串类型的本地缓存
  8. function getStorage(objName){
  9. var ret = '';
  10. var sto = window.localStorage;
  11. if (sto)
  12. ret = sto.getItem(objName);
  13. return ret;
  14. }
  15. //清除本地缓存,如没指定名称则为清空所有缓存
  16. function clearStorage(objName){
  17. var sto = window.localStorage;
  18. if (sto) {
  19. if (objName)
  20. sto.removeItem(objName);
  21. else
  22. sto.clear();
  23. }
  24. }
  25. //设置Json类型的本地缓存
  26. function setStorJson(objName, json){
  27. if (json)
  28. setStorage(objName, JSON.stringify(json));
  29. }
  30. //读取Json类型的本地缓存
  31. function getStorJson(objName){
  32. var ret = null;
  33. var str = getStorage(objName);
  34. if (str)
  35. ret = JSON.parse(str);
  36. return ret;
  37. }
  38. function iflogin(){
  39. $.ajax({
  40. type:"post",
  41. url:"./zz-fx/control.php",
  42. data:{type:"distribut_iflogin"},
  43. dataType: "json",
  44. success: function (data) {
  45. console.log(data);
  46. if(data.iflogin == 1){
  47. //alert("用户未登录,请先登录");
  48. window.wxc.xcConfirm("用户未登录,请先登录", window.wxc.xcConfirm.typeEnum.info,{
  49. onOk:function(){
  50. window.location.href="login.html"
  51. }
  52. });
  53. }else{
  54. return;
  55. }
  56. },
  57. fail: function (date) {
  58. // 此处放失败后执行的代码
  59. }
  60. });
  61. }