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.
 
 
 
 
 
 

61 rivejä
1.4 KiB

  1. var users;
  2. //验证登录状态
  3. function CheckLogin() {
  4. users = JSON.parse(localStorage.getItem('taigangstudentUserModel') || '{}');
  5. if(users.phone != undefined && users.phone != "") {
  6. return true;
  7. } else {
  8. return false;
  9. }
  10. }
  11. //刷新用户信息
  12. function RefreshUserData() {
  13. mui.post(api + '/user/getStuByUserId', {
  14. data: users.ID
  15. }, function(des) {
  16. if (des.code == "200") {
  17. SetLogin(des.data)
  18. }
  19. }, 'json')
  20. }
  21. //保存登录状态
  22. function SetLogin(us) {
  23. localStorage.setItem('taigangstudentUserModel', JSON.stringify(us));
  24. }
  25. //退出,删除文件
  26. function SetLogOut() {
  27. localStorage.removeItem('taigangstudentMsgList');
  28. localStorage.removeItem('taigangstudentUserModel');
  29. // plus.oauth.getServices(function(services) {
  30. // for(var i in services) {
  31. // var service = services[i];
  32. // service.logout(function(suc) {
  33. // console.log("logout success!");
  34. // }, function(err) {
  35. // console.log("logout error!");
  36. // });
  37. // }
  38. // });
  39. }
  40. function SetUserModel(model) {
  41. users = JSON.parse(localStorage.getItem('taigangstudentUserModel') || '{}');
  42. }
  43. function SetUserPhoto(psrc) {
  44. users = JSON.parse(localStorage.getItem('taigangstudentUserModel') || '{}');
  45. users.photo = "" + psrc.replace(/"/g, '').replace(/\\/g, '') + "";
  46. SetLogin(users);
  47. }
  48. function SetUserRealName(nn) {
  49. users = JSON.parse(localStorage.getItem('taigangstudentUserModel') || '{}');
  50. users.username = nn;
  51. SetLogin(users);
  52. }