App.vue 4.4 KB

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