takeout.vue 16 KB

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