takeout.vue 14 KB

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