App.vue 4.3 KB

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