index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  1. <template>
  2. <view>
  3. <view class="head-box">
  4. <view class="navbar"></view>
  5. <view class="container">
  6. <view class="left">
  7. <view class="logo">
  8. <image src="../../static/img/logo96x96.png" mode="aspectFit"></image>
  9. </view>
  10. <view class="">
  11. byqMarket
  12. </view>
  13. </view>
  14. <!-- <view class="right" :style="'padding-right: ' + MPPR + 'px'">
  15. <view class="address-box">
  16. <i class="hxicon-locationfill"></i>
  17. <text>幸福花园</text>
  18. <i class="hxicon-right"></i>
  19. </view>
  20. <view class="notice">
  21. <i class="hxicon-notice"></i>
  22. </view>
  23. </view> -->
  24. </view>
  25. </view>
  26. <view class=" bannerimg-box">
  27. <swiper circular duration="400" interval="10000" autoplay>
  28. <swiper-item class="swiper-item bannerImg" v-for="(item,index) in bannerData" :key="index">
  29. 图片尺寸为 750*250
  30. <!-- <image :src="item.src" class="loaded" mode="widthFix"></image> -->
  31. </swiper-item>
  32. </swiper>
  33. </view>
  34. <!-- <view class="search-box" :class="{'QZBG':GDHEAD}" :style="GDHEAD ? 'padding-right: ' + MPPR + 'px' : ''">
  35. <view class="navbar" ></view>
  36. <view class="ctn">
  37. <view class="hx-search-box" @click="goSearch">
  38. <uni-icons type="search" size="22" color="#666666" />
  39. <text>输入搜索关键词</text>
  40. </view>
  41. </view>
  42. </view> -->
  43. <!-- <view class="container">
  44. <view class="hot-box">
  45. <text class="item" v-for="(item,i) in hos_list" :key="i">{{item}}</text>
  46. </view>
  47. </view> -->
  48. <mescroll-body ref="mescrollRef" :down="downOption" @down="downCallback" @up="upCallback">
  49. <!--
  50. <view class="container menu-box">
  51. <view class="item-box" v-for="(item,i) in menuList" :key="i">
  52. <image :src="item.img" mode=""></image>
  53. <view class="tit">
  54. <text>{{item.tit}}</text>
  55. </view>
  56. </view>
  57. </view> -->
  58. <view class="container gg-box">
  59. <view class="item-ggbox" v-for="(item,i) in menuList" :key="i" @click="toGGdetail">
  60. <image :src="item.img" mode=""></image>
  61. <view class="tit">
  62. <view class="title">{{item.tit}}</view>
  63. <view class="date">2022-01-01</view>
  64. </view>
  65. </view>
  66. </view>
  67. <!-- <view class="container margin-top sort-box">
  68. <view class="item-box" v-for="(item,i) in sortList" :key="i">
  69. <view class="tit" :class="{'active': sortIndex == i}">
  70. <text>{{item.tit}}</text>
  71. </view>
  72. </view>
  73. </view>
  74. <view class=" store-box" v-if="storeList">
  75. <view class=" item-box" v-for="(store,i) in storeList" :key="i">
  76. <view class="container top-box">
  77. <view class="left" @click="toStore(store,null)">
  78. <image :src="store.avatar" mode="aspectFill"></image>
  79. </view>
  80. <view class="right" @click="toStore(store,null)">
  81. <text class="tit">{{store.name}}({{store.community}})</text>
  82. <view class="row justify-content">
  83. <view class="row-left">
  84. <i class="hxicon-favorfill "></i>
  85. <text class="t1">{{store.mark}}</text>
  86. <text class="t2">月售{{store.monthly_sales}}</text>
  87. </view>
  88. <view class="row-right">
  89. <i class="hxicon-locationfill"></i>
  90. <text>{{store.distance}}</text>
  91. </view>
  92. </view>
  93. <view class="row">
  94. <text>起送¥{{store.starting_price}}</text>
  95. <text class="t2" v-if="store.shipping_dees > 0">配送¥{{store.shipping_dees}} </text>
  96. <text class="t2" v-else>免费配送</text>
  97. </view>
  98. </view>
  99. </view>
  100. <scroll-view scroll-x class="bottom-box">
  101. <view class="bottom-box-container">
  102. <view class="goods-box" v-for="(goods,j) in store.goods" :key="j"
  103. @click="toStore(store,goods.id)">
  104. <view class="img-box">
  105. <image :src="goods.main_pic" mode="aspectFit"></image>
  106. <view class="tag">
  107. {{goods.tag}}
  108. </view>
  109. </view>
  110. <view class="tit">
  111. {{goods.name}}
  112. </view>
  113. <view class="price-box">
  114. <text class="txt1">¥</text>
  115. <text class="txt2">{{goods.price}}</text>
  116. <text class="txt3">¥{{goods.old_price}}</text>
  117. </view>
  118. </view>
  119. </view>
  120. </scroll-view>
  121. </view>
  122. </view> -->
  123. </mescroll-body>
  124. <view class="footzw"></view>
  125. </view>
  126. </template>
  127. <script>
  128. import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue"
  129. import MescrollUni from "@/components/mescroll-uni/mescroll-uni.vue"
  130. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  131. //引入测试数据
  132. import testData from "@/common/testdata.js";
  133. const screenHeight = uni.getSystemInfoSync().screenHeight;
  134. export default {
  135. mixins: [MescrollMixin],
  136. components: {
  137. MescrollBody
  138. },
  139. // onPageScroll(e) {
  140. // let that = this;
  141. // if (e.scrollTop > 10) {
  142. // let view = uni.createSelectorQuery().select(".search-box");
  143. // view.fields({
  144. // rect: true
  145. // }, res => {
  146. // if (res.top == 0) {
  147. // that.GDHEAD = 1;
  148. // } else {
  149. // that.GDHEAD = 0;
  150. // }
  151. // }).exec();
  152. // }
  153. // },
  154. data() {
  155. return {
  156. MPPR: 0,
  157. GDHEAD: 0,
  158. //显示没有更多商户
  159. showFoot: 0,
  160. downOption: {
  161. auto: false //是否在初始化后,自动执行downCallback; 默认true
  162. },
  163. menuList: [
  164. {
  165. img: '/static/img/index/cs.png',
  166. tit: '超市百货'
  167. },
  168. {
  169. img: '/static/img/index/sc.png',
  170. tit: '绿色果蔬'
  171. },
  172. {
  173. img: '/static/img/index/sg.png',
  174. tit: '生鲜鱼肉'
  175. },
  176. {
  177. img: '/static/img/index/xh.png',
  178. tit: '鲜花礼品'
  179. },
  180. {
  181. img: '/static/img/index/yd.png',
  182. tit: '送药到家'
  183. }
  184. ],
  185. sortIndex: 0,
  186. sortList: [{
  187. tit: '附近商户'
  188. }, {
  189. tit: '销量'
  190. }, {
  191. tit: '速度'
  192. }, {
  193. tit: '配送费'
  194. }],
  195. //filterTagList: [{tit:'支持预定'}, {tit:'销量'}, {tit:'速度'}, {tit:'配送费'}]
  196. storeList: [],
  197. bannerData: [{
  198. page: '/pages/product/product?id=457',
  199. src: '@/static/img/coupon_dq.png'
  200. },
  201. {
  202. page: '/pages/product/product?id=57',
  203. src: '//imgs.1op.cn/i/hxshop/banner/banner.jpg'
  204. },
  205. {
  206. page: '/pages/product/product?id=95',
  207. src: '//imgs.1op.cn/i/hxshop/banner/banner.jpg'
  208. },
  209. {
  210. page: '/pages/product/product?id=45',
  211. src: '//imgs.1op.cn/i/hxshop/banner/banner.jpg'
  212. }
  213. ],
  214. hos_list: [
  215. '红烧排骨',
  216. '飞过肉',
  217. '野生大菠萝',
  218. '红烧排骨',
  219. '西红柿蛋汤'
  220. ]
  221. }
  222. },
  223. onLoad() {
  224. let that = this;
  225. // #ifdef MP
  226. //小程序下空出胶囊距离
  227. let m = uni.getMenuButtonBoundingClientRect();
  228. that.MPPR = m.width + 8
  229. // #endif
  230. },
  231. mounted() {
  232. let that = this;
  233. },
  234. methods: {
  235. toGGdetail(id) {
  236. uni.navigateTo({
  237. url: "/pages/index/detail"
  238. })
  239. },
  240. /*下拉刷新的回调 */
  241. downCallback() {
  242. // that.$request.baseRequest('post', '/evaluateInfo/api/addEvaluateInfo', _data).then(res => {
  243. // if (res.code==200) {
  244. // this.$refs.uToast.show({
  245. // type: 'success',
  246. // message: "评价成功",
  247. // complete() {
  248. // uni.navigateTo({
  249. // url: '/pages/order/index'
  250. // })
  251. // }
  252. // })
  253. // }else{
  254. // this.$refs.uToast.show({
  255. // type: 'error',
  256. // message: "评价失败",
  257. // })
  258. // }
  259. // })
  260. let that = this;
  261. //联网成功的回调,隐藏下拉刷新的状态
  262. that.mescroll.endSuccess();
  263. // setTimeout(()=>{
  264. // that.mescroll.endSuccess();
  265. // },1500)
  266. //联网失败的回调,隐藏下拉刷新的状态
  267. //this.mescroll.endErr();
  268. },
  269. upCallback(page) {
  270. let that = this;
  271. //加载门店数据
  272. that.storeList = testData.storeList;
  273. //无更多商家
  274. that.showFoot = true;
  275. //隐藏加载
  276. that.mescroll.endSuccess(10);
  277. // setTimeout(()=>{
  278. // //加载门店数据
  279. // that.storeList = testData.storeList;
  280. // //无更多商家
  281. // that.showFoot = true;
  282. // //隐藏加载
  283. // that.mescroll.endSuccess(10);
  284. // },1500)
  285. },
  286. toStore(store, goodsID) {
  287. let store_id = store.store_id
  288. let parameter = `?sid=${store_id}`
  289. if (goodsID != null) {
  290. parameter += `&gid=${goodsID}`
  291. }
  292. uni.navigateTo({
  293. url: '/pages/store/index' + parameter
  294. })
  295. },
  296. //搜索
  297. goSearch() {
  298. uni.navigateTo({
  299. url: '/pages/search/search?type=home'
  300. })
  301. }
  302. }
  303. }
  304. </script>
  305. <style lang="scss">
  306. .gg-box {
  307. .item-ggbox {
  308. margin-bottom: 20rpx;
  309. background: white;
  310. border-radius: 20rpx;
  311. .tit {
  312. padding: 20rpx;
  313. box-sizing: border-box;
  314. .title {
  315. font-weight: 700;
  316. font-size: 32rpx;
  317. margin-bottom: 20rpx;
  318. }
  319. }
  320. }
  321. }
  322. .b-b {
  323. position: relative;
  324. }
  325. .b-b:after,
  326. .b-t:after {
  327. position: absolute;
  328. z-index: 3;
  329. left: 0;
  330. right: 0;
  331. height: 0;
  332. content: '';
  333. transform: scaleY(.5);
  334. border-bottom: 1px solid #E4E7ED;
  335. }
  336. .b-b:after {
  337. bottom: 0;
  338. }
  339. .b-t:after {
  340. top: 0;
  341. }
  342. .container {
  343. margin: 0 15px;
  344. }
  345. .margin-top {
  346. margin-top: 12px;
  347. }
  348. .head-box {
  349. padding: 14px 0;
  350. /* #ifdef MP */
  351. padding-top: 2px;
  352. /* #endif */
  353. background: linear-gradient(100deg, #FFEB3B, #FFC107);
  354. position: relative;
  355. z-index: 3;
  356. .navbar {
  357. position: sticky;
  358. top: 0;
  359. height: var(--status-bar-height);
  360. }
  361. .container {
  362. display: flex;
  363. flex-direction: row;
  364. justify-content: space-between;
  365. height: 32px;
  366. align-items: center;
  367. .left {
  368. display: flex;
  369. align-items: center;
  370. .logo {
  371. width: 32px;
  372. height: 32px;
  373. margin-right: 20rpx;
  374. image {
  375. width: 32px;
  376. height: 32px;
  377. border-radius: 50%;
  378. }
  379. }
  380. }
  381. .right {
  382. display: flex;
  383. flex-direction: row;
  384. color: #333333;
  385. align-items: center;
  386. .address-box {
  387. font-size: 14px;
  388. margin-right: 16px;
  389. display: flex;
  390. flex-direction: row;
  391. align-items: center;
  392. text {
  393. margin-left: 2px;
  394. margin-right: 4px;
  395. }
  396. .icon-right {
  397. position: relative;
  398. top: 2px;
  399. }
  400. }
  401. .notice {
  402. font-weight: bold;
  403. font-size: 18px;
  404. }
  405. }
  406. }
  407. }
  408. .search-box {
  409. position: sticky;
  410. top: 0;
  411. z-index: 2;
  412. background: linear-gradient(100deg, #FFEB3B, #FFC107);
  413. padding-top: var(--status-bar-height);
  414. margin-top: calc(var(--status-bar-height) * -1);
  415. .ctn {
  416. border-top-left-radius: 50upx;
  417. border-top-right-radius: 50upx;
  418. background: #f8f8f8;
  419. padding: 15px 15px 12px;
  420. .hx-search-box {
  421. border-radius: 40px;
  422. padding: 0 15px;
  423. height: 34px;
  424. display: flex;
  425. align-items: center;
  426. line-height: 44rpx;
  427. background-color: #eeeeee;
  428. flex: 1;
  429. color: #888888;
  430. font-size: 14px;
  431. }
  432. }
  433. }
  434. .loaded {
  435. background: red;
  436. }
  437. .QZBG {
  438. background: #ffffff;
  439. box-shadow: 0 1px 6px #ccc;
  440. .navbar {
  441. height: var(--status-bar-height);
  442. }
  443. .ctn {
  444. background: #ffffff;
  445. /* #ifdef MP */
  446. padding-top: 0px;
  447. /* #endif */
  448. }
  449. }
  450. .hot-box {
  451. display: flex;
  452. flex-direction: row;
  453. flex-wrap: wrap;
  454. justify-content: flex-start;
  455. .item {
  456. margin-right: 12px;
  457. background-color: #EEEEEE;
  458. color: #666666;
  459. font-size: 12px;
  460. border-radius: 20px;
  461. padding: 2px 6px;
  462. margin-bottom: 8px;
  463. }
  464. .item:last-child {
  465. margin-right: 0;
  466. }
  467. }
  468. .bannerimg-box {
  469. border-bottom-left-radius: 10upx;
  470. border-bottom-right-radius: 10upx;
  471. padding: 24rpx;
  472. swiper {
  473. height: 233rpx;
  474. width: 699rpx;
  475. }
  476. .swiper-item {
  477. background: red;
  478. display: flex;
  479. justify-content: center;
  480. align-content: center;
  481. overflow: hidden;
  482. width: 100%;
  483. height: 100%;
  484. image {
  485. border-radius: 8px;
  486. width: 100%;
  487. }
  488. }
  489. }
  490. .menu-box {
  491. display: flex;
  492. flex-direction: row;
  493. justify-content: space-between;
  494. margin-top: 12px;
  495. border-radius: 8px;
  496. background: #ffffff;
  497. padding: 12px 8px;
  498. .item-box {
  499. display: flex;
  500. flex-direction: column;
  501. justify-content: center;
  502. align-items: center;
  503. image {
  504. width: 40px;
  505. height: 40px;
  506. }
  507. .tit {
  508. display: flex;
  509. justify-content: center;
  510. align-items: center;
  511. font-size: 12px;
  512. margin-top: 6px;
  513. color: #333333;
  514. padding: 2px 0;
  515. white-space: nowrap;
  516. overflow: hidden;
  517. text-overflow: ellipsis;
  518. }
  519. .active {
  520. color: #ffffff;
  521. background-color: #999999;
  522. border-radius: 60px;
  523. }
  524. }
  525. }
  526. .sort-box {
  527. display: flex;
  528. flex-direction: row;
  529. margin-top: 12px;
  530. .item-box {
  531. margin-right: 16px;
  532. .tit {
  533. display: flex;
  534. justify-content: center;
  535. align-items: center;
  536. font-size: 12px;
  537. color: #333333;
  538. white-space: nowrap;
  539. overflow: hidden;
  540. text-overflow: ellipsis;
  541. }
  542. .active {
  543. //color: #111111;
  544. font-weight: bold;
  545. }
  546. }
  547. }
  548. .store-box {
  549. margin-top: 20px;
  550. .item-box {
  551. display: flex;
  552. flex-direction: column;
  553. margin-bottom: 14px;
  554. padding-bottom: 18px;
  555. padding-top: 18px;
  556. background-color: #ffffff;
  557. .top-box {
  558. display: flex;
  559. flex-direction: row;
  560. .left {
  561. margin-right: 10px;
  562. image {
  563. width: 72px;
  564. height: 54px;
  565. border-radius: 6px;
  566. }
  567. }
  568. .right {
  569. flex: 1;
  570. .tit {
  571. font-size: 16px;
  572. font-weight: bold;
  573. color: #333333;
  574. white-space: nowrap;
  575. overflow: hidden;
  576. text-overflow: ellipsis;
  577. }
  578. .justify-content {
  579. display: flex;
  580. flex-direction: row;
  581. justify-content: space-between;
  582. }
  583. .row {
  584. font-size: 12px;
  585. color: #999999;
  586. margin-top: 4px;
  587. .row-left {
  588. display: flex;
  589. flex-direction: row;
  590. .t1,
  591. i {
  592. color: #ffca3e;
  593. }
  594. }
  595. .t2 {
  596. margin-left: 12px;
  597. }
  598. .row-right {
  599. display: flex;
  600. flex-direction: row;
  601. i {
  602. margin-right: 4px;
  603. }
  604. }
  605. }
  606. }
  607. }
  608. .bottom-box {
  609. &-container {
  610. margin: 12px 0 0;
  611. padding-left: 82px;
  612. white-space: nowrap;
  613. .goods-box {
  614. width: 80px;
  615. margin-left: 12px;
  616. display: inline-block;
  617. .img-box {
  618. position: relative;
  619. width: 80px;
  620. height: 60px;
  621. background-color: #f1f1f1;
  622. border-radius: 4px;
  623. image {
  624. width: 100%;
  625. height: 60px;
  626. }
  627. .tag {
  628. position: absolute;
  629. bottom: 0;
  630. left: 0;
  631. background-color: #FF5722;
  632. color: #ffffff;
  633. padding: 2px 4px;
  634. font-size: 12px;
  635. border-radius: 4px;
  636. }
  637. }
  638. .tit {
  639. font-size: 14px;
  640. margin-top: 4px;
  641. white-space: nowrap;
  642. overflow: hidden;
  643. text-overflow: ellipsis;
  644. }
  645. .price-box {
  646. margin-top: 4px;
  647. .txt1 {
  648. font-size: 10px;
  649. color: #FF5722;
  650. }
  651. .txt2 {
  652. font-size: 16px;
  653. color: #FF5722;
  654. }
  655. .txt3 {
  656. margin-left: 6px;
  657. font-size: 10px;
  658. color: #bbbbbb;
  659. text-decoration: line-through;
  660. }
  661. }
  662. }
  663. .goods-box:last-child {
  664. margin-right: 12px;
  665. }
  666. }
  667. }
  668. }
  669. .item-box:last-child {
  670. border-bottom: 0;
  671. }
  672. }
  673. .foot {
  674. position: relative;
  675. display: flex;
  676. justify-content: center;
  677. margin-top: 36px;
  678. margin-bottom: 50px;
  679. text {
  680. font-size: 14px;
  681. position: relative;
  682. z-index: 2;
  683. height: 20px;
  684. line-height: 20px;
  685. background-color: #f8f8f8;
  686. color: #cccccc;
  687. padding: 0 12px;
  688. }
  689. }
  690. .foot::before {
  691. content: "";
  692. z-index: 1;
  693. display: block;
  694. position: absolute;
  695. top: 50%;
  696. height: 0;
  697. width: 100%;
  698. transform: scaleY(0.5);
  699. border-bottom: 1px solid #E4E7ED;
  700. }
  701. .footzw {
  702. /* #ifdef H5*/
  703. height: 50px;
  704. /* #endif */
  705. }
  706. </style>