takeout.vue 12 KB

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