App.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <script>
  2. /**
  3. * vuex管理登陆状态,具体可以参考官方登陆模板示例
  4. */
  5. import { mapMutations } from 'vuex';
  6. // #ifdef H5
  7. import { weixindata } from './utils/wxAuthorized';
  8. // #endif
  9. export default {
  10. data() {
  11. return {};
  12. },
  13. methods: {
  14. ...mapMutations('user',['login', 'hasLogin', 'setUserInfo']),
  15. ...mapMutations(['setAddressData'])
  16. },
  17. onLaunch: function(urlObj) {
  18. let obj = this;
  19. // 加载缓存中的用户信息
  20. let userInfo = uni.getStorageSync('userInfo') || '';
  21. let token = uni.getStorageSync('token');
  22. // let GetInfo = uni.getStorageSync('GetInfo');
  23. // console.log(GetInfo,8)
  24. // 判断是否拥有用户信息
  25. if (userInfo.uid) {
  26. // 更新登录信息
  27. obj.login();
  28. //更新登陆状态
  29. uni.getStorage({
  30. key: 'userInfo',
  31. success: res => {
  32. obj.setUserInfo(res.data);
  33. }
  34. });
  35. }
  36. // #ifdef H5
  37. //判断是否已经缓存浏览器
  38. let bool = uni.getStorageSync('weichatBrowser') || '';
  39. if (bool === '') {
  40. //判断是否为微信浏览
  41. bool = navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger';
  42. // 保存当前是否为微信内核浏览器
  43. uni.setStorageSync('weichatBrowser', bool);
  44. }
  45. // 判断是否为微信浏览器
  46. if (bool) {
  47. // 加载微信注册信息
  48. weixindata();
  49. }
  50. // #endif
  51. // if ( userInfo.is_promoter == 1 ) {
  52. // uni.navigateTo({
  53. // url: '/pages/groupBooking/index',
  54. // fail(e) {
  55. // uni.navigateTo({
  56. // url: '/pages/index/index'
  57. // })
  58. // }
  59. // })
  60. // }
  61. }
  62. };
  63. </script>
  64. <style lang="scss">
  65. /*全局公共样式和字体图标*/
  66. @import '/static/css/cmy.css';
  67. @import '/static/iconfont/font.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. /* 骨架屏替代方案 */
  95. .Skeleton {
  96. background: #f3f3f3;
  97. padding: 20rpx 0;
  98. border-radius: 8rpx;
  99. }
  100. /* 图片载入替代方案 */
  101. .image-wrapper {
  102. font-size: 0;
  103. border-radius: 4px;
  104. image {
  105. width: 100%;
  106. height: 100%;
  107. }
  108. }
  109. // 设置富文本中图片最大宽度
  110. uni-rich-text img {
  111. max-width: 100% !important;
  112. }
  113. //上下居中
  114. .flex_center_down_center{
  115. display: flex;
  116. align-items: center;
  117. }
  118. //左右顶格
  119. .flex_between{
  120. display: flex;
  121. justify-content: space-between;
  122. }
  123. //左右顶格加上下居中
  124. .flex-between-center{
  125. display: flex;
  126. justify-content: space-between;
  127. align-items: center;
  128. }
  129. //完全居中
  130. .flex-center{
  131. display: flex;
  132. justify-content: center;
  133. align-items: center;
  134. }
  135. .flex-start-center{
  136. display: flex;
  137. justify-content: flex-start;
  138. align-items: center;
  139. }
  140. /*边框*/
  141. .b-b:after,
  142. .b-t:after {
  143. position: absolute;
  144. z-index: 3;
  145. left: 0;
  146. right: 0;
  147. height: 0;
  148. content: '';
  149. transform: scaleY(0.5);
  150. border-bottom: 1px solid $border-color-base;
  151. }
  152. .b-b:after {
  153. bottom: 0;
  154. }
  155. .b-t:after {
  156. top: 0;
  157. }
  158. /* button样式改写 */
  159. uni-button,
  160. button {
  161. height: 80rpx;
  162. line-height: 80rpx;
  163. font-size: $font-lg + 2rpx;
  164. font-weight: normal;
  165. &.no-border:before,
  166. &.no-border:after {
  167. border: 0;
  168. }
  169. }
  170. uni-button[type='default'],
  171. button[type='default'] {
  172. color: $font-color-dark;
  173. }
  174. /* input 样式 */
  175. .input-placeholder {
  176. color: #999999;
  177. }
  178. .placeholder {
  179. color: #999999;
  180. }
  181. // 边距样式
  182. @for $i from 1 to 4 {
  183. .margin-l-#{$i * 10} {
  184. margin-left: $i * 10rpx !important;
  185. }
  186. .margin-r-#{$i * 10} {
  187. margin-right: $i * 10rpx !important;
  188. }
  189. .margin-t-#{$i * 10} {
  190. margin-top: $i * 10rpx !important;
  191. }
  192. .margin-b-#{$i * 10} {
  193. margin-bottom: $i * 10rpx !important;
  194. }
  195. .margin-#{$i * 10} {
  196. margin: $i * 10rpx !important;
  197. }
  198. .margin-v-#{$i * 10} {
  199. margin-top: $i * 10rpx !important;
  200. margin-bottom: $i * 10rpx !important;
  201. }
  202. .margin-c-#{$i * 10} {
  203. margin-left: $i * 10rpx !important;
  204. margin-right: $i * 10rpx !important;
  205. }
  206. .padding-l-#{$i * 10} {
  207. padding-left: $i * 10rpx !important;
  208. }
  209. .padding-r-#{$i * 10} {
  210. padding-right: $i * 10rpx !important;
  211. }
  212. .padding-t-#{$i * 10} {
  213. padding-top: $i * 10rpx !important;
  214. }
  215. .padding-b-#{$i * 10} {
  216. padding-bottom: $i * 10rpx !important;
  217. }
  218. .padding-#{$i * 10} {
  219. padding: $i * 10rpx !important;
  220. }
  221. .padding-v-#{$i * 10} {
  222. padding-top: $i * 10rpx !important;
  223. padding-bottom: $i * 10rpx !important;
  224. }
  225. .padding-c-#{$i * 10} {
  226. padding-left: $i * 10rpx !important;
  227. padding-right: $i * 10rpx !important;
  228. }
  229. }
  230. // 字体大小
  231. .font-size-sm {
  232. font-size: $font-sm;
  233. }
  234. .font-size-base {
  235. font-size: $font-base;
  236. }
  237. .font-size-lg {
  238. font-size: $font-lg;
  239. }
  240. // 字体颜色
  241. .font-color-yellow {
  242. color: $color-yellow;
  243. }
  244. .font-color-gray {
  245. color: $color-gray;
  246. }
  247. .font-color-red {
  248. color: $color-red;
  249. }
  250. // 边框颜色
  251. .border-color-yellow {
  252. border: 1rpx solid $color-yellow;
  253. }
  254. // 修改默认背景颜色
  255. uni-page-wrapper {
  256. background-color: $page-color-base;
  257. }
  258. page {
  259. background-color: $page-color-base;
  260. // 设置默认字体
  261. font-family: PingFang SC, STHeitiSC-Light, Helvetica-Light, arial, sans-serif, Droid Sans Fallback;
  262. }
  263. </style>