App.vue 2.3 KB

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