App.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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.setStorageSync('cookieKey','JSESSIONID='+response.data.sessionId)
  33. this.getHomeInformation()
  34. }).catch(response =>{
  35. this.isLogin = false;
  36. this.userID ='';
  37. let user_key = {code:response.code,userID:this.userID,openid:''}
  38. uni.setStorageSync('cookieKey','JSESSIONID='+response.data)
  39. this.$store.commit('updateStatus',user_key)
  40. this.getHomeInformation()
  41. })
  42. })
  43. },
  44. refresh(){
  45. let TIME = (20*60)*1000;
  46. let self = this;
  47. setInterval(function(){
  48. self.getCheekeyCode()
  49. },TIME)
  50. }
  51. },
  52. onShow: function() {
  53. console.log('App Show')
  54. uni.setStorageSync('token','token')
  55. },
  56. onHide: function() {
  57. console.log('App Hide')
  58. },
  59. }
  60. </script>
  61. <style lang="scss">
  62. /*每个页面公共css */
  63. @import "@/common/css/common.scss";
  64. @import "@/common/css/iconfont.scss";
  65. view,
  66. scroll-view,
  67. swiper,
  68. swiper-item,
  69. cover-view,
  70. cover-image,
  71. icon,
  72. text,
  73. rich-text,
  74. progress,
  75. button,
  76. checkbox,
  77. form,
  78. input,
  79. label,
  80. radio,
  81. slider,
  82. switch,
  83. textarea,
  84. navigator,
  85. audio,
  86. camera,
  87. image,
  88. video {
  89. // box-sizing: border-box;
  90. }
  91. page{
  92. height: 100%;
  93. background-color: #FFFFFF;
  94. }
  95. /* 骨架屏替代方案 */
  96. .Skeleton {
  97. background: #f3f3f3;
  98. padding: 20upx 0;
  99. border-radius: 8upx;
  100. }
  101. .clamp {
  102. overflow: hidden;
  103. text-overflow: ellipsis;
  104. white-space: nowrap;
  105. display: block;
  106. }
  107. .common-hover {
  108. background: #f5f5f5;
  109. }
  110. /* input 样式 */
  111. .input-placeholder {
  112. color: #999999;
  113. }
  114. .placeholder {
  115. color: #999999;
  116. }
  117. </style>