App.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <script>
  2. /**
  3. * vuex管理登陆状态,具体可以参考官方登陆模板示例
  4. */
  5. import Vue from 'vue'
  6. import { mapActions, mapMutations } from 'vuex'
  7. export default {
  8. onLaunch: function() {
  9. console.log('清空本地缓存')
  10. uni.clearStorageSync()
  11. this.initSystemInfo()
  12. this.wechatlogin()
  13. // 判断优惠券弹窗是否显示
  14. // this.checkShowCouponPopup()
  15. },
  16. methods: {
  17. ...mapActions('app', ['setWindowHeight', 'setVariableFun']),
  18. ...mapActions('user', ['wechatlogin']),
  19. ...mapMutations('coupon', ['setCouponPopupStatus']),
  20. ...mapMutations('app', ['setWindowHeight']),
  21. // 验证是否需要显示优惠券入口弹窗
  22. checkShowCouponPopup() {
  23. const couponPopupType = uni.getStorageSync('couponPopupType')
  24. const nowDay = new Date().getDay()
  25. // 新用户 当天不弹窗
  26. if (couponPopupType === nowDay) {
  27. this.setCouponPopupStatus(false)
  28. }
  29. },
  30. initSystemInfo() {
  31. let self = this
  32. uni.getSystemInfo({
  33. success: function(e) {
  34. let modelmes = e.model
  35. self.setWindowHeight(e.windowHeight)
  36. console.log(modelmes)
  37. // iphone x以上的版本都要控制下巴高度
  38. console.log(/iphone [1|x]\s?/i.test(modelmes))
  39. if (/iphone [1|x]\s?/i.test(modelmes)) {
  40. self.setVariableFun(true)
  41. } else {
  42. self.setVariableFun(false)
  43. }
  44. // #ifndef MP
  45. Vue.prototype.StatusBar = e.statusBarHeight
  46. if (e.platform == 'android') {
  47. Vue.prototype.CustomBar = e.statusBarHeight + 50
  48. Vue.prototype.platformClass = true
  49. } else {
  50. Vue.prototype.CustomBar = e.statusBarHeight + 45
  51. Vue.prototype.platformClass = false
  52. }
  53. // #endif
  54. // #ifdef MP-WEIXIN || MP-QQ
  55. if (e.platform == 'android') {
  56. Vue.prototype.platformClass = 'left'
  57. } else {
  58. Vue.prototype.platformClass = 'center'
  59. }
  60. Vue.prototype.StatusBar = e.statusBarHeight
  61. Vue.prototype.fontSizeSetting = e.fontSizeSetting
  62. Vue.prototype.screenWidth = e.screenWidth
  63. let capsule = wx.getMenuButtonBoundingClientRect()
  64. Vue.prototype.capsule = capsule
  65. if (capsule) {
  66. Vue.prototype.Custom = capsule
  67. Vue.prototype.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight
  68. } else {
  69. Vue.prototype.CustomBar = e.statusBarHeight + 50
  70. }
  71. // #endif
  72. // #ifdef MP-ALIPAY
  73. Vue.prototype.StatusBar = e.statusBarHeight
  74. Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight
  75. // #endif
  76. }
  77. })
  78. }
  79. }
  80. }
  81. </script>
  82. <style lang="scss">
  83. /*每个页面公共css */
  84. @import '@/common/css/common.scss';
  85. @import '@/common/css/iconfont.scss';
  86. @import '@/common/css/style/thorui.css';
  87. @import '@/common/css/style/icon.css';
  88. view,
  89. scroll-view,
  90. swiper,
  91. swiper-item,
  92. cover-view,
  93. cover-image,
  94. icon,
  95. text,
  96. rich-text,
  97. progress,
  98. button,
  99. checkbox,
  100. form,
  101. input,
  102. label,
  103. radio,
  104. slider,
  105. switch,
  106. textarea,
  107. navigator,
  108. audio,
  109. camera,
  110. image,
  111. video {
  112. // box-sizing: border-box;
  113. }
  114. // page {
  115. // width: 100%;
  116. // height: 100%;
  117. // background: #fff;
  118. // filter: grayscale(100%);
  119. // filter: gray;
  120. // filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
  121. // --toast-default-width: 114px;
  122. // }
  123. page {
  124. height: 100%;
  125. background-color: #ffffff;
  126. }
  127. /* 骨架屏替代方案 */
  128. .Skeleton {
  129. background: #f3f3f3;
  130. padding: 20upx 0;
  131. border-radius: 8upx;
  132. }
  133. .clamp {
  134. overflow: hidden;
  135. text-overflow: ellipsis;
  136. white-space: nowrap;
  137. display: block;
  138. }
  139. .common-hover {
  140. background: #f5f5f5;
  141. }
  142. /* input 样式 */
  143. .input-placeholder {
  144. color: #999999;
  145. }
  146. .placeholder {
  147. color: #999999;
  148. }
  149. </style>