takeout.vue 12 KB

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