takeout.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  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. goFeedback() {
  232. // 问题反馈
  233. uni.navigateTo({
  234. url: '/pages-my/feedback'
  235. })
  236. },
  237. searchClick() {
  238. console.log("898989898998");
  239. this.listData = []
  240. this.getGoodsList()
  241. },
  242. clickClass(id) {
  243. if (this.category_id == id) {
  244. return
  245. }
  246. console.log(this.page);
  247. this.page = 1
  248. this.category_id = id
  249. this.listData = []
  250. this.getGoodsList()
  251. },
  252. toBack() {
  253. tools.leftClick()
  254. },
  255. onSwiperChange(e) {
  256. this.BanenerCurrent = e.detail.current;
  257. },
  258. scrollFun(e) {
  259. if (e.target.scrollTop > 60) {
  260. this.isScroll = true;
  261. } else {
  262. this.isScroll = false;
  263. }
  264. },
  265. scrollList() {},
  266. scrolltolower() {
  267. if (this.listTotal > this.listData.length) {
  268. ++this.page
  269. this.getGoodsList()
  270. }
  271. console.log('触底');
  272. },
  273. toShop(item) {
  274. const operate_id = uni.getStorageSync('operate_id')
  275. shopInfo({
  276. operate_id: operate_id,
  277. shop_id: item.shop_id
  278. }).then((res) => {
  279. if (res.code == 1) {
  280. uni.navigateTo({
  281. url: '/pages-takeout/shop?shop_id=' + item.shop_id
  282. })
  283. } else {
  284. tools.error(res.msg)
  285. }
  286. })
  287. },
  288. shopTop() {
  289. const operate_id = uni.getStorageSync('operate_id')
  290. shopTop({
  291. operate_id: operate_id
  292. }).then((res) => {
  293. if (res.code == 1) {
  294. this.topShopData = res.data
  295. }
  296. })
  297. },
  298. getGoodsList() {
  299. const operate_id = uni.getStorageSync('operate_id')
  300. getGoodsList({
  301. operate_id: operate_id,
  302. category_id: this.category_id,
  303. search: this.search,
  304. page: this.page
  305. }).then((res) => {
  306. if (res.code == 1) {
  307. if (res.data.items.length > 0) {
  308. this.listData.push(...res.data.items)
  309. this.listTotal = res.data.total
  310. }
  311. }
  312. })
  313. },
  314. getTakeaway() {
  315. getTakeaway().then((res) => {
  316. if (res.code == 1) {
  317. this.navList = res.data
  318. }
  319. })
  320. }
  321. },
  322. }
  323. </script>
  324. <style scoped lang="scss">
  325. .list-but {
  326. width: 140rpx;
  327. height: 48rpx;
  328. line-height: 48rpx;
  329. border-radius: 24rpx;
  330. }
  331. .sj-fff {
  332. width: 0;
  333. height: 0;
  334. border-top: 8rpx solid transparent;
  335. border-right: 8rpx solid transparent;
  336. border-left: 8rpx solid #fff;
  337. border-bottom: 8rpx solid transparent;
  338. }
  339. .index-search-box-buttom {
  340. width: 120rpx;
  341. height: 60rpx;
  342. position: absolute;
  343. z-index: 100;
  344. right: 30rpx;
  345. top: 6rpx;
  346. background: linear-gradient(90deg, #57CAFF 0%, #41ABF5 100%);
  347. border-radius: 200rpx;
  348. margin-left: auto;
  349. line-height: 60rpx;
  350. text-align: center;
  351. }
  352. .takeout-index {
  353. position: relative;
  354. .s-input-f {
  355. position: relative;
  356. .s-input-c {
  357. position: absolute;
  358. top: -16rpx;
  359. left: 50rpx;
  360. }
  361. }
  362. .bg-index {
  363. width: 100%;
  364. height: 272rpx;
  365. position: absolute;
  366. top: 0;
  367. left: 0;
  368. background-image: linear-gradient(#E0F6FB, #F5F4F9);
  369. z-index: -1;
  370. }
  371. .w-100100 {
  372. width: 100%;
  373. }
  374. .w-454 {
  375. width: 454rpx;
  376. }
  377. .s-input {
  378. margin-bottom: 24rpx;
  379. height: 72rpx;
  380. box-sizing: border-box;
  381. position: relative;
  382. .s-left {
  383. left: 24rpx !important;
  384. }
  385. .input-icon {
  386. position: absolute;
  387. left: 44rpx;
  388. top: 16rpx;
  389. }
  390. input {
  391. font-size: 32rpx;
  392. width: 100%;
  393. height: 72rpx;
  394. background: #FFFFFF;
  395. border-radius: 200rpx;
  396. box-sizing: border-box;
  397. padding: 0 120rpx 0 78rpx;
  398. border: 1rpx solid #41ABF5;
  399. }
  400. }
  401. .shop-box {
  402. width: 100%;
  403. height: 242rpx;
  404. position: relative;
  405. .shop-box-bg {
  406. width: 100%;
  407. height: 242rpx;
  408. position: absolute;
  409. top: 0;
  410. left: 0;
  411. z-index: -1;
  412. }
  413. .swiper-tj {
  414. width: 100%;
  415. height: 172rpx;
  416. border-radius: 20rpx;
  417. .swiper-item {
  418. width: 100%;
  419. height: 100%;
  420. border-radius: 20rpx;
  421. background-color: #fff;
  422. box-sizing: border-box;
  423. padding: 16rpx;
  424. .left-img-box {
  425. width: 140rpx;
  426. height: 140rpx;
  427. margin-right: 14rpx;
  428. position: relative;
  429. .left-img {
  430. width: 140rpx;
  431. height: 140rpx;
  432. border-radius: 12rpx;
  433. }
  434. .status-box {
  435. position: absolute;
  436. bottom: 0;
  437. left: 0;
  438. width: 100%;
  439. padding: 10rpx 0;
  440. text-align: center;
  441. background: rgba(0, 0, 0, 0.5);
  442. font-size: 20rpx;
  443. border-radius: 0 0 12rpx 12rpx;
  444. }
  445. }
  446. .right-box {}
  447. }
  448. }
  449. .dot-f {
  450. margin: 20rpx auto;
  451. justify-content: center;
  452. .dot-box {
  453. width: 8rpx;
  454. height: 6rpx;
  455. background: #FEC683;
  456. border-radius: 200rpx;
  457. margin: 0 6rpx;
  458. }
  459. .dot-box-s {
  460. width: 16rpx;
  461. height: 6rpx;
  462. background: #FF7F00;
  463. border-radius: 200rpx;
  464. margin: 0 6rpx;
  465. }
  466. }
  467. }
  468. .nav-bg {
  469. background-image: linear-gradient(#F0F4FA, #FFFFFF);
  470. padding: 24rpx !important;
  471. }
  472. .nav-type-box-f {
  473. position: sticky;
  474. top: 0;
  475. left: 0;
  476. z-index: 9999;
  477. .nav-type-box {
  478. width: 100%;
  479. height: 120rpx;
  480. display: flex;
  481. // overflow: scroll;
  482. white-space: nowrap;
  483. .nav-type-list {
  484. display: inline-block;
  485. height: 120rpx;
  486. width: 96rpx !important;
  487. text-align: center;
  488. margin-right: 44rpx;
  489. image {
  490. display: block;
  491. width: 80rpx;
  492. height: 80rpx;
  493. margin: 0 8rpx 12rpx 8rpx;
  494. }
  495. }
  496. }
  497. }
  498. .goos-list-box {
  499. width: 100%;
  500. min-height: 100rpx;
  501. padding: 28rpx 30rpx 35rpx;
  502. background: #FFFFFF;
  503. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(51, 51, 51, 0.1);
  504. border-radius: 20rpx;
  505. margin-bottom: 20rpx;
  506. .goods-items-list {
  507. width: 100%;
  508. overflow-y: scroll;
  509. .goods-items-list-box {
  510. width: 33.3%;
  511. margin-right: 13rpx;
  512. position: relative;
  513. .label-box {
  514. position: absolute;
  515. left: 0;
  516. top: 0;
  517. width: 66rpx;
  518. height: 31rpx;
  519. line-height: 31rpx;
  520. border-radius: 10rpx 2rpx 10rpx 2rpx;
  521. }
  522. image {
  523. width: 201rpx;
  524. height: 200rpx;
  525. border-radius: 10rpx
  526. }
  527. }
  528. }
  529. }
  530. .left-img-box {
  531. width: 120rpx;
  532. height: 120rpx;
  533. position: relative;
  534. .left-img {
  535. width: 120rpx;
  536. height: 120rpx;
  537. border-radius: 12rpx;
  538. }
  539. .status-box {
  540. position: absolute;
  541. bottom: 0;
  542. left: 0;
  543. width: 100%;
  544. padding: 4rpx 0;
  545. text-align: center;
  546. background: rgba(0, 0, 0, 0.5);
  547. font-size: 17rpx;
  548. border-radius: 0 0 12rpx 12rpx;
  549. }
  550. }
  551. .img-x {
  552. width: 16rpx;
  553. height: 16rpx;
  554. }
  555. .right-box-title {
  556. width: 438rpx;
  557. }
  558. .right-box-title-img {
  559. width: 32rpx;
  560. height: 32rpx;
  561. margin-left: auto;
  562. }
  563. .quan-list {
  564. min-width: 88rpx;
  565. height: 28rpx;
  566. line-height: 28rpx;
  567. .quan-list-1 {
  568. width: 38rpx;
  569. height: 28rpx;
  570. }
  571. }
  572. }
  573. .index-search {
  574. position: sticky;
  575. left: 0;
  576. z-index: 10;
  577. padding: 0 24rpx 20rpx 24rpx;
  578. .index-search-box {
  579. width: 100%;
  580. height: 72rpx;
  581. padding: 0 6rpx 0 24rpx;
  582. border-radius: 200rpx;
  583. .index-search-box-buttom {
  584. width: 120rpx;
  585. height: 60rpx;
  586. background: linear-gradient(-90deg, #3BB5FE, #62C4FF);
  587. border-radius: 200rpx;
  588. margin-left: auto;
  589. line-height: 60rpx;
  590. text-align: center;
  591. }
  592. }
  593. }
  594. </style>