App.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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. import { timeComputed, space, openMap } from '@/utils/rocessor.js';
  13. import { groom1, loadIndexs, getIndexData, getStoreList, getCouponsList, getCoupon } from '@/api/index.js';
  14. export default {
  15. data() {
  16. return {
  17. /* 保存微信信息 */
  18. appData: {}
  19. };
  20. },
  21. methods: {
  22. ...mapMutations('user', ['setUserInfo', 'login', 'hasLogin','setDes','setStoreInfo','setLatlng', 'setLatitude', 'setLongitude','logout']),
  23. getaddress() {
  24. let obj = this;
  25. uni.getLocation({
  26. type: 'gcj02',
  27. success: res => {
  28. uni.removeStorageSync('latlon');
  29. let latlon = Math.abs(res.latitude) + ',' + Math.abs(res.longitude);
  30. console.log('app页+++++++++++++++++++++')
  31. obj.setLatlng(latlon);
  32. obj.setLatitude(Math.abs(res.latitude));
  33. obj.setLongitude(Math.abs(res.longitude));
  34. uni.setStorageSync('latlon', latlon);
  35. obj.setMrStore(Math.abs(res.latitude), Math.abs(res.longitude));
  36. },
  37. fail: err => {
  38. console.log('失败')
  39. openMap().then(e => {
  40. this.getaddress();
  41. });
  42. }
  43. });
  44. },
  45. setMrStore(latitude = '', longitude = '') {
  46. //checkedStore
  47. getStoreList({
  48. latitude: latitude,
  49. longitude: longitude,
  50. page: 1,
  51. limit: 1
  52. }).then(({ data }) => {
  53. console.log(data, '店面列表');
  54. if (data.list[0]) {
  55. // data.list[0].space = data.list[0].latitude + ',' + data.list[0].longitude;
  56. this.setDes(data.list[0].distance);
  57. this.setStoreInfo(data.list[0]);
  58. }
  59. });
  60. },
  61. },
  62. onLaunch: function(urlObj) {
  63. let obj = this;
  64. console.log('app 开始')
  65. //清除店铺缓存newStore
  66. uni.removeStorageSync('newStore')
  67. // obj.logout()
  68. // 加载缓存中的用户信息
  69. let userInfo = uni.getStorageSync('userInfo') || '';
  70. let checkedStore = uni.getStorageSync('store') || ''
  71. // 判断是否拥有用户信息
  72. if (userInfo.uid) {
  73. //更新登陆状态
  74. uni.getStorage({
  75. key: 'userInfo',
  76. success: res => {
  77. obj.setUserInfo(res.data);
  78. obj.login(res.data);
  79. }
  80. });
  81. }else {
  82. obj.logout()
  83. }
  84. this.getaddress()
  85. // if(checkedStore.id) {
  86. // console.log('有店铺信息')
  87. // //保存店铺信息
  88. // uni.getStorage({
  89. // key: 'store',
  90. // success: res => {
  91. // obj.setStoreInfo(res.data);
  92. // }
  93. // });
  94. // }else {
  95. // console.log('无店铺信息')
  96. // this.getaddress()
  97. // }
  98. // #ifdef H5
  99. // 保存路由对象
  100. setRouter(this.$router);
  101. //判断是否已经缓存浏览器
  102. let bool = uni.getStorageSync('weichatBrowser') || '';
  103. if (bool === '') {
  104. //判断是否为微信浏览
  105. bool = navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger';
  106. // 保存当前是否为微信内核浏览器
  107. uni.setStorageSync('weichatBrowser', bool);
  108. }
  109. if (bool) {
  110. // 加载微信信息
  111. weixindata();
  112. }
  113. // #endif
  114. // #ifdef APP-PLUS
  115. // 判断是否升级
  116. getUpApp();
  117. // 获取当前运行系统
  118. let system = uni.getStorageSync('platform') || '';
  119. if (!system) {
  120. uni.setStorage({
  121. key: 'platform',
  122. data: uni.getSystemInfoSync().platform
  123. });
  124. }
  125. // #endif
  126. },
  127. onShow: function() {
  128. // 加载拦截
  129. // console.log('App Show');
  130. },
  131. onHide: function() {
  132. // console.log('App Hide');
  133. }
  134. };
  135. </script>
  136. <style lang="scss">
  137. /*全局公共样式和字体图标*/
  138. @import '/static/css/cmy.css';
  139. view,
  140. scroll-view,
  141. swiper,
  142. swiper-item,
  143. cover-view,
  144. cover-image,
  145. icon,
  146. text,
  147. rich-text,
  148. progress,
  149. button,
  150. checkbox,
  151. form,
  152. input,
  153. label,
  154. radio,
  155. slider,
  156. switch,
  157. textarea,
  158. navigator,
  159. audio,
  160. camera,
  161. image,
  162. video {
  163. box-sizing: border-box;
  164. }
  165. /* 骨架屏替代方案 */
  166. .Skeleton {
  167. background: #f3f3f3;
  168. padding: 20rpx 0;
  169. border-radius: 8rpx;
  170. }
  171. /* 图片载入替代方案 */
  172. .image-wrapper {
  173. font-size: 0;
  174. background: #f3f3f3;
  175. border-radius: 4px;
  176. image {
  177. width: 100%;
  178. height: 100%;
  179. transition: 0.6s;
  180. opacity: 0;
  181. &.loaded {
  182. opacity: 1;
  183. }
  184. }
  185. }
  186. // 设置富文本中图片最大宽度
  187. uni-rich-text img {
  188. max-width: 100% !important;
  189. }
  190. /*边框*/
  191. .b-b:after,
  192. .b-t:after {
  193. position: absolute;
  194. z-index: 3;
  195. left: 0;
  196. right: 0;
  197. height: 0;
  198. content: '';
  199. transform: scaleY(0.5);
  200. border-bottom: 1px solid $border-color-base;
  201. }
  202. .b-b:after {
  203. bottom: 0;
  204. }
  205. .b-t:after {
  206. top: 0;
  207. }
  208. /* button样式改写 */
  209. uni-button,
  210. button {
  211. height: 80rpx;
  212. line-height: 80rpx;
  213. font-size: $font-lg + 2rpx;
  214. font-weight: normal;
  215. &.no-border:before,
  216. &.no-border:after {
  217. border: 0;
  218. }
  219. }
  220. uni-button[type='default'],
  221. button[type='default'] {
  222. color: $font-color-dark;
  223. }
  224. /* input 样式 */
  225. .input-placeholder {
  226. color: #999999;
  227. }
  228. .placeholder {
  229. color: #999999;
  230. }
  231. // 边距样式
  232. @for $i from 1 to 4 {
  233. .margin-l-#{$i * 10} {
  234. margin-left: $i * 10rpx !important;
  235. }
  236. .margin-r-#{$i * 10} {
  237. margin-right: $i * 10rpx !important;
  238. }
  239. .margin-t-#{$i * 10} {
  240. margin-top: $i * 10rpx !important;
  241. }
  242. .margin-b-#{$i * 10} {
  243. margin-bottom: $i * 10rpx !important;
  244. }
  245. .margin-#{$i * 10} {
  246. margin: $i * 10rpx !important;
  247. }
  248. .margin-v-#{$i * 10} {
  249. margin-top: $i * 10rpx !important;
  250. margin-bottom: $i * 10rpx !important;
  251. }
  252. .margin-c-#{$i * 10} {
  253. margin-left: $i * 10rpx !important;
  254. margin-right: $i * 10rpx !important;
  255. }
  256. .padding-l-#{$i * 10} {
  257. padding-left: $i * 10rpx !important;
  258. }
  259. .padding-r-#{$i * 10} {
  260. padding-right: $i * 10rpx !important;
  261. }
  262. .padding-t-#{$i * 10} {
  263. padding-top: $i * 10rpx !important;
  264. }
  265. .padding-b-#{$i * 10} {
  266. padding-bottom: $i * 10rpx !important;
  267. }
  268. .padding-#{$i * 10} {
  269. padding: $i * 10rpx !important;
  270. }
  271. .padding-v-#{$i * 10} {
  272. padding-top: $i * 10rpx !important;
  273. padding-bottom: $i * 10rpx !important;
  274. }
  275. .padding-c-#{$i * 10} {
  276. padding-left: $i * 10rpx !important;
  277. padding-right: $i * 10rpx !important;
  278. }
  279. }
  280. // 字体大小
  281. .font-size-sm {
  282. font-size: $font-sm;
  283. }
  284. .font-size-base {
  285. font-size: $font-base;
  286. }
  287. .font-size-lg {
  288. font-size: $font-lg;
  289. }
  290. // 字体颜色
  291. .font-color-yellow {
  292. color: $color-yellow;
  293. }
  294. .font-color-gray {
  295. color: $color-gray;
  296. }
  297. .font-color-red {
  298. color: $color-red;
  299. }
  300. // 边框颜色
  301. .border-color-yellow {
  302. border: 1rpx solid $color-yellow;
  303. }
  304. // 修改默认背景颜色
  305. uni-page-wrapper {
  306. background-color: $page-color-base;
  307. }
  308. page {
  309. background-color: $page-color-base;
  310. // 设置默认字体
  311. font-family: PingFang SC, STHeitiSC-Light, Helvetica-Light, arial, sans-serif, Droid Sans Fallback;
  312. }
  313. //首页边框
  314. $border: solid 4rpx #ECD49E;
  315. $background-image: url(https://zccy.liuniu946.com/static/img/frame-1.png),
  316. url(https://zccy.liuniu946.com/static/img/frame-2.png),
  317. url(https://zccy.liuniu946.com/static/img/frame-4.png),
  318. url(https://zccy.liuniu946.com/static/img/frame-3.png);
  319. $background-repeat: no-repeat, no-repeat, no-repeat, no-repeat;
  320. $background-position: top left, top right, bottom left, bottom right;
  321. .border-index {
  322. border-radius: 10rpx;
  323. background-color: #FFFFFF;
  324. border: $border;
  325. background-image: $background-image;
  326. background-repeat: $background-repeat;
  327. background-position: $background-position;
  328. }
  329. .scroll_box{
  330. overflow: hidden;
  331. white-space: nowrap;
  332. }
  333. .item_list{
  334. height: auto;
  335. display: inline-block;
  336. }
  337. </style>