takeout.vue 13 KB

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