App.vue 5.9 KB

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