App.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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 wxLogin from "@/common/config/wxLogin.js"
  9. export default {
  10. onLaunch: function() {
  11. let self = this
  12. uni.getSystemInfo({
  13. success: function(e) {
  14. let modelmes = e.model;
  15. console.log(e);
  16. if (modelmes.search('iPhone 11') || modelmes.search('iPhone 11 Pro Max') ||modelmes.search('iPhone X') != -1) { //XS,XR,XS MAX均可以适配
  17. self.$store.dispatch('setVariableFun',true)
  18. }else{
  19. self.$store.dispatch('setVariableFun',false)
  20. }
  21. // #ifndef MP
  22. Vue.prototype.StatusBar = e.statusBarHeight;
  23. if (e.platform == 'android') {
  24. Vue.prototype.CustomBar = e.statusBarHeight + 50;
  25. Vue.prototype.platformClass = true
  26. } else {
  27. Vue.prototype.CustomBar = e.statusBarHeight + 45;
  28. Vue.prototype.platformClass = false
  29. };
  30. // #endif
  31. // #ifdef MP-WEIXIN || MP-QQ
  32. console.log(e.platform)
  33. if (e.platform == 'android') {
  34. Vue.prototype.platformClass = 'left'
  35. self.$store.dispatch('setVariableFun',false)
  36. } else {
  37. Vue.prototype.platformClass = 'center'
  38. self.$store.dispatch('setIsIphoneFun',true)
  39. }
  40. Vue.prototype.StatusBar = e.statusBarHeight;
  41. Vue.prototype.fontSizeSetting = e.fontSizeSetting
  42. Vue.prototype.screenWidth = e.screenWidth
  43. let capsule = wx.getMenuButtonBoundingClientRect();
  44. Vue.prototype.capsule = capsule
  45. if (capsule) {
  46. Vue.prototype.Custom = capsule;
  47. // Vue.prototype.capsuleSafe = uni.upx2px(750) - capsule.left + uni.upx2px(750) - capsule.right;
  48. Vue.prototype.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
  49. } else {
  50. Vue.prototype.CustomBar = e.statusBarHeight + 50;
  51. }
  52. // #endif
  53. // #ifdef MP-ALIPAY
  54. Vue.prototype.StatusBar = e.statusBarHeight;
  55. Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
  56. // #endif
  57. }
  58. })
  59. this.refresh()
  60. if(uni.getStorageSync('isActivityStatus')){
  61. const lockTime = uni.getStorageSync('lockTime')
  62. const eTime = this.diffTime(lockTime)
  63. this.$store.dispatch('setActivityFn',eTime)
  64. }else{
  65. this.$store.dispatch('setActivityFn',true)
  66. }
  67. },
  68. methods:{
  69. refresh(){
  70. let TIME = (20*60)*1000;
  71. setInterval(()=>{
  72. authorize.getSetting().then(res =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  73. if(res == 1){
  74. wxLogin.wxLoginAuthorize()
  75. }else{
  76. console.log('授权失败============>:'+'用户取消授权或者未操作')
  77. }
  78. }).catch(error=>{
  79. console.log('授权失败============>:'+'用户授权失败,提醒用户重新授权')
  80. })
  81. },TIME)
  82. },
  83. diffTime(t){
  84. let date = Date.now();
  85. return (date -t) < 2*60*1000 ? false : true
  86. }
  87. },
  88. onShow: function() {
  89. },
  90. onHide: function() {
  91. console.log('App Hide')
  92. },
  93. }
  94. </script>
  95. <style lang="scss">
  96. /*每个页面公共css */
  97. @import "@/common/css/common.scss";
  98. @import "@/common/css/iconfont.scss";
  99. @import "@/common/css/style/thorui.css";
  100. @import "@/common/css/style/icon.css";
  101. view,
  102. scroll-view,
  103. swiper,
  104. swiper-item,
  105. cover-view,
  106. cover-image,
  107. icon,
  108. text,
  109. rich-text,
  110. progress,
  111. button,
  112. checkbox,
  113. form,
  114. input,
  115. label,
  116. radio,
  117. slider,
  118. switch,
  119. textarea,
  120. navigator,
  121. audio,
  122. camera,
  123. image,
  124. video {
  125. // box-sizing: border-box;
  126. }
  127. // page {
  128. // width: 100%;
  129. // height: 100%;
  130. // background: #fff;
  131. // filter: grayscale(100%);
  132. // filter: gray;
  133. // filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
  134. // --toast-default-width: 114px;
  135. // }
  136. page{
  137. height: 100%;
  138. background-color: #FFFFFF;
  139. }
  140. /* 骨架屏替代方案 */
  141. .Skeleton {
  142. background: #f3f3f3;
  143. padding: 20upx 0;
  144. border-radius: 8upx;
  145. }
  146. .clamp {
  147. overflow: hidden;
  148. text-overflow: ellipsis;
  149. white-space: nowrap;
  150. display: block;
  151. }
  152. .common-hover {
  153. background: #f5f5f5;
  154. }
  155. /* input 样式 */
  156. .input-placeholder {
  157. color: #999999;
  158. }
  159. .placeholder {
  160. color: #999999;
  161. }
  162. </style>