App.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <script>
  2. /**
  3. * vuex管理登陆状态,具体可以参考官方登陆模板示例
  4. */
  5. import Vue from 'vue'
  6. import { mapState,mapMutations} from 'vuex';
  7. import authorize from '@/common/config/authorize.js'
  8. import { userInfoLogin } from "@/api/use.js"
  9. export default {
  10. onLaunch: function() {
  11. let self = this
  12. uni.getSystemInfo({
  13. success: function(e) {
  14. let modelmes = e.model;
  15. if (modelmes.search('iPhone X') != -1) { //XS,XR,XS MAX均可以适配
  16. self.$store.dispatch('setVariableFun',true)
  17. }
  18. // #ifndef MP
  19. Vue.prototype.StatusBar = e.statusBarHeight;
  20. if (e.platform == 'android') {
  21. Vue.prototype.CustomBar = e.statusBarHeight + 50;
  22. Vue.prototype.platformClass = true
  23. } else {
  24. Vue.prototype.CustomBar = e.statusBarHeight + 45;
  25. Vue.prototype.platformClass = false
  26. };
  27. // #endif
  28. // #ifdef MP-WEIXIN || MP-QQ
  29. console.log(e.platform)
  30. if (e.platform == 'android') {
  31. Vue.prototype.platformClass = 'left'
  32. } else {
  33. Vue.prototype.platformClass = 'center'
  34. }
  35. Vue.prototype.StatusBar = e.statusBarHeight;
  36. Vue.prototype.fontSizeSetting = e.fontSizeSetting
  37. Vue.prototype.screenWidth = e.screenWidth
  38. let capsule = wx.getMenuButtonBoundingClientRect();
  39. Vue.prototype.capsule = capsule
  40. if (capsule) {
  41. Vue.prototype.Custom = capsule;
  42. // Vue.prototype.capsuleSafe = uni.upx2px(750) - capsule.left + uni.upx2px(750) - capsule.right;
  43. Vue.prototype.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
  44. } else {
  45. Vue.prototype.CustomBar = e.statusBarHeight + 50;
  46. }
  47. // #endif
  48. // #ifdef MP-ALIPAY
  49. Vue.prototype.StatusBar = e.statusBarHeight;
  50. Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
  51. // #endif
  52. }
  53. })
  54. this.refresh()
  55. },
  56. methods:{
  57. ...mapMutations(['login','logout']),
  58. getCheekeyCode(){// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
  59. authorize.getCode('weixin').then(wechatcode =>{
  60. // 根据微信的code获取用户登录状态:1已登录过 -1未登录过
  61. authorize.getUserInfo('weixin').then(wxResponse =>{
  62. userInfoLogin({code:wechatcode,encryptedData:wxResponse.encryptedData,iv:wxResponse.iv}).then(response =>{
  63. this.login(response.data)
  64. uni.setStorageSync('token',response.data.token)
  65. uni.removeStorageSync('sessionid')
  66. uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
  67. this.$store.commit('updateStatus',response.data)
  68. }).catch(error =>{
  69. this.logout()
  70. uni.removeStorageSync('sessionid')
  71. uni.setStorageSync('sessionid','JSESSIONID='+error.data)
  72. this.$store.commit('updateStatus',error.data)
  73. })
  74. })
  75. })
  76. },
  77. refresh(){
  78. let TIME = (20*60)*1000;
  79. setInterval(()=>{
  80. this.getCheekeyCode()
  81. },TIME)
  82. }
  83. },
  84. onShow: function() {
  85. // this.getCheekeyCode()
  86. },
  87. onHide: function() {
  88. console.log('App Hide')
  89. },
  90. }
  91. </script>
  92. <style lang="scss">
  93. /*每个页面公共css */
  94. @import "@/common/css/common.scss";
  95. @import "@/common/css/iconfont.scss";
  96. view,
  97. scroll-view,
  98. swiper,
  99. swiper-item,
  100. cover-view,
  101. cover-image,
  102. icon,
  103. text,
  104. rich-text,
  105. progress,
  106. button,
  107. checkbox,
  108. form,
  109. input,
  110. label,
  111. radio,
  112. slider,
  113. switch,
  114. textarea,
  115. navigator,
  116. audio,
  117. camera,
  118. image,
  119. video {
  120. // box-sizing: border-box;
  121. }
  122. // page {
  123. // width: 100%;
  124. // height: 100%;
  125. // background: #fff;
  126. // filter: grayscale(100%);
  127. // filter: gray;
  128. // filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
  129. // --toast-default-width: 114px;
  130. // }
  131. page{
  132. height: 100%;
  133. background-color: #FFFFFF;
  134. }
  135. /* 骨架屏替代方案 */
  136. .Skeleton {
  137. background: #f3f3f3;
  138. padding: 20upx 0;
  139. border-radius: 8upx;
  140. }
  141. .clamp {
  142. overflow: hidden;
  143. text-overflow: ellipsis;
  144. white-space: nowrap;
  145. display: block;
  146. }
  147. .common-hover {
  148. background: #f5f5f5;
  149. }
  150. /* input 样式 */
  151. .input-placeholder {
  152. color: #999999;
  153. }
  154. .placeholder {
  155. color: #999999;
  156. }
  157. </style>