App.vue 2.4 KB

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