index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. <template>
  2. <!-- 商品分类 -->
  3. <view :style="colorStyle">
  4. <!-- 门店的两种样式布局 -->
  5. <storeCate1 v-if="home_style==1" :info="info" :customerType="customer_type" ref="refresh2">
  6. </storeCate1>
  7. <storeCate2 v-else-if="home_style==2" :cart_num="cart_num" :info="info" :customerType="customer_type" ref="refresh">
  8. </storeCate2>
  9. </view>
  10. </template>
  11. <script>
  12. import {
  13. mapState,
  14. mapGetters
  15. } from 'vuex';
  16. import colors from "@/mixins/color";
  17. import storeCate1 from './store_cate1.vue'
  18. import storeCate2 from './store_cate2.vue'
  19. import {
  20. getnearbyStore
  21. } from '@/api/new_store.js'
  22. import {
  23. colorChange
  24. } from '@/api/api.js';
  25. import {
  26. getCartCounts
  27. } from '@/api/order.js';
  28. // #ifdef MP
  29. import util from '@/utils/util.js';
  30. // #endif
  31. export default {
  32. computed: {
  33. ...mapState({
  34. nearbyStore: state => state.app.nearbyStore
  35. }),
  36. ...mapGetters(['isLogin', 'uid'])
  37. },
  38. components: {
  39. storeCate1,
  40. storeCate2,
  41. },
  42. mixins: [colors],
  43. data() {
  44. return {
  45. info: {},
  46. id: 0,
  47. category: '',
  48. home_style: 0,
  49. customer_type: 1,
  50. where: {
  51. latitude: 0,
  52. longitude: 0,
  53. store_id: 0
  54. },
  55. cart_num: 0,
  56. mapFrom: 0,
  57. }
  58. },
  59. watch: {
  60. nearbyStore(value) {
  61. this.where.store_id = value;
  62. this.getStore();
  63. }
  64. },
  65. onLoad(options) {
  66. // #ifdef MP
  67. if (options.scene) {
  68. options = util.getUrlParams(decodeURIComponent(options.scene));
  69. }
  70. // #endif
  71. this.where.store_id = this.nearbyStore;
  72. if (options.mapFrom) {
  73. this.mapFrom = options.mapFrom;
  74. }
  75. if (options.id) {
  76. this.where.store_id = options.id;
  77. uni.setStorageSync('user_store_id', options.id);
  78. }
  79. // this.mapFrom = options.mapFrom || 0;
  80. // this.where.store_id = options.id;
  81. // uni.setStorageSync('user_store_id', options.id);
  82. try {
  83. this.where.latitude = uni.getStorageSync('user_latitude');
  84. this.where.longitude = uni.getStorageSync('user_longitude');
  85. if (options.mapFrom == 1) {
  86. this.getStore();
  87. //this.getCartNum(options.id);
  88. } else {
  89. this.selfLocation();
  90. if (!this.$util.checkOpenGPSServiceByAndroidIOS()) {
  91. this.getStore();
  92. }
  93. }
  94. } catch (e) {
  95. this.getStore();
  96. }
  97. },
  98. onUnload() {
  99. this.mapFrom = 0;
  100. uni.$off('newAttrNum')
  101. },
  102. onHide() {
  103. this.mapFrom = 0;
  104. },
  105. onShow() {
  106. // if(uni.getStorageSync('form_type_cart')){
  107. // this.getStore();
  108. // }
  109. if (this.mapFrom == 0) {
  110. if (this.home_style == 1) {
  111. setTimeout(() => {
  112. this.$refs.refresh2.getNoCart();
  113. }, 10)
  114. }
  115. }
  116. },
  117. onPageScroll(e) {
  118. uni.$emit('onPageScroll', e);
  119. uni.$emit('scroll');
  120. },
  121. onReachBottom: function() {
  122. uni.$emit('onReachBottom');
  123. },
  124. methods: {
  125. otherFun(object) {
  126. if (!!object) {
  127. if (this.home_style == 1) {
  128. this.$refs.refresh2.updateFun(object);
  129. }
  130. }
  131. },
  132. selfLocation() {
  133. let self = this
  134. // #ifdef H5
  135. if (self.$wechat.isWeixin()) {
  136. self.$wechat.location().then(res => {
  137. // this.where.latitude = res.latitude;
  138. // this.where.longitude = res.longitude;
  139. uni.setStorageSync('user_latitude', res.latitude);
  140. uni.setStorageSync('user_longitude', res.longitude);
  141. self.getStore();
  142. }).catch(err => {
  143. self.getStore();
  144. })
  145. } else {
  146. // #endif
  147. uni.getLocation({
  148. type: 'gcj02',
  149. success: (res) => {
  150. try {
  151. // this.where.latitude = res.latitude;
  152. // this.where.longitude = res.longitude;
  153. uni.setStorageSync('user_latitude', res.latitude);
  154. uni.setStorageSync('user_longitude', res.longitude);
  155. } catch {}
  156. // self.getStore();
  157. },
  158. fail: (err) => {
  159. // return self.$util.Tips({
  160. // title: err.errMsg
  161. // });
  162. },
  163. complete: function() {
  164. self.getStore();
  165. }
  166. });
  167. // #ifdef H5
  168. }
  169. // #endif
  170. },
  171. // 获取接口附近门店
  172. getStore() {
  173. // this.where.latitude = uni.getStorageSync('user_latitude');
  174. // this.where.longitude = uni.getStorageSync('user_longitude');
  175. getnearbyStore(this.where).then(res => {
  176. let data = res.data;
  177. let info = data.info;
  178. if (Object.prototype.toString.call(info) === '[object Array]') {
  179. info = {};
  180. }
  181. this.info = {
  182. // #ifdef H5 || MP
  183. store_splicing_switch: data.store_splicing_switch,
  184. // #endif
  185. store_self_mention: parseInt(data.store_self_mention),
  186. ...info,
  187. };
  188. this.cart_num = data.cart_num;
  189. this.customer_type = parseInt(info.customer_type);
  190. this.home_style = info.home_style || 0;
  191. this.id = info.id || 0;
  192. uni.setStorageSync('user_store_id', this.id);
  193. if (this.home_style === 1) {
  194. setTimeout(() => {
  195. // this.$refs.refresh2.getAllCategory();
  196. if (this.isLogin) {
  197. this.$refs.refresh2.getCartList(1);
  198. }
  199. }, 10)
  200. } else if (this.home_style === 2) {
  201. setTimeout(() => {
  202. // this.$refs.refresh.where.store_id = this.id
  203. // this.$refs.refresh.loadend = false
  204. // this.$refs.refresh.getProducts(true)
  205. })
  206. }
  207. })
  208. },
  209. },
  210. }
  211. </script>
  212. <style lang="scss">
  213. page {
  214. background: #F5F5F5;
  215. }
  216. /deep/.footer {
  217. position: fixed;
  218. right: 20rpx;
  219. left: 20rpx;
  220. bottom: 36rpx;
  221. bottom: calc(36rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  222. bottom: calc(36rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  223. z-index: 101;
  224. .cartIcon {
  225. position: absolute;
  226. bottom: 0;
  227. left: 0;
  228. width: 96rpx;
  229. height: 96rpx;
  230. border-radius: 48rpx;
  231. background: linear-gradient(-90deg, var(--view-gradient), var(--view-theme));
  232. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.1);
  233. .image-wrap {
  234. width: 96rpx;
  235. height: 96rpx;
  236. border-radius: 48rpx;
  237. text-align: center;
  238. line-height: 96rpx;
  239. }
  240. .image {
  241. width: 54rpx;
  242. height: 54rpx;
  243. vertical-align: middle;
  244. }
  245. }
  246. .inner-box {
  247. position: absolute;
  248. bottom: 0;
  249. left: 0;
  250. width: 96rpx;
  251. height: 96rpx;
  252. border-radius: 48rpx;
  253. overflow: hidden;
  254. transition: 0.3s;
  255. &.open {
  256. width: 100%;
  257. }
  258. }
  259. .inner {
  260. flex-wrap: nowrap;
  261. height: 96rpx;
  262. padding: 0 12rpx 0 128rpx;
  263. border-radius: 48rpx;
  264. background: #333333;
  265. }
  266. .btn {
  267. width: 186rpx;
  268. height: 72rpx;
  269. padding: 0 32rpx;
  270. background: linear-gradient(-90deg, var(--view-gradient) 0%, var(--view-theme) 100%);
  271. border-radius: 36rpx;
  272. text-align: center;
  273. font-weight: 500;
  274. font-size: 26rpx;
  275. line-height: 72rpx;
  276. color: #FFFFFF;
  277. }
  278. .detail-btn {
  279. margin-left: 16rpx;
  280. font-size: 24rpx;
  281. color: #FFFFFF;
  282. .iconfont {
  283. font-size: 24rpx;
  284. }
  285. }
  286. }
  287. /deep/.goodCate .uni-badge-left-margin .uni-badge--error {
  288. background-color: #fff !important;
  289. color: var(--view-theme);
  290. border-color: var(--view-theme);
  291. z-index: 8;
  292. }
  293. /deep/.goodCate .footer .cartIcon .uni-badge-left-margin .uni-badge--error {
  294. right: 0 !important;
  295. top: 10px !important;
  296. }
  297. /deep/.one .uni-badge-left-margin .uni-badge--error {
  298. background-color: var(--view-theme) !important;
  299. color: #fff;
  300. border-color: #fff;
  301. z-index: 8;
  302. }
  303. /deep/.mask {
  304. z-index: 99;
  305. }
  306. /deep/.good-cate {
  307. padding: 80rpx;
  308. }
  309. /deep/.address-window {
  310. /* #ifdef H5 */
  311. bottom: 94rpx !important;
  312. bottom: calc(94rpx+ constant(safe-area-inset-bottom)) !important; ///兼容 IOS<11.2/
  313. bottom: calc(94rpx + env(safe-area-inset-bottom)) !important; ///兼容 IOS>11.2/
  314. /* #endif */
  315. /* #ifndef H5 */
  316. bottom: 98rpx;
  317. bottom: calc(98rpx + constant(safe-area-inset-bottom)) !important; ///兼容 IOS<11.2/
  318. bottom: calc(98rpx + env(safe-area-inset-bottom)) !important; ///兼容 IOS>11.2/
  319. /* #endif */
  320. &.ons {
  321. bottom: 0 !important;
  322. bottom: constant(safe-area-inset-bottom) !important; ///兼容 IOS<11.2/
  323. bottom: env(safe-area-inset-bottom) !important; ///兼容 IOS>11.2/
  324. }
  325. }
  326. /deep/.dialog_nav::before {
  327. margin: 0;
  328. }
  329. /deep/.dialog_nav {
  330. &.dialogIndex {
  331. &::before {
  332. left: -172rpx !important;
  333. }
  334. }
  335. }
  336. /deep/.menu_box {
  337. width: 40rpx;
  338. height: 40rpx;
  339. margin-right: 20rpx;
  340. .iconfont {
  341. font-size: 40rpx;
  342. color: #FFFFFF;
  343. }
  344. }
  345. /deep/.tui-drawer-container_right {
  346. left: 80rpx !important;
  347. border-radius: 50rpx 0 0 50rpx;
  348. }
  349. /deep/.tui-header {
  350. .tui-list-cell {
  351. padding: 24rpx 10rpx !important;
  352. font-size: 24rpx !important;
  353. color: #333333 !important;
  354. &::after {
  355. display: none;
  356. }
  357. }
  358. .open {
  359. font-size: 20rpx;
  360. color: #999999;
  361. }
  362. }
  363. .brand-box {
  364. /deep/.tui-header {
  365. .tui-list-cell {
  366. padding: 24rpx 0 !important;
  367. font-weight: 500;
  368. font-size: 28rpx !important;
  369. }
  370. }
  371. }
  372. /deep/.input-box.fixed {
  373. background: #FFFFFF;
  374. top: 0;
  375. right: 0;
  376. left: 0;
  377. z-index: 10;
  378. .input {
  379. background: #F5F5F5;
  380. color: #999999;
  381. }
  382. .menu_box .iconfont {
  383. color: #333333;
  384. }
  385. }
  386. /* #ifdef H5 || MP */
  387. .dialog {
  388. padding: 44rpx 20rpx 0;
  389. padding-bottom: constant(safe-area-inset-bottom);
  390. padding-bottom: env(safe-area-inset-bottom);
  391. border-radius: 40rpx 40rpx 0 0;
  392. background: linear-gradient(180deg, #F5F5F5 0%, #F5F5F5 0%, #FFFFFF 100%);
  393. }
  394. .dialog-head {
  395. padding: 0 24rpx;
  396. font-weight: 500;
  397. font-size: 32rpx;
  398. color: #333333;
  399. .btn {
  400. width: 40rpx;
  401. height: 40rpx;
  402. cursor: pointer;
  403. .iconfont {
  404. font-size: 40rpx;
  405. color: #BBBBBB;
  406. }
  407. }
  408. }
  409. .dialog-body {
  410. margin-top: 48rpx;
  411. .navbar {
  412. flex-shrink: 0;
  413. position: relative;
  414. height: 82rpx;
  415. .navbar-bg {
  416. position: absolute;
  417. top: 0;
  418. left: 0;
  419. width: 100%;
  420. height: 190rpx;
  421. border-radius: 16rpx 16rpx 0 0;
  422. background: #EEEEEE;
  423. }
  424. .active-bg {
  425. position: absolute;
  426. bottom: 0;
  427. left: 0;
  428. width: 100%;
  429. height: 96rpx;
  430. .image1 {
  431. width: 50%;
  432. height: 100%;
  433. }
  434. .image2 {
  435. width: 48rpx;
  436. height: 78rpx;
  437. }
  438. }
  439. .inner {
  440. position: absolute;
  441. bottom: 0;
  442. left: 0;
  443. width: 100%;
  444. height: 100%;
  445. .item {
  446. flex: 1;
  447. min-width: 0;
  448. font-size: 28rpx;
  449. line-height: 44rpx;
  450. color: #666666;
  451. .iconfont {
  452. display: none;
  453. margin-right: 8rpx;
  454. font-size: 36rpx;
  455. }
  456. &.on {
  457. font-weight: 500;
  458. font-size: 32rpx;
  459. color: var(--view-theme);
  460. .iconfont {
  461. display: inline-block;
  462. }
  463. }
  464. }
  465. }
  466. }
  467. .dialog-content {
  468. position: relative;
  469. border-radius: 0 0 16rpx 16rpx;
  470. background: #FFFFFF;
  471. &.btl {
  472. border-top-left-radius: 24rpx;
  473. }
  474. &.btr {
  475. border-top-right-radius: 24rpx;
  476. }
  477. .link {
  478. padding: 40rpx 32rpx;
  479. font-size: 22rpx;
  480. line-height: 30rpx;
  481. color: #999999;
  482. .title {
  483. margin-bottom: 16rpx;
  484. font-weight: 500;
  485. font-size: 28rpx;
  486. line-height: 40rpx;
  487. color: #333333;
  488. }
  489. .iconfont {
  490. font-size: 32rpx;
  491. }
  492. }
  493. }
  494. .address-box {
  495. height: 388rpx;
  496. .list {
  497. padding: 36rpx 32rpx;
  498. }
  499. .item {
  500. margin-top: 32rpx;
  501. color: #333333;
  502. &:first-child {
  503. margin-top: 0;
  504. }
  505. .text {
  506. flex: 1;
  507. }
  508. .info {
  509. font-weight: 500;
  510. font-size: 28rpx;
  511. line-height: 40rpx;
  512. }
  513. .name {
  514. margin-top: 8rpx;
  515. font-size: 22rpx;
  516. line-height: 30rpx;
  517. color: #999999;
  518. }
  519. .iconfont {
  520. visibility: hidden;
  521. font-size: 36rpx;
  522. }
  523. &.on {
  524. color: var(--view-theme);
  525. .name {
  526. color: var(--view-theme);
  527. }
  528. .iconfont {
  529. visibility: visible;
  530. }
  531. }
  532. }
  533. }
  534. .btn-box {
  535. height: 88rpx;
  536. font-size: 24rpx;
  537. line-height: 34rpx;
  538. color: #666666;
  539. .iconfont {
  540. margin-left: 4rpx;
  541. font-size: 24rpx;
  542. }
  543. }
  544. .store-box {
  545. padding: 40rpx 28rpx 40rpx 32rpx;
  546. .text {
  547. flex: 1;
  548. }
  549. .name {
  550. font-weight: 500;
  551. font-size: 28rpx;
  552. line-height: 40rpx;
  553. color: #333333;
  554. }
  555. .info {
  556. margin-top: 16rpx;
  557. font-size: 22rpx;
  558. line-height: 30rpx;
  559. color: #999999;
  560. }
  561. .value {
  562. flex: 1;
  563. }
  564. .iconfont {
  565. margin-right: 12rpx;
  566. font-size: 22rpx;
  567. }
  568. .map-box {
  569. position: relative;
  570. width: 188rpx;
  571. height: 104rpx;
  572. margin-left: 32rpx;
  573. .map {
  574. width: 100%;
  575. height: 100%;
  576. }
  577. .img-box {
  578. position: absolute;
  579. bottom: 16rpx;
  580. left: 50%;
  581. width: 52rpx;
  582. height: 52rpx;
  583. padding: 6rpx;
  584. border-radius: 6rpx;
  585. background: #FFFFFF;
  586. box-shadow: 0rpx 0rpx 12rpx 0rpx rgba(0, 0, 0, 0.0784);
  587. transform: translateX(-50%);
  588. }
  589. .img {
  590. width: 100%;
  591. height: 100%;
  592. border-radius: 6rpx;
  593. }
  594. .range {
  595. position: absolute;
  596. top: -40rpx;
  597. left: 50%;
  598. height: 36rpx;
  599. padding: 0 16rpx;
  600. border-radius: 6rpx;
  601. background: #FFFFFF;
  602. box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(0, 0, 0, 0.0784);
  603. transform: translateX(-50%);
  604. white-space: nowrap;
  605. font-size: 20rpx;
  606. line-height: 36rpx;
  607. color: #333333;
  608. &::after {
  609. content: "";
  610. position: absolute;
  611. bottom: 0;
  612. left: 50%;
  613. width: 0;
  614. height: 0;
  615. border-width: 5rpx 9rpx;
  616. border-style: solid;
  617. border-color: #FFFFFF transparent transparent;
  618. transform: translate(-50%, 100%);
  619. }
  620. }
  621. .dot {
  622. position: absolute;
  623. bottom: -10rpx;
  624. left: 50%;
  625. width: 6rpx;
  626. height: 6rpx;
  627. border-radius: 50%;
  628. background: var(--view-theme);
  629. transform: translateX(-50%);
  630. }
  631. }
  632. }
  633. }
  634. .dialog-foot {
  635. padding: 20rpx 0;
  636. .btn {
  637. height: 72rpx;
  638. border-radius: 36rpx;
  639. background: var(--view-theme);
  640. text-align: center;
  641. font-weight: 500;
  642. font-size: 26rpx;
  643. line-height: 72rpx;
  644. color: #FFFFFF;
  645. }
  646. }
  647. /* #endif */
  648. </style>