takeout.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. <template>
  2. <view class="takeout-index iPhone-bottom flex-common-css box-border-box">
  3. <view class="bg-index"></view>
  4. <view class="">
  5. <Nav :leftShow='false' :customNav='true' :bgckgroundBox='bgckgroundBox'>
  6. <template>
  7. <view slot="custom" class="">
  8. <view class="align-items-center mb-28 s-input-f">
  9. <uni-icons @click="toBack()" type="left" size="20"></uni-icons>
  10. <view v-if="!isScroll" class="fs-40 ml-10 fw-600">外卖</view>
  11. <view v-else class="s-input s-input-c" :class="isScroll?'w-454':'w-100100'">
  12. <view class="input-icon s-left">
  13. <uni-icons type="search" size="22" color="#999"></uni-icons>
  14. </view>
  15. <input v-model="search" type="text" @confirm='searchClick' confirm-type="search"
  16. placeholder="请输入商家或者商品名称">
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. </Nav>
  22. </view>
  23. <scroll-view scroll-y="true" class="scroll-view-css" @scrolltolower="scrolltolower" @scroll="scrollFun">
  24. <view class="">
  25. <view class="s-input box-border-box plr-24">
  26. <view class="input-icon">
  27. <uni-icons type="search" size="22" color="#999"></uni-icons>
  28. </view>
  29. <input class="input-box" v-model="search" type="text" @confirm='searchClick' confirm-type="search"
  30. placeholder="请输入商家或者商品名称">
  31. <view class="fs-28 fc-f index-search-box-buttom" @click="searchClick">搜索</view>
  32. </view>
  33. <!-- <view class="p-24 box-border-box">
  34. <view class="index-search-box box-border-box align-items-center">
  35. <uni-icons type="search" size="22" color="#999"></uni-icons>
  36. <view class="fs-28 fc-9 ml-10">搜索店铺名称或者商品名称</view>
  37. <view class="fs-28 fc-f index-search-box-buttom">搜索</view>
  38. </view>
  39. </view> -->
  40. <view class="box-border-box plr-24">
  41. <view class="shop-box mb-32 box-border-box p-16">
  42. <image class="shop-box-bg" src="@/static/img/takeout/bg.png" mode="scaleToFill"></image>
  43. <swiper class="swiper-tj" easing-function="easeInOutCubic" :circular='true'
  44. :current='BanenerCurrent' @change="onSwiperChange" :autoplay="true" :interval="3000"
  45. :duration="500">
  46. <swiper-item v-for="(item,i) in topShopData" :key="i" @click="toShop(item)">
  47. <view class="swiper-item display-flex">
  48. <view class="left-img-box">
  49. <image class="left-img" :src="item.shop_logo" mode="aspectFill"></image>
  50. <view class="status-box fc-f" v-if="item.status != 1">
  51. 休息中
  52. </view>
  53. </view>
  54. <view class="right-box flex-1">
  55. <view class="align-items-center mb-8">
  56. <view class="right-box-title fs-32 fw-600 text-overflow-ellipsis-one">
  57. {{item.shop_name}}
  58. </view>
  59. <image class="right-box-title-img" src="@/static/img/toRight.png" mode="">
  60. </image>
  61. </view>
  62. <view class="align-items-center mb-12">
  63. <image class="img-x mr-12" src="@/static/img/my/wdpj.png" mode=""></image>
  64. <view class="fs-26 fw-600 fc-FF7F00 mr-12">{{item.shop_score}}分</view>
  65. <view class="fc-6 fs-24 mr-12">| 预计{{item.delivery_time}}分钟 |</view>
  66. <view class="fc-6 fs-24 mr-12">{{item.shop_sales}}人购买</view>
  67. </view>
  68. <view class="align-items-center flex-wrap-wrap">
  69. <view class="quan-list display-flex mr-12 mb-12"
  70. v-for="(itemCoupon,iCoupon) in item.coupon" :key="iCoupon">
  71. <view class="quan-list-1 fs-24 fc-f">券</view>
  72. <view class="quan-list-2 fs-24 fc-FB3D03">{{itemCoupon.money}}元</view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </swiper-item>
  78. </swiper>
  79. <view class="align-items-center dot-f">
  80. <view :class="BanenerCurrent === i?'dot-box-s':'dot-box'" v-for="(item,i) in topShopData"
  81. :key="i">
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. <view class="box-border-box plr-24 nav-type-box-f" :class="isScroll?'nav-bg':''">
  87. <scroll-view class="nav-type-box" scroll-x="true">
  88. <view class="nav-type-list" @click="clickClass(0)">
  89. <image src="@/static/img/takeout/all.png" mode=""></image>
  90. <view :class="category_id == 0?'fc-41ABF5':''" class="fs-24 fw-400 text-align-center">全部
  91. </view>
  92. </view>
  93. <view class="nav-type-list" v-for="(item,i) in navList" :key="i" @click="clickClass(item.id)">
  94. <image :src="item.img" mode=""></image>
  95. <view class="fs-24 fw-400" :class="category_id == item.id?'fc-41ABF5':''">{{item.name}}
  96. </view>
  97. </view>
  98. </scroll-view>
  99. </view>
  100. <scroll-view :scroll-y="true" class="box-border-box plr-24 mt-24" @scrolltolower="scrollList">
  101. <EnBlank :customSrc='true' v-if="listData<= 0">
  102. <template v-slot:blankImg>
  103. <image class="black-custom-img" src="@/static/img/common/no-order.png" mode=""></image>
  104. </template>
  105. </EnBlank>
  106. <view class="" v-else>
  107. <view class="goos-list-box box-border-box" v-for="(item,i) in listData" :key='i' @click="toShop(item)">
  108. <view class="display-flex p-b-20 mb-26 b-b-EFF2F5">
  109. <view class="left-img-box mr-24">
  110. <image class="left-img" :src="item.shop_logo" mode="aspectFill"></image>
  111. <view class="status-box fc-f" v-if="item.status != 1">
  112. 休息中
  113. </view>
  114. </view>
  115. <view class="flex-1">
  116. <view class="align-items-center mb-8">
  117. <view class="right-box-title fs-28 fw-600 text-overflow-ellipsis-one">
  118. {{item.shop_name}}
  119. </view>
  120. <image class="right-box-title-img" src="@/static/img/toRight.png" mode="">
  121. </image>
  122. </view>
  123. <view class="align-items-center mb-12">
  124. <image class="img-x mr-8" src="@/static/img/my/wdpj.png" mode=""></image>
  125. <view class="fs-24 fw-600 fc-FF7F00 mr-12">{{item.shop_score}}</view>
  126. <view class="fc-0 fs-24 mr-12">预计{{item.delivery_time}}分钟 |</view>
  127. <view class="fc-0 fs-24 mr-12">{{item.shop_sales}}人购买</view>
  128. </view>
  129. <view class="align-items-center flex-wrap-wrap">
  130. <view class="quan-list b-F5541E box-border-box bgc-f align-items-center b-rad-5 mr-10" v-for="(info1,index1) in item.coupon" :key="index1">
  131. <image class="quan-list-1" src="@/static/img/index/q.png" mode=""></image>
  132. <view class="quan-list-2 fs-24 fc-F5531E">{{info1.money}}元</view>
  133. </view>
  134. </view>
  135. </view>
  136. </view>
  137. <view class="goods-items-list display-flex">
  138. <view class="goods-items-list-box" v-for="(info2,index2) in item.goods" :key="index2">
  139. <view v-show="info2.label === 3"
  140. class="label-box text-align-center bgc-F5811E fs-24 fc-f">
  141. 推荐</view>
  142. <view v-show="info2.label === 2"
  143. class="label-box text-align-center bgc-FF5555 fs-24 fc-f">
  144. 新品</view>
  145. <view v-show="info2.label === 1"
  146. class="label-box text-align-center bgc-48D3C5 fs-24 fc-f">
  147. 折扣</view>
  148. <view v-show="info2.label === 4"
  149. class="label-box text-align-center bgc-4db8ff fs-24 fc-f">
  150. 招牌</view>
  151. <image class="mb-18" :src="info2.goods_image" mode="aspectFill"></image>
  152. <view class="mb-12 fw-600 text-overflow-ellipsis-one fs-24">{{info2.goods_name}}
  153. </view>
  154. <view class="">
  155. <span class="fs-24 fc-FD5D05 fw-b">¥</span>
  156. <span class="fs-32 fc-FD5D05 fw-b">{{info2.price}}</span>
  157. </view>
  158. </view>
  159. </view>
  160. </view>
  161. <view class="pt-40 flex-direction align-items-center" v-if="listData.length === listTotal">
  162. <view class="fs-32 fc-0 fw-b">
  163. 小主都到这里了
  164. </view>
  165. <view class="fs-32 fc-0 fw-b mb-26">
  166. 还没有找到满意的店铺吗?
  167. </view>
  168. <view class="fs-24 fc-0 mb-32">
  169. 可以提交你意见与反馈哟。我们一定尽快努力达成!
  170. </view>
  171. <view class="list-but align-items-center flex-justify-center bgc-5CC2FF"
  172. @click="goFeedback">
  173. <view class="fs-28 fc-f mr-10">
  174. 去提交
  175. </view>
  176. <view class="sj-fff"></view>
  177. </view>
  178. </view>
  179. </view>
  180. </scroll-view>
  181. <!-- <view class="box-border-box plr-24 mt-24">
  182. </view> -->
  183. </view>
  184. </scroll-view>
  185. </view>
  186. </template>
  187. <script>
  188. import EnBlank from "@/components/en-utils/en-blank/en-blank";
  189. import {
  190. shopTop
  191. } from "@/api/shop.js"
  192. import {
  193. getGoodsList
  194. } from "@/api/goods.js"
  195. import {
  196. getTakeaway
  197. } from "@/api/category.js"
  198. import {
  199. shopInfo
  200. } from "@/api/shop.js"
  201. import tools from "@/service/tools";
  202. export default {
  203. components: {
  204. EnBlank
  205. },
  206. data() {
  207. return {
  208. bgckgroundBox: 'transparent',
  209. BanenerCurrent: 0,
  210. search: '',
  211. category_id: 0,
  212. isScroll: false,
  213. topShopData: [],
  214. page: 1,
  215. listData: [],
  216. navList: [],
  217. listTotal: 0
  218. }
  219. },
  220. mounted() {
  221. this.shopTop()
  222. this.getGoodsList()
  223. this.getTakeaway()
  224. },
  225. methods: {
  226. searchClick() {
  227. console.log("898989898998");
  228. this.listData = []
  229. this.getGoodsList()
  230. },
  231. clickClass(id) {
  232. if (this.category_id == id) {
  233. return
  234. }
  235. console.log(this.page);
  236. this.page = 1
  237. this.category_id = id
  238. this.listData = []
  239. this.getGoodsList()
  240. },
  241. toBack() {
  242. tools.leftClick()
  243. },
  244. onSwiperChange(e) {
  245. this.BanenerCurrent = e.detail.current;
  246. },
  247. scrollFun(e) {
  248. if (e.target.scrollTop > 60) {
  249. this.isScroll = true;
  250. } else {
  251. this.isScroll = false;
  252. }
  253. },
  254. scrollList() {},
  255. scrolltolower() {
  256. if (this.listTotal > this.listData.length) {
  257. ++this.page
  258. this.getGoodsList()
  259. }
  260. console.log('触底');
  261. },
  262. toShop(item) {
  263. const operate_id = uni.getStorageSync('operate_id')
  264. shopInfo({
  265. operate_id: operate_id,
  266. shop_id: item.shop_id
  267. }).then((res) => {
  268. if (res.code == 1) {
  269. uni.navigateTo({
  270. url: '/pages-takeout/shop?shop_id=' + item.shop_id
  271. })
  272. } else {
  273. tools.error(res.msg)
  274. }
  275. })
  276. },
  277. shopTop() {
  278. const operate_id = uni.getStorageSync('operate_id')
  279. shopTop({
  280. operate_id: operate_id
  281. }).then((res) => {
  282. if (res.code == 1) {
  283. this.topShopData = res.data
  284. }
  285. })
  286. },
  287. getGoodsList() {
  288. const operate_id = uni.getStorageSync('operate_id')
  289. getGoodsList({
  290. operate_id: operate_id,
  291. category_id: this.category_id,
  292. search: this.search,
  293. page: this.page
  294. }).then((res) => {
  295. if (res.code == 1) {
  296. if (res.data.items.length > 0) {
  297. this.listData.push(...res.data.items)
  298. this.listTotal = res.data.total
  299. }
  300. }
  301. })
  302. },
  303. getTakeaway() {
  304. getTakeaway().then((res) => {
  305. if (res.code == 1) {
  306. this.navList = res.data
  307. }
  308. })
  309. }
  310. },
  311. }
  312. </script>
  313. <style scoped lang="scss">
  314. .list-but {
  315. width: 140rpx;
  316. height: 48rpx;
  317. line-height: 48rpx;
  318. border-radius: 24rpx;
  319. }
  320. .sj-fff {
  321. width: 0;
  322. height: 0;
  323. border-top: 8rpx solid transparent;
  324. border-right: 8rpx solid transparent;
  325. border-left: 8rpx solid #fff;
  326. border-bottom: 8rpx solid transparent;
  327. }
  328. .index-search-box-buttom {
  329. width: 120rpx;
  330. height: 60rpx;
  331. position: absolute;
  332. z-index: 100;
  333. right: 30rpx;
  334. top: 6rpx;
  335. background: linear-gradient(90deg, #57CAFF 0%, #41ABF5 100%);
  336. border-radius: 200rpx;
  337. margin-left: auto;
  338. line-height: 60rpx;
  339. text-align: center;
  340. }
  341. .takeout-index {
  342. position: relative;
  343. .s-input-f {
  344. position: relative;
  345. .s-input-c {
  346. position: absolute;
  347. top: -16rpx;
  348. left: 50rpx;
  349. }
  350. }
  351. .bg-index {
  352. width: 100%;
  353. height: 272rpx;
  354. position: absolute;
  355. top: 0;
  356. left: 0;
  357. background-image: linear-gradient(#E0F6FB, #F5F4F9);
  358. z-index: -1;
  359. }
  360. .w-100100 {
  361. width: 100%;
  362. }
  363. .w-454 {
  364. width: 454rpx;
  365. }
  366. .s-input {
  367. margin-bottom: 24rpx;
  368. height: 72rpx;
  369. box-sizing: border-box;
  370. position: relative;
  371. .s-left {
  372. left: 24rpx !important;
  373. }
  374. .input-icon {
  375. position: absolute;
  376. left: 44rpx;
  377. top: 16rpx;
  378. }
  379. input {
  380. font-size: 32rpx;
  381. width: 100%;
  382. height: 72rpx;
  383. background: #FFFFFF;
  384. border-radius: 200rpx;
  385. box-sizing: border-box;
  386. padding: 0 120rpx 0 78rpx;
  387. border: 1rpx solid #41ABF5;
  388. }
  389. }
  390. .shop-box {
  391. width: 100%;
  392. height: 242rpx;
  393. position: relative;
  394. .shop-box-bg {
  395. width: 100%;
  396. height: 242rpx;
  397. position: absolute;
  398. top: 0;
  399. left: 0;
  400. z-index: -1;
  401. }
  402. .swiper-tj {
  403. width: 100%;
  404. height: 172rpx;
  405. border-radius: 20rpx;
  406. .swiper-item {
  407. width: 100%;
  408. height: 100%;
  409. border-radius: 20rpx;
  410. background-color: #fff;
  411. box-sizing: border-box;
  412. padding: 16rpx;
  413. .left-img-box {
  414. width: 140rpx;
  415. height: 140rpx;
  416. margin-right: 14rpx;
  417. position: relative;
  418. .left-img {
  419. width: 140rpx;
  420. height: 140rpx;
  421. border-radius: 12rpx;
  422. }
  423. .status-box {
  424. position: absolute;
  425. bottom: 0;
  426. left: 0;
  427. width: 100%;
  428. padding: 10rpx 0;
  429. text-align: center;
  430. background: rgba(0, 0, 0, 0.5);
  431. font-size: 20rpx;
  432. border-radius: 0 0 12rpx 12rpx;
  433. }
  434. }
  435. .right-box {}
  436. }
  437. }
  438. .dot-f {
  439. margin: 20rpx auto;
  440. justify-content: center;
  441. .dot-box {
  442. width: 8rpx;
  443. height: 6rpx;
  444. background: #FEC683;
  445. border-radius: 200rpx;
  446. margin: 0 6rpx;
  447. }
  448. .dot-box-s {
  449. width: 16rpx;
  450. height: 6rpx;
  451. background: #FF7F00;
  452. border-radius: 200rpx;
  453. margin: 0 6rpx;
  454. }
  455. }
  456. }
  457. .nav-bg {
  458. background-image: linear-gradient(#F0F4FA, #FFFFFF);
  459. padding: 24rpx !important;
  460. }
  461. .nav-type-box-f {
  462. position: sticky;
  463. top: 0;
  464. left: 0;
  465. z-index: 9999;
  466. .nav-type-box {
  467. width: 100%;
  468. height: 120rpx;
  469. display: flex;
  470. // overflow: scroll;
  471. white-space: nowrap;
  472. .nav-type-list {
  473. display: inline-block;
  474. height: 120rpx;
  475. width: 96rpx !important;
  476. text-align: center;
  477. margin-right: 44rpx;
  478. image {
  479. display: block;
  480. width: 80rpx;
  481. height: 80rpx;
  482. margin: 0 8rpx 12rpx 8rpx;
  483. }
  484. }
  485. }
  486. }
  487. .goos-list-box {
  488. width: 100%;
  489. min-height: 100rpx;
  490. padding: 28rpx 30rpx 35rpx;
  491. background: #FFFFFF;
  492. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(51, 51, 51, 0.1);
  493. border-radius: 20rpx;
  494. margin-bottom: 20rpx;
  495. .goods-items-list {
  496. width: 100%;
  497. overflow-y: scroll;
  498. .goods-items-list-box {
  499. width: 33.3%;
  500. margin-right: 13rpx;
  501. position: relative;
  502. .label-box {
  503. position: absolute;
  504. left: 0;
  505. top: 0;
  506. width: 66rpx;
  507. height: 31rpx;
  508. line-height: 31rpx;
  509. border-radius: 10rpx 2rpx 10rpx 2rpx;
  510. }
  511. image {
  512. width: 201rpx;
  513. height: 200rpx;
  514. border-radius: 10rpx
  515. }
  516. }
  517. }
  518. }
  519. .left-img-box {
  520. width: 120rpx;
  521. height: 120rpx;
  522. position: relative;
  523. .left-img {
  524. width: 120rpx;
  525. height: 120rpx;
  526. border-radius: 12rpx;
  527. }
  528. .status-box {
  529. position: absolute;
  530. bottom: 0;
  531. left: 0;
  532. width: 100%;
  533. padding: 4rpx 0;
  534. text-align: center;
  535. background: rgba(0, 0, 0, 0.5);
  536. font-size: 17rpx;
  537. border-radius: 0 0 12rpx 12rpx;
  538. }
  539. }
  540. .img-x {
  541. width: 16rpx;
  542. height: 16rpx;
  543. }
  544. .right-box-title {
  545. width: 438rpx;
  546. }
  547. .right-box-title-img {
  548. width: 32rpx;
  549. height: 32rpx;
  550. margin-left: auto;
  551. }
  552. .quan-list {
  553. min-width: 88rpx;
  554. height: 28rpx;
  555. line-height: 28rpx;
  556. .quan-list-1 {
  557. width: 38rpx;
  558. height: 28rpx;
  559. }
  560. }
  561. }
  562. .index-search {
  563. position: sticky;
  564. left: 0;
  565. z-index: 10;
  566. padding: 0 24rpx 20rpx 24rpx;
  567. .index-search-box {
  568. width: 100%;
  569. height: 72rpx;
  570. padding: 0 6rpx 0 24rpx;
  571. border-radius: 200rpx;
  572. .index-search-box-buttom {
  573. width: 120rpx;
  574. height: 60rpx;
  575. background: linear-gradient(-90deg, #3BB5FE, #62C4FF);
  576. border-radius: 200rpx;
  577. margin-left: auto;
  578. line-height: 60rpx;
  579. text-align: center;
  580. }
  581. }
  582. }
  583. </style>