App.vue 2.3 KB

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