App.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <script>
  2. /**
  3. * vuex管理登陆状态,具体可以参考官方登陆模板示例
  4. */
  5. import { mapMutations } from 'vuex';
  6. import { weixindata } from './utils/wxAuthorized';
  7. export default {
  8. data() {
  9. return {
  10. /* 保存微信信息 */
  11. appData: {}
  12. };
  13. },
  14. methods: {
  15. ...mapMutations('user', ['setUserInfo', 'login', 'hasLogin'])
  16. },
  17. onLaunch: function(urlObj) {
  18. let obj = this;
  19. // 加载缓存中的用户信息
  20. let userInfo = uni.getStorageSync('userInfo') || '';
  21. // 判断是否拥有用户信息
  22. if (userInfo.uid) {
  23. //更新登陆状态
  24. uni.getStorage({
  25. key: 'userInfo',
  26. success: res => {
  27. obj.setUserInfo(res.data);
  28. obj.login(res.data);
  29. }
  30. });
  31. }
  32. //判断是否已经缓存浏览器
  33. let bool = uni.getStorageSync('weichatBrowser') || '';
  34. if (bool === '') {
  35. //判断是否为微信浏览
  36. bool = navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger';
  37. // 保存当前是否为微信内核浏览器
  38. uni.setStorageSync('weichatBrowser', bool);
  39. }
  40. if (bool) {
  41. // 加载微信信息
  42. weixindata();
  43. }
  44. },
  45. onShow: function() {
  46. // 加载拦截
  47. // console.log('App Show');
  48. },
  49. onHide: function() {
  50. // console.log('App Hide');
  51. }
  52. };
  53. </script>
  54. <style lang="scss">
  55. /*全局公共样式和字体图标*/
  56. @import '/static/css/cmy.css';
  57. @import "uview-ui/index.scss";
  58. // 边距样式
  59. @for $i from 1 to 4 {
  60. .margin-l-#{$i * 10} {
  61. margin-left: $i * 10rpx !important;
  62. }
  63. .margin-r-#{$i * 10} {
  64. margin-right: $i * 10rpx !important;
  65. }
  66. .margin-t-#{$i * 10} {
  67. margin-top: $i * 10rpx !important;
  68. }
  69. .margin-b-#{$i * 10} {
  70. margin-bottom: $i * 10rpx !important;
  71. }
  72. .margin-#{$i * 10} {
  73. margin: $i * 10rpx !important;
  74. }
  75. .margin-v-#{$i * 10} {
  76. margin-top: $i * 10rpx !important;
  77. margin-bottom: $i * 10rpx !important;
  78. }
  79. .margin-c-#{$i * 10} {
  80. margin-left: $i * 10rpx !important;
  81. margin-right: $i * 10rpx !important;
  82. }
  83. .padding-l-#{$i * 10} {
  84. padding-left: $i * 10rpx !important;
  85. }
  86. .padding-r-#{$i * 10} {
  87. padding-right: $i * 10rpx !important;
  88. }
  89. .padding-t-#{$i * 10} {
  90. padding-top: $i * 10rpx !important;
  91. }
  92. .padding-b-#{$i * 10} {
  93. padding-bottom: $i * 10rpx !important;
  94. }
  95. .padding-#{$i * 10} {
  96. padding: $i * 10rpx !important;
  97. }
  98. .padding-v-#{$i * 10} {
  99. padding-top: $i * 10rpx !important;
  100. padding-bottom: $i * 10rpx !important;
  101. }
  102. .padding-c-#{$i * 10} {
  103. padding-left: $i * 10rpx !important;
  104. padding-right: $i * 10rpx !important;
  105. }
  106. }
  107. // 修改默认背景颜色
  108. uni-page-wrapper {
  109. background-color: $page-color-base;
  110. }
  111. page {
  112. background-color: $page-color-base;
  113. // 设置默认字体
  114. font-family: PingFang SC, STHeitiSC-Light, Helvetica-Light, arial, sans-serif, Droid Sans Fallback;
  115. }
  116. </style>