App.vue 5.6 KB

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