App.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <script>
  2. /**
  3. * vuex管理登陆状态,具体可以参考官方登陆模板示例
  4. */
  5. import { mapMutations } from 'vuex';
  6. // #ifdef H5
  7. import { weixindata, setRouter } from './utils/wxAuthorized';
  8. // #endif
  9. // #ifdef APP-PLUS
  10. import { getUpApp } from './utils/upApp.js';
  11. // #endif
  12. export default {
  13. data() {
  14. return {
  15. /* 保存微信信息 */
  16. appData: {}
  17. };
  18. },
  19. methods: {
  20. ...mapMutations('user', ['setUserInfo', 'login', 'hasLogin'])
  21. },
  22. onLaunch: function(urlObj) {
  23. let obj = this;
  24. let systemInfo = uni.getSystemInfoSync();
  25. let lang = systemInfo.language || 'zh-CN'
  26. uni.setStorageSync('lang',lang)
  27. // 加载缓存中的用户信息
  28. let userInfo = uni.getStorageSync('userInfo') || '';
  29. // 判断是否拥有用户信息
  30. if (userInfo.id) {
  31. //更新登陆状态
  32. uni.getStorage({
  33. key: 'userInfo',
  34. success: res => {
  35. obj.setUserInfo(res.data);
  36. obj.login(res.data);
  37. }
  38. });
  39. }
  40. // #ifdef H5
  41. // 保存路由对象
  42. setRouter(this.$router);
  43. //判断是否已经缓存浏览器
  44. let bool = uni.getStorageSync('weichatBrowser') || '';
  45. if (bool === '') {
  46. //判断是否为微信浏览
  47. bool = navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger';
  48. // 保存当前是否为微信内核浏览器
  49. uni.setStorageSync('weichatBrowser', bool);
  50. }
  51. if (bool) {
  52. // 加载微信信息
  53. weixindata();
  54. }
  55. // #endif
  56. // #ifdef APP-PLUS
  57. // 判断是否升级
  58. getUpApp();
  59. // 获取当前运行系统
  60. let system = uni.getStorageSync('platform') || '';
  61. if (!system) {
  62. uni.setStorage({
  63. key: 'platform',
  64. data: uni.getSystemInfoSync().platform
  65. });
  66. }
  67. // #endif
  68. },
  69. onShow: function() {
  70. // 加载拦截
  71. // console.log('App Show');
  72. },
  73. onHide: function() {
  74. // console.log('App Hide');
  75. }
  76. };
  77. </script>
  78. <style lang="scss">
  79. /*全局公共样式和字体图标*/
  80. @import '/static/css/cmy.css';
  81. @import "uview-ui/index.scss";
  82. view,
  83. scroll-view,
  84. swiper,
  85. swiper-item,
  86. cover-view,
  87. cover-image,
  88. icon,
  89. text,
  90. rich-text,
  91. progress,
  92. button,
  93. checkbox,
  94. form,
  95. input,
  96. label,
  97. radio,
  98. slider,
  99. switch,
  100. textarea,
  101. navigator,
  102. audio,
  103. camera,
  104. image,
  105. video {
  106. box-sizing: border-box;
  107. }
  108. /* 骨架屏替代方案 */
  109. .Skeleton {
  110. background: #f3f3f3;
  111. padding: 20rpx 0;
  112. border-radius: 8rpx;
  113. }
  114. /* 图片载入替代方案 */
  115. .image-wrapper {
  116. font-size: 0;
  117. background: #f3f3f3;
  118. border-radius: 4px;
  119. image {
  120. width: 100%;
  121. height: 100%;
  122. transition: 0.6s;
  123. opacity: 0;
  124. &.loaded {
  125. opacity: 1;
  126. }
  127. }
  128. }
  129. // 设置富文本中图片最大宽度
  130. uni-rich-text img {
  131. max-width: 100% !important;
  132. }
  133. /*边框*/
  134. .b-b:after,
  135. .b-t:after {
  136. position: absolute;
  137. z-index: 3;
  138. left: 0;
  139. right: 0;
  140. height: 0;
  141. content: '';
  142. transform: scaleY(0.5);
  143. border-bottom: 1px solid $border-color-base;
  144. }
  145. .b-b:after {
  146. bottom: 0;
  147. }
  148. .b-t:after {
  149. top: 0;
  150. }
  151. /* button样式改写 */
  152. uni-button,
  153. button {
  154. height: 80rpx;
  155. line-height: 80rpx;
  156. font-size: $font-lg + 2rpx;
  157. font-weight: normal;
  158. &.no-border:before,
  159. &.no-border:after {
  160. border: 0;
  161. }
  162. }
  163. uni-button[type='default'],
  164. button[type='default'] {
  165. color: $font-color-dark;
  166. }
  167. /* input 样式 */
  168. .input-placeholder {
  169. color: #999999;
  170. }
  171. .placeholder {
  172. color: #999999;
  173. }
  174. // 边距样式
  175. @for $i from 1 to 4 {
  176. .margin-l-#{$i * 10} {
  177. margin-left: $i * 10rpx !important;
  178. }
  179. .margin-r-#{$i * 10} {
  180. margin-right: $i * 10rpx !important;
  181. }
  182. .margin-t-#{$i * 10} {
  183. margin-top: $i * 10rpx !important;
  184. }
  185. .margin-b-#{$i * 10} {
  186. margin-bottom: $i * 10rpx !important;
  187. }
  188. .margin-#{$i * 10} {
  189. margin: $i * 10rpx !important;
  190. }
  191. .margin-v-#{$i * 10} {
  192. margin-top: $i * 10rpx !important;
  193. margin-bottom: $i * 10rpx !important;
  194. }
  195. .margin-c-#{$i * 10} {
  196. margin-left: $i * 10rpx !important;
  197. margin-right: $i * 10rpx !important;
  198. }
  199. .padding-l-#{$i * 10} {
  200. padding-left: $i * 10rpx !important;
  201. }
  202. .padding-r-#{$i * 10} {
  203. padding-right: $i * 10rpx !important;
  204. }
  205. .padding-t-#{$i * 10} {
  206. padding-top: $i * 10rpx !important;
  207. }
  208. .padding-b-#{$i * 10} {
  209. padding-bottom: $i * 10rpx !important;
  210. }
  211. .padding-#{$i * 10} {
  212. padding: $i * 10rpx !important;
  213. }
  214. .padding-v-#{$i * 10} {
  215. padding-top: $i * 10rpx !important;
  216. padding-bottom: $i * 10rpx !important;
  217. }
  218. .padding-c-#{$i * 10} {
  219. padding-left: $i * 10rpx !important;
  220. padding-right: $i * 10rpx !important;
  221. }
  222. }
  223. // 字体大小
  224. .font-size-sm {
  225. font-size: $font-sm;
  226. }
  227. .font-size-base {
  228. font-size: $font-base;
  229. }
  230. .font-size-lg {
  231. font-size: $font-lg;
  232. }
  233. // 字体颜色
  234. .font-color-yellow {
  235. color: $color-yellow;
  236. }
  237. .font-color-gray {
  238. color: $color-gray;
  239. }
  240. .font-color-red {
  241. color: $color-red;
  242. }
  243. // 边框颜色
  244. .border-color-yellow {
  245. border: 1rpx solid $color-yellow;
  246. }
  247. // 修改默认背景颜色
  248. uni-page-wrapper {
  249. background-color: $page-color-base;
  250. }
  251. page {
  252. background-color: $page-color-base;
  253. // 设置默认字体
  254. font-family: PingFang SC, STHeitiSC-Light, Helvetica-Light, arial, sans-serif, Droid Sans Fallback;
  255. }
  256. </style>