App.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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. // console.log(this.$u.config.v);
  60. },
  61. onHide: function() {
  62. // console.log('App Hide');
  63. }
  64. };
  65. </script>
  66. <style lang="scss">
  67. @import "uview-ui/index.scss";
  68. view,
  69. scroll-view,
  70. swiper,
  71. swiper-item,
  72. cover-view,
  73. cover-image,
  74. icon,
  75. text,
  76. rich-text,
  77. progress,
  78. button,
  79. checkbox,
  80. form,
  81. input,
  82. label,
  83. radio,
  84. slider,
  85. switch,
  86. textarea,
  87. navigator,
  88. audio,
  89. camera,
  90. image,
  91. video {
  92. box-sizing: border-box;
  93. }
  94. /* flex布局-整体居中 */
  95. .flex-center {
  96. display: flex;
  97. align-items: center;
  98. justify-content: center;
  99. }
  100. /* flex布局-上下居中 */
  101. .flex-upDown-center {
  102. display: flex;
  103. align-items: center;
  104. }
  105. //单行排列,居中
  106. .flex_direction {
  107. display: flex;
  108. flex-direction: column;
  109. align-items: center;
  110. }
  111. //单行字体省略
  112. .word1_ellipsis {
  113. text-overflow: ellipsis; //显示 ...
  114. overflow: hidden; //隐藏文字
  115. white-space: nowrap; //不换行
  116. }
  117. //多行字体省略
  118. .word2_ellipsis {
  119. overflow: hidden;
  120. text-overflow: ellipsis;
  121. display: -webkit-box;
  122. -webkit-line-clamp: 2; //在第几行显示...
  123. -webkit-box-orient: vertical;
  124. }
  125. //右外边距
  126. .m-r25 {
  127. margin-right: 25rpx;
  128. }
  129. .m-r15 {
  130. margin-right: 15rpx;
  131. }
  132. .flex1 {
  133. display: flex;
  134. align-items: center;
  135. justify-content: space-between;
  136. }
  137. .flex-start {
  138. display: flex;
  139. align-items: center;
  140. justify-content: flex-start;
  141. }
  142. .flex {
  143. display: flex;
  144. }
  145. .position-relative {
  146. position: relative;
  147. }
  148. /* 骨架屏替代方案 */
  149. .Skeleton {
  150. background: #f3f3f3;
  151. padding: 20rpx 0;
  152. border-radius: 8rpx;
  153. }
  154. /* 图片载入替代方案 */
  155. .image-wrapper {
  156. font-size: 0;
  157. background: #f3f3f3;
  158. border-radius: 4px;
  159. image {
  160. width: 100%;
  161. height: 100%;
  162. transition: 0.6s;
  163. opacity: 0;
  164. &.loaded {
  165. opacity: 1;
  166. }
  167. }
  168. }
  169. // 设置富文本中图片最大宽度
  170. uni-rich-text img {
  171. max-width: 100% !important;
  172. }
  173. /*边框*/
  174. .b-b:after,
  175. .b-t:after {
  176. position: absolute;
  177. z-index: 3;
  178. left: 0;
  179. right: 0;
  180. height: 0;
  181. content: '';
  182. transform: scaleY(0.5);
  183. border-bottom: 1px solid $border-color-base;
  184. }
  185. .b-b:after {
  186. bottom: 0;
  187. }
  188. .b-t:after {
  189. top: 0;
  190. }
  191. /* button样式改写 */
  192. uni-button,
  193. button {
  194. height: 80rpx;
  195. line-height: 80rpx;
  196. font-size: $font-lg + 2rpx;
  197. font-weight: normal;
  198. &.no-border:before,
  199. &.no-border:after {
  200. border: 0;
  201. }
  202. }
  203. uni-button[type='default'],
  204. button[type='default'] {
  205. color: $font-color-dark;
  206. }
  207. /* input 样式 */
  208. .input-placeholder {
  209. color: #999999;
  210. }
  211. .placeholder {
  212. color: #999999;
  213. }
  214. // 边距样式
  215. @for $i from 1 to 4 {
  216. .margin-l-#{$i * 10} {
  217. margin-left: $i * 10rpx !important;
  218. }
  219. .margin-r-#{$i * 10} {
  220. margin-right: $i * 10rpx !important;
  221. }
  222. .margin-t-#{$i * 10} {
  223. margin-top: $i * 10rpx !important;
  224. }
  225. .margin-b-#{$i * 10} {
  226. margin-bottom: $i * 10rpx !important;
  227. }
  228. .margin-#{$i * 10} {
  229. margin: $i * 10rpx !important;
  230. }
  231. .margin-v-#{$i * 10} {
  232. margin-top: $i * 10rpx !important;
  233. margin-bottom: $i * 10rpx !important;
  234. }
  235. .margin-c-#{$i * 10} {
  236. margin-left: $i * 10rpx !important;
  237. margin-right: $i * 10rpx !important;
  238. }
  239. .padding-l-#{$i * 10} {
  240. padding-left: $i * 10rpx !important;
  241. }
  242. .padding-r-#{$i * 10} {
  243. padding-right: $i * 10rpx !important;
  244. }
  245. .padding-t-#{$i * 10} {
  246. padding-top: $i * 10rpx !important;
  247. }
  248. .padding-b-#{$i * 10} {
  249. padding-bottom: $i * 10rpx !important;
  250. }
  251. .padding-#{$i * 10} {
  252. padding: $i * 10rpx !important;
  253. }
  254. .padding-v-#{$i * 10} {
  255. padding-top: $i * 10rpx !important;
  256. padding-bottom: $i * 10rpx !important;
  257. }
  258. .padding-c-#{$i * 10} {
  259. padding-left: $i * 10rpx !important;
  260. padding-right: $i * 10rpx !important;
  261. }
  262. }
  263. // 字体大小
  264. .font-size-sm {
  265. font-size: $font-sm;
  266. }
  267. .font-size-base {
  268. font-size: $font-base;
  269. }
  270. .font-size-lg {
  271. font-size: $font-lg;
  272. }
  273. // 字体颜色
  274. .font-color-yellow {
  275. color: $color-yellow;
  276. }
  277. .font-color-gray {
  278. color: $color-gray;
  279. }
  280. .font-color-red {
  281. color: $color-red;
  282. }
  283. // 边框颜色
  284. .border-color-yellow {
  285. border: 1rpx solid $color-yellow;
  286. }
  287. // 修改默认背景颜色
  288. uni-page-wrapper {
  289. background-color: $page-color-base;
  290. }
  291. page {
  292. background-color: $page-color-base;
  293. // 设置默认字体
  294. font-family: PingFang SC, STHeitiSC-Light, Helvetica-Light, arial, sans-serif, Droid Sans Fallback;
  295. }
  296. .clamp {
  297. overflow: hidden;
  298. text-overflow: ellipsis;
  299. white-space: nowrap;
  300. display: block;
  301. }
  302. .clamp2 {
  303. overflow: hidden;
  304. text-overflow: ellipsis;
  305. display: -webkit-box;
  306. -webkit-box-orient: vertical;
  307. -webkit-line-clamp: 2;
  308. }
  309. </style>