App.vue 2.3 KB

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