App.vue 5.6 KB

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