takeout.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  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 v-else class="goos-list-box box-border-box p-24 display-flex" v-for="(item,i) in listData"
  107. :key='i' @click="toShop(item)">
  108. <view class="left-img-box">
  109. <image class="left-img" :src="item.shop_logo" mode="aspectFill"></image>
  110. <view class="status-box fc-f" v-if="item.status != 1">
  111. 休息中
  112. </view>
  113. </view>
  114. <view class="flex-1">
  115. <view class="align-items-center mb-8">
  116. <view class="right-box-title fs-32 fw-600 text-overflow-ellipsis-one">
  117. {{item.shop_name}}
  118. </view>
  119. <image class="right-box-title-img" src="@/static/img/toRight.png" mode=""></image>
  120. </view>
  121. <view class="align-items-center mb-8">
  122. <image class="img-x mr-12" src="@/static/img/my/wdpj.png" mode=""></image>
  123. <view class="fs-26 fw-600 fc-FF7F00 mr-12">{{item.shop_score}}分</view>
  124. <view class="fc-6 fs-24 mr-12">| 预计{{item.delivery_time}}分钟 |</view>
  125. <view class="fc-6 fs-24 mr-12">{{item.shop_sales}}人购买</view>
  126. </view>
  127. <view class="align-items-center flex-wrap-wrap">
  128. <view class="quan-list display-flex mr-12 mb-12"
  129. v-for="(itemCoupon,iCoupon) in item.coupon" :key="iCoupon">
  130. <view class="quan-list-1 fs-24 fc-f">券</view>
  131. <view class="quan-list-2 fs-24 fc-FB3D03">{{itemCoupon.money}}元</view>
  132. </view>
  133. </view>
  134. <view class="goods-items-list display-flex view-nowrap">
  135. <view class="goods-items-list-box" v-for="(info,iGoods) in item.goods" :key='iGoods'>
  136. <image class="mb-12" :src="info.goods_image" mode="scaleToFill"></image>
  137. <view class="mb-8 fw-600 text-overflow-ellipsis-one fs-26">{{info.goods_name}}
  138. </view>
  139. <view class="">
  140. <span class="fs-24 fc-FB3D03">¥</span>
  141. <span class="fs-32 fc-FB3D03 fw-b">{{info.price}}</span>
  142. </view>
  143. </view>
  144. </view>
  145. </view>
  146. </view>
  147. </scroll-view>
  148. <!-- <view class="box-border-box plr-24 mt-24">
  149. </view> -->
  150. </view>
  151. </scroll-view>
  152. </view>
  153. </template>
  154. <script>
  155. import EnBlank from "@/components/en-utils/en-blank/en-blank";
  156. import {
  157. shopTop
  158. } from "@/api/shop.js"
  159. import {
  160. getGoodsList
  161. } from "@/api/goods.js"
  162. import {
  163. getTakeaway
  164. } from "@/api/category.js"
  165. import {
  166. shopInfo
  167. } from "@/api/shop.js"
  168. import tools from "@/service/tools";
  169. export default {
  170. components: {
  171. EnBlank
  172. },
  173. data() {
  174. return {
  175. bgckgroundBox: 'transparent',
  176. BanenerCurrent: 0,
  177. search: '',
  178. category_id: 0,
  179. isScroll: false,
  180. topShopData: [],
  181. page: 1,
  182. listData: [],
  183. navList: [],
  184. listTotal: 0
  185. }
  186. },
  187. mounted() {
  188. this.shopTop()
  189. this.getGoodsList()
  190. this.getTakeaway()
  191. },
  192. methods: {
  193. searchClick() {
  194. console.log("898989898998");
  195. this.listData = []
  196. this.getGoodsList()
  197. },
  198. clickClass(id) {
  199. if (this.category_id == id) {
  200. return
  201. }
  202. this.category_id = id
  203. this.listData = []
  204. this.getGoodsList()
  205. },
  206. toBack() {
  207. tools.leftClick()
  208. },
  209. onSwiperChange(e) {
  210. this.BanenerCurrent = e.detail.current;
  211. },
  212. scrollFun(e) {
  213. if (e.target.scrollTop > 60) {
  214. this.isScroll = true;
  215. } else {
  216. this.isScroll = false;
  217. }
  218. },
  219. scrollList() {},
  220. scrolltolower() {
  221. console.log(this.listTotal, this.listData.length);
  222. if (this.listTotal > this.listData.length) {
  223. ++this.page
  224. this.getGoodsList()
  225. }
  226. console.log('触底');
  227. },
  228. toShop(item) {
  229. const operate_id = uni.getStorageSync('operate_id')
  230. shopInfo({
  231. operate_id: operate_id,
  232. shop_id: item.shop_id
  233. }).then((res) => {
  234. if (res.code == 1) {
  235. uni.navigateTo({
  236. url: '/pages-takeout/shop?shop_id=' + item.shop_id
  237. })
  238. } else {
  239. tools.error(res.msg)
  240. }
  241. })
  242. },
  243. shopTop() {
  244. const operate_id = uni.getStorageSync('operate_id')
  245. shopTop({
  246. operate_id: operate_id
  247. }).then((res) => {
  248. if (res.code == 1) {
  249. this.topShopData = res.data
  250. }
  251. })
  252. },
  253. getGoodsList() {
  254. const operate_id = uni.getStorageSync('operate_id')
  255. getGoodsList({
  256. operate_id: operate_id,
  257. category_id: this.category_id,
  258. search: this.search,
  259. page: this.page
  260. }).then((res) => {
  261. if (res.code == 1) {
  262. if (res.data.items.length > 0) {
  263. this.listData.push(...res.data.items)
  264. this.listTotal = res.data.total
  265. }
  266. }
  267. })
  268. },
  269. getTakeaway() {
  270. getTakeaway().then((res) => {
  271. if (res.code == 1) {
  272. this.navList = res.data
  273. }
  274. })
  275. }
  276. },
  277. }
  278. </script>
  279. <style scoped lang="scss">
  280. .index-search-box-buttom {
  281. width: 120rpx;
  282. height: 60rpx;
  283. position: absolute;
  284. z-index: 100;
  285. right: 30rpx;
  286. top: 6rpx;
  287. background: linear-gradient(90deg, #57CAFF 0%, #41ABF5 100%);
  288. border-radius: 200rpx;
  289. margin-left: auto;
  290. line-height: 60rpx;
  291. text-align: center;
  292. }
  293. .takeout-index {
  294. position: relative;
  295. .s-input-f {
  296. position: relative;
  297. .s-input-c {
  298. position: absolute;
  299. top: -16rpx;
  300. left: 50rpx;
  301. }
  302. }
  303. .bg-index {
  304. width: 100%;
  305. height: 272rpx;
  306. position: absolute;
  307. top: 0;
  308. left: 0;
  309. background-image: linear-gradient(#E0F6FB, #F5F4F9);
  310. z-index: -1;
  311. }
  312. .w-100100 {
  313. width: 100%;
  314. }
  315. .w-454 {
  316. width: 454rpx;
  317. }
  318. .s-input {
  319. margin-bottom: 24rpx;
  320. height: 72rpx;
  321. box-sizing: border-box;
  322. position: relative;
  323. .s-left {
  324. left: 24rpx !important;
  325. }
  326. .input-icon {
  327. position: absolute;
  328. left: 44rpx;
  329. top: 16rpx;
  330. }
  331. input {
  332. font-size: 32rpx;
  333. width: 100%;
  334. height: 72rpx;
  335. background: #FFFFFF;
  336. border-radius: 200rpx;
  337. box-sizing: border-box;
  338. padding: 0 120rpx 0 78rpx;
  339. border: 1rpx solid #41ABF5;
  340. }
  341. }
  342. .shop-box {
  343. width: 100%;
  344. height: 242rpx;
  345. position: relative;
  346. .shop-box-bg {
  347. width: 100%;
  348. height: 242rpx;
  349. position: absolute;
  350. top: 0;
  351. left: 0;
  352. z-index: -1;
  353. }
  354. .swiper-tj {
  355. width: 100%;
  356. height: 172rpx;
  357. border-radius: 20rpx;
  358. .swiper-item {
  359. width: 100%;
  360. height: 100%;
  361. border-radius: 20rpx;
  362. background-color: #fff;
  363. box-sizing: border-box;
  364. padding: 16rpx;
  365. .left-img-box {
  366. width: 140rpx;
  367. height: 140rpx;
  368. margin-right: 14rpx;
  369. position: relative;
  370. .left-img {
  371. width: 140rpx;
  372. height: 140rpx;
  373. border-radius: 12rpx;
  374. }
  375. .status-box {
  376. position: absolute;
  377. bottom: 0;
  378. left: 0;
  379. width: 100%;
  380. padding: 10rpx 0;
  381. text-align: center;
  382. background: rgba(0, 0, 0, 0.5);
  383. font-size: 20rpx;
  384. border-radius: 0 0 12rpx 12rpx;
  385. }
  386. }
  387. .right-box {}
  388. }
  389. }
  390. .dot-f {
  391. margin: 20rpx auto;
  392. justify-content: center;
  393. .dot-box {
  394. width: 8rpx;
  395. height: 6rpx;
  396. background: #FEC683;
  397. border-radius: 200rpx;
  398. margin: 0 6rpx;
  399. }
  400. .dot-box-s {
  401. width: 16rpx;
  402. height: 6rpx;
  403. background: #FF7F00;
  404. border-radius: 200rpx;
  405. margin: 0 6rpx;
  406. }
  407. }
  408. }
  409. .nav-bg {
  410. background-image: linear-gradient(#F0F4FA, #FFFFFF);
  411. padding: 24rpx !important;
  412. }
  413. .nav-type-box-f {
  414. position: sticky;
  415. top: 0;
  416. left: 0;
  417. z-index: 9999;
  418. .nav-type-box {
  419. width: 100%;
  420. height: 120rpx;
  421. display: flex;
  422. // overflow: scroll;
  423. white-space: nowrap;
  424. .nav-type-list {
  425. display: inline-block;
  426. height: 120rpx;
  427. width: 96rpx !important;
  428. text-align: center;
  429. margin-right: 44rpx;
  430. image {
  431. display: block;
  432. width: 80rpx;
  433. height: 80rpx;
  434. margin: 0 8rpx 12rpx 8rpx;
  435. }
  436. }
  437. }
  438. }
  439. .goos-list-box {
  440. width: 100%;
  441. // min-height: 428rpx;
  442. background: #FFFFFF;
  443. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(51, 51, 51, 0.1);
  444. border-radius: 20rpx;
  445. margin-bottom: 20rpx;
  446. .goods-items-list {
  447. width: 530rpx;
  448. overflow-y: scroll;
  449. .goods-items-list-box {
  450. width: 140rpx;
  451. margin-right: 16rpx;
  452. image {
  453. width: 140rpx;
  454. height: 140rpx;
  455. border-radius: 12rpx
  456. }
  457. }
  458. }
  459. }
  460. .left-img-box {
  461. width: 100rpx;
  462. height: 100rpx;
  463. margin-right: 16rpx;
  464. position: relative;
  465. .left-img {
  466. width: 100rpx;
  467. height: 100rpx;
  468. border-radius: 12rpx;
  469. }
  470. .status-box {
  471. position: absolute;
  472. bottom: 0;
  473. left: 0;
  474. width: 100%;
  475. padding: 4rpx 0;
  476. text-align: center;
  477. background: rgba(0, 0, 0, 0.5);
  478. font-size: 17rpx;
  479. border-radius: 0 0 12rpx 12rpx;
  480. }
  481. }
  482. .img-x {
  483. width: 24rpx;
  484. height: 24rpx;
  485. }
  486. .right-box-title {
  487. width: 438rpx;
  488. }
  489. .right-box-title-img {
  490. width: 32rpx;
  491. height: 32rpx;
  492. margin-left: auto;
  493. }
  494. .quan-list {
  495. .quan-list-1 {
  496. width: 32rpx;
  497. height: 34rpx;
  498. background: #FB3D03;
  499. border-radius: 5rpx 0rpx 0rpx 5rpx;
  500. text-align: center;
  501. }
  502. .quan-list-2 {
  503. box-sizing: border-box;
  504. padding: 0 2rpx;
  505. height: 34rpx;
  506. border-radius: 0 5rpx 5rpx 0;
  507. border: 1rpx solid #FB3D03;
  508. text-align: center;
  509. }
  510. }
  511. }
  512. // .index-search-box {
  513. // width: 100%;
  514. // height: 72rpx;
  515. // padding: 0 6rpx 0 24rpx;
  516. // border-radius: 200rpx;
  517. // border: 2rpx solid #4FB3EF;
  518. // .index-search-box-buttom {
  519. // width: 120rpx;
  520. // height: 60rpx;
  521. // background: linear-gradient(90deg, #57CAFF 0%, #41ABF5 100%);
  522. // border-radius: 200rpx;
  523. // margin-left: auto;
  524. // line-height: 60rpx;
  525. // text-align: center;
  526. // }
  527. // }
  528. </style>