App.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <script>
  2. /**
  3. * vuex管理登陆状态,具体可以参考官方登陆模板示例
  4. */
  5. import { mapState,mapMutations} from 'vuex';
  6. import authorize from '@/common/config/authorize.js'
  7. import { userInfoLogin } from "@/api/use.js"
  8. export default {
  9. onLaunch: function() {
  10. this.refresh()
  11. let _self = this;
  12. uni.getSystemInfo({
  13. success: res => {
  14. let modelmes = res.model;
  15. if (modelmes.search('iPhone X') != -1) { //XS,XR,XS MAX均可以适配
  16. this.$store.dispatch('setVariableFun',true)
  17. }
  18. // uni.setStorageSync('modelmes', modelmes)
  19. }
  20. })
  21. },
  22. methods:{
  23. getCheekeyCode(){// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
  24. authorize.getCode('weixin').then(wechatcode =>{
  25. // console.log(wechatcode);
  26. // 根据微信的code获取用户登录状态:1已登录过 -1未登录过
  27. userInfoLogin({code:wechatcode}).then(response =>{
  28. this.isLogin = true;
  29. this.userID = response.data.userID;
  30. let user_key = {code:response.code,openid:response.data.openid,userID:response.data.userID}
  31. this.$store.commit('updateStatus',user_key)
  32. uni.removeStorageSync('sessionid')
  33. uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
  34. this.getHomeInformation()
  35. }).catch(response =>{
  36. this.isLogin = false;
  37. this.userID ='';
  38. let user_key = {code:response.code,userID:this.userID,openid:''}
  39. uni.removeStorageSync('sessionid')
  40. uni.setStorageSync('sessionid','JSESSIONID='+response.data)
  41. this.$store.commit('updateStatus',user_key)
  42. this.getHomeInformation()
  43. })
  44. })
  45. },
  46. refresh(){
  47. let TIME = (20*60)*1000;
  48. let self = this;
  49. setInterval(function(){
  50. self.getCheekeyCode()
  51. },TIME)
  52. }
  53. },
  54. onShow: function() {
  55. console.log('App Show')
  56. uni.setStorageSync('token','token')
  57. },
  58. onHide: function() {
  59. console.log('App Hide')
  60. },
  61. }
  62. </script>
  63. <style lang="scss">
  64. /*每个页面公共css */
  65. @import "@/common/css/common.scss";
  66. @import "@/common/css/iconfont.scss";
  67. view,
  68. scroll-view,
  69. swiper,
  70. swiper-item,
  71. cover-view,
  72. cover-image,
  73. icon,
  74. text,
  75. rich-text,
  76. progress,
  77. button,
  78. checkbox,
  79. form,
  80. input,
  81. label,
  82. radio,
  83. slider,
  84. switch,
  85. textarea,
  86. navigator,
  87. audio,
  88. camera,
  89. image,
  90. video {
  91. // box-sizing: border-box;
  92. }
  93. page{
  94. height: 100%;
  95. background-color: #FFFFFF;
  96. }
  97. /* 骨架屏替代方案 */
  98. .Skeleton {
  99. background: #f3f3f3;
  100. padding: 20upx 0;
  101. border-radius: 8upx;
  102. }
  103. .clamp {
  104. overflow: hidden;
  105. text-overflow: ellipsis;
  106. white-space: nowrap;
  107. display: block;
  108. }
  109. .common-hover {
  110. background: #f5f5f5;
  111. }
  112. /* input 样式 */
  113. .input-placeholder {
  114. color: #999999;
  115. }
  116. .placeholder {
  117. color: #999999;
  118. }
  119. </style>