App.vue 5.5 KB

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