App.vue 6.4 KB

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