list.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924
  1. <template>
  2. <gracePage :customHeader="false">
  3. <view class="container" slot="gBody">
  4. <view class="main" v-if="fetch.cate.length > 0">
  5. <view class="content" :style="height">
  6. <scroll-view class="menus" :scroll-into-view="view" scroll-with-animation scroll-y>
  7. <view class="wrapper">
  8. <view class="menu" :id="`menu-${v.id}`" :class="{'current': k == cate_index}" v-for="(v, k) in fetch.cate" :key="k" @tap="menu(k, v.id)">
  9. <text>{{ v.name }}</text>
  10. </view>
  11. </view>
  12. </scroll-view>
  13. <!-- goods list begin -->
  14. <scroll-view class="goods" scroll-with-animation scroll-y :scroll-top="top" @scroll="scoll">
  15. <view class="wrapper">
  16. <swiper class="ads" id="ads" autoplay :interval="3000" indicator-dots v-if="fetch.focus.length > 0">
  17. <swiper-item v-for="(v, k) in fetch.focus" :key="k" @tap="go" :data-url="v.link">
  18. <image :src="v.pic"></image>
  19. </swiper-item>
  20. </swiper>
  21. <view class="list">
  22. <!-- category begin -->
  23. <view class="category" v-for="(v, k) in fetch.cate" :key="k" :id="`cate-${v.id}`">
  24. <view class="title">
  25. <text>{{ v.name }}</text>
  26. <image :src="v.logo" class="icon"></image>
  27. </view>
  28. <view class="items">
  29. <!-- 商品 begin -->
  30. <view class="good" v-for="(v1, k1) in fetch.info[v.id]" :key="k1">
  31. <image :src="v1.pic_cover" class="image" @tap="location(v1.id_code)"></image>
  32. <view class="right">
  33. <text class="name">{{ v1.name }}</text>
  34. <text class="tips">{{ v1.desc }}</text>
  35. <view class="price_and_action" v-if="v1.buy == 1">
  36. <text class="price">¥{{ v1.buy_price }}</text>
  37. </view>
  38. </view>
  39. </view>
  40. <!-- 商品 end -->
  41. </view>
  42. </view>
  43. <!-- category end -->
  44. </view>
  45. </view>
  46. </scroll-view>
  47. <!-- goods list end -->
  48. </view>
  49. <!-- content end -->
  50. </view>
  51. </view>
  52. </gracePage>
  53. </template>
  54. <script>
  55. export default {
  56. components: {
  57. },
  58. data() {
  59. return {
  60. fetch : {
  61. cate : [],
  62. info : [],
  63. hot : [],
  64. },
  65. height : 'height:100%',
  66. cate_index: 0,//默认分类
  67. top: 0,
  68. view: '',
  69. sizeState: false,
  70. }
  71. },
  72. onLoad() {
  73. },
  74. onShow() {
  75. //this.Dever.checkLogin();
  76. this.getData();
  77. },
  78. // 重新加载
  79. onPullDownRefresh: function() {
  80. this.getData();
  81. },
  82. //下拉加载
  83. onReachBottom() {
  84. this.getData();
  85. },
  86. methods: {
  87. getData : function() {
  88. var self = this;
  89. this.Dever.get(this, 'app/collection/?l=api.getList', {id:-1}, function(t) {
  90. uni.getSystemInfo({
  91. success: function (res) {
  92. self.height = 'height:' + res.windowHeight + 'px';
  93. }
  94. })
  95. });
  96. },
  97. location : function(id) {
  98. this.Dever.location('dream/index?id=' + id);
  99. },
  100. go : function(e) {
  101. var link = e.currentTarget.dataset.url;
  102. if (link) {
  103. this.Dever.location(link);
  104. }
  105. },
  106. menu : function(index, id) {
  107. if(!this.sizeState) {
  108. this.size()
  109. }
  110. this.cate_index = index
  111. this.$nextTick(() => this.top = this.fetch.cate.find(item => item.id == id).top)
  112. },
  113. scoll : function({detail}) { //商品列表滚动事件
  114. if(!this.sizeState) {
  115. this.size()
  116. }
  117. const {scrollTop} = detail
  118. let tabs = this.fetch.cate.filter(item=> item.top <= scrollTop).reverse()
  119. if(tabs.length > 0){
  120. this.cate_id = tabs[0].id
  121. }
  122. },
  123. size : function() {
  124. let h = 10
  125. let view = uni.createSelectorQuery().select('#ads')
  126. view.fields({
  127. size: true
  128. }, data => {
  129. h += Math.floor(data.height)
  130. }).exec()
  131. this.fetch.cate.forEach(item => {
  132. let view = uni.createSelectorQuery().select(`#cate-${item.id}`)
  133. view.fields({
  134. size: true
  135. }, data => {
  136. item.top = h
  137. h += data.height
  138. item.bottom = h
  139. }).exec()
  140. })
  141. this.sizeState = true
  142. },
  143. }
  144. };
  145. </script>
  146. <style lang="scss" scoped>
  147. /* #ifdef H5 */
  148. page {
  149. min-height: 100%;
  150. }
  151. /* #endif */
  152. uni-button {
  153. background-color: #ADB838;
  154. }
  155. .container {
  156. overflow: hidden;
  157. position: relative;
  158. }
  159. .loading {
  160. width: 100%;
  161. height: 100%;
  162. display: flex;
  163. align-items: center;
  164. justify-content: center;
  165. image {
  166. width: 260rpx;
  167. height: 260rpx;
  168. position: relative;
  169. margin-top: -200rpx;
  170. /* #ifdef h5 */
  171. margin-top: 0;
  172. /* #endif */
  173. }
  174. }
  175. .stores {
  176. width: 100%;
  177. display: flex;
  178. flex-direction: column;
  179. justify-content: flex-start;
  180. margin-bottom: -40rpx;
  181. .store {
  182. width: 100%;
  183. background-color: $bg-color-grey;
  184. padding: 20rpx;
  185. display: flex;
  186. align-items: center;
  187. margin-bottom: 20rpx;
  188. border-radius: 6rpx;
  189. .iconfont {
  190. font-size: 50rpx;
  191. margin-right: 15rpx;
  192. &.iconradio-button-off {
  193. color: $text-color-assist;
  194. }
  195. &.iconradio-button-on {
  196. color: $color-primary;
  197. }
  198. }
  199. .infos {
  200. flex: 1;
  201. display: flex;
  202. flex-direction: column;
  203. color: $text-color-base;
  204. overflow: hidden;
  205. .name_and_distance {
  206. width: 100%;
  207. display: flex;
  208. justify-content: space-between;
  209. margin-bottom: 10rpx;
  210. overflow: hidden;
  211. .name {
  212. flex: 1;
  213. flex-shrink: 0;
  214. overflow: hidden;
  215. text-overflow: ellipsis;
  216. white-space: nowrap;
  217. font-size: $font-size-lg;
  218. }
  219. .distance {
  220. flex-shrink: 0;
  221. font-size: $font-size-lg;
  222. font-weight: bold;
  223. margin-left: 20rpx;
  224. }
  225. }
  226. .street {
  227. color: $text-color-assist;
  228. font-size: $font-size-sm;
  229. }
  230. }
  231. }
  232. }
  233. .main {
  234. width: 100%;
  235. height: 100%;
  236. position: relative;
  237. display: flex;
  238. flex-direction: column;
  239. }
  240. .nav {
  241. width: 100%;
  242. height: 212rpx;
  243. flex-shrink: 0;
  244. display: flex;
  245. flex-direction: column;
  246. .header {
  247. width: 100%;
  248. display: flex;
  249. align-items: center;
  250. justify-content: space-between;
  251. padding: 20rpx;
  252. background-color: #ffffff;
  253. height: 140rpx;
  254. .left {
  255. flex: 1;
  256. display: flex;
  257. flex-direction: column;
  258. .store-name {
  259. display: flex;
  260. justify-content: flex-start;
  261. align-items: center;
  262. font-size: $font-size-lg;
  263. margin-bottom: 10rpx;
  264. .iconfont {
  265. margin-left: 10rpx;
  266. line-height: 100%;
  267. }
  268. }
  269. .store-location {
  270. display: flex;
  271. justify-content: flex-start;
  272. align-items: center;
  273. color: $text-color-assist;
  274. font-size: $font-size-sm;
  275. .iconfont {
  276. vertical-align: middle;
  277. display: table-cell;
  278. color: $color-primary;
  279. line-height: 100%;
  280. }
  281. }
  282. }
  283. .right {
  284. background-color: $bg-color-grey;
  285. border-radius: 38rpx;
  286. display: flex;
  287. align-items: center;
  288. font-size: $font-size-sm;
  289. padding: 0 38rpx;
  290. color: $text-color-assist;
  291. .dinein, .takeout {
  292. position: relative;
  293. display: flex;
  294. align-items: center;
  295. &.active {
  296. padding: 14rpx 38rpx;
  297. color: #ffffff;
  298. background-color: $color-primary;
  299. border-radius: 38rpx;
  300. }
  301. }
  302. .takeout {
  303. margin-left: 20rpx;
  304. height: 100%;
  305. flex: 1;
  306. padding: 14rpx 0;
  307. }
  308. .dinein.active {
  309. margin-left: -38rpx;
  310. }
  311. .takeout.active {
  312. margin-right: -38rpx;
  313. }
  314. }
  315. }
  316. .coupon {
  317. flex: 1;
  318. width: 100%;
  319. background-color: $bg-color-primary;
  320. font-size: $font-size-base;
  321. color: $color-primary;
  322. padding: 0 20rpx;
  323. display: flex;
  324. align-items: center;
  325. overflow: hidden;
  326. .title {
  327. flex: 1;
  328. margin-left: 10rpx;
  329. overflow: hidden;
  330. white-space: nowrap;
  331. text-overflow: ellipsis;
  332. }
  333. .iconfont {
  334. line-height: 100%;
  335. }
  336. }
  337. }
  338. .content {
  339. flex: 1;
  340. overflow: hidden;
  341. width: 100%;
  342. display: flex;
  343. .menus {
  344. width: 200rpx;
  345. height: 100%;
  346. overflow: hidden;
  347. background-color: $bg-color-grey;
  348. .wrapper {
  349. width: 100%;
  350. height: 100%;
  351. .menu {
  352. display: flex;
  353. align-items: center;
  354. justify-content: flex-start;
  355. padding: 30rpx 20rpx;
  356. font-size: 26rpx;
  357. color: $text-color-assist;
  358. position: relative;
  359. &:nth-last-child(1) {
  360. margin-bottom: 130rpx;
  361. }
  362. &.current {
  363. background-color: #ffffff;
  364. color: $text-color-base;
  365. }
  366. .dot {
  367. position: absolute;
  368. width: 34rpx;
  369. height: 34rpx;
  370. line-height: 34rpx;
  371. font-size: 22rpx;
  372. background-color: $color-primary;
  373. color: #ffffff;
  374. top: 16rpx;
  375. right: 10rpx;
  376. border-radius: 100%;
  377. text-align: center;
  378. }
  379. }
  380. }
  381. }
  382. .goods {
  383. flex: 1;
  384. height: 100%;
  385. overflow: hidden;
  386. background-color: #ffffff;
  387. .wrapper {
  388. width: 100%;
  389. height: 100%;
  390. padding: 20rpx;
  391. .ads {
  392. height: calc(300 / 550 * 510rpx);
  393. image {
  394. width: 100%;
  395. height: 100%;
  396. border-radius: 8rpx;
  397. }
  398. }
  399. .list {
  400. width: 100%;
  401. font-size: $font-size-base;
  402. padding-bottom: 130rpx;
  403. .category {
  404. width: 100%;
  405. .title {
  406. padding: 30rpx 0;
  407. display: flex;
  408. align-items: center;
  409. color: $text-color-base;
  410. .icon {
  411. width: 38rpx;
  412. height: 38rpx;
  413. margin-left: 10rpx;
  414. }
  415. }
  416. }
  417. .items {
  418. display: flex;
  419. flex-direction: column;
  420. padding-bottom: -30rpx;
  421. .good {
  422. display: flex;
  423. align-items: center;
  424. margin-bottom: 30rpx;
  425. .image {
  426. width: 160rpx;
  427. height: 160rpx;
  428. margin-right: 20rpx;
  429. border-radius: 8rpx;
  430. }
  431. .right {
  432. flex: 1;
  433. height: 160rpx;
  434. overflow: hidden;
  435. display: flex;
  436. flex-direction: column;
  437. align-items: flex-start;
  438. justify-content: space-between;
  439. padding-right: 14rpx;
  440. .name {
  441. font-size: $font-size-base;
  442. margin-bottom: 10rpx;
  443. }
  444. .tips {
  445. width: 100%;
  446. height: 100rpx;
  447. line-height: 40rpx;
  448. overflow: hidden;
  449. text-overflow: ellipsis;
  450. white-space: nowrap;
  451. font-size: $font-size-sm;
  452. color: $text-color-assist;
  453. margin-bottom: 10rpx;
  454. }
  455. .price_and_action {
  456. width: 100%;
  457. display: flex;
  458. justify-content: space-between;
  459. align-items: center;
  460. .price {
  461. font-size: $font-size-base;
  462. font-weight: 600;
  463. }
  464. .btn-group {
  465. display: flex;
  466. justify-content: space-between;
  467. align-items: center;
  468. position: relative;
  469. .btn {
  470. padding: 0 20rpx;
  471. box-sizing: border-box;
  472. font-size: $font-size-sm;
  473. height: 44rpx;
  474. line-height: 44rpx;
  475. &.property_btn {
  476. border-radius: 24rpx;
  477. }
  478. &.add_btn,
  479. &.reduce_btn {
  480. padding: 0;
  481. width: 44rpx;
  482. border-radius: 44rpx;
  483. }
  484. }
  485. .dot {
  486. position: absolute;
  487. background-color: #ffffff;
  488. border: 1px solid $color-primary;
  489. color: $color-primary;
  490. font-size: $font-size-sm;
  491. width: 36rpx;
  492. height: 36rpx;
  493. line-height: 36rpx;
  494. text-align: center;
  495. border-radius: 100%;
  496. right: -12rpx;
  497. top: -10rpx;
  498. }
  499. .number {
  500. width: 44rpx;
  501. height: 44rpx;
  502. line-height: 44rpx;
  503. text-align: center;
  504. }
  505. }
  506. }
  507. }
  508. }
  509. }
  510. }
  511. }
  512. }
  513. }
  514. .modal-box {
  515. max-height: 90vh;
  516. }
  517. .good-detail-modal {
  518. width: 100%;
  519. height: 100%;
  520. display: flex;
  521. flex-direction: column;
  522. .cover {
  523. height: 320rpx;
  524. padding: 30rpx 0;
  525. display: flex;
  526. justify-content: center;
  527. align-items: center;
  528. position: relative;
  529. .image {
  530. width: 260rpx;
  531. height: 260rpx;
  532. }
  533. .btn-group {
  534. position: absolute;
  535. right: 10rpx;
  536. top: 30rpx;
  537. display: flex;
  538. align-items: center;
  539. justify-content: space-around;
  540. image {
  541. width: 80rpx;
  542. height: 80rpx;
  543. }
  544. }
  545. }
  546. .detail {
  547. width: 100%;
  548. min-height: 1vh;
  549. max-height: calc(90vh - 320rpx - 80rpx - 120rpx);
  550. .wrapper {
  551. width: 100%;
  552. height: 100%;
  553. overflow: hidden;
  554. .basic {
  555. padding: 0 20rpx 30rpx;
  556. display: flex;
  557. flex-direction: column;
  558. .name {
  559. font-size: $font-size-base;
  560. color: $text-color-base;
  561. margin-bottom: 10rpx;
  562. }
  563. .tips {
  564. font-size: $font-size-sm;
  565. color: $text-color-grey;
  566. }
  567. }
  568. .properties {
  569. width: 100%;
  570. border-top: 2rpx solid $bg-color-grey;
  571. padding: 10rpx 30rpx 0;
  572. display: flex;
  573. flex-direction: column;
  574. .property {
  575. width: 100%;
  576. display: flex;
  577. flex-direction: column;
  578. margin-bottom: 30rpx;
  579. padding-bottom: -16rpx;
  580. .title {
  581. width: 100%;
  582. display: flex;
  583. justify-content: flex-start;
  584. align-items: center;
  585. margin-bottom: 20rpx;
  586. .name {
  587. font-size: 26rpx;
  588. color: $text-color-base;
  589. margin-right: 20rpx;
  590. }
  591. .desc {
  592. flex: 1;
  593. font-size: $font-size-sm;
  594. color: $color-primary;
  595. overflow: hidden;
  596. text-overflow: ellipsis;
  597. white-space: nowrap;
  598. }
  599. }
  600. .values {
  601. width: 100%;
  602. display: flex;
  603. flex-wrap: wrap;
  604. .value {
  605. border-radius: 8rpx;
  606. background-color: $bg-color-grey;
  607. padding: 16rpx 30rpx;
  608. font-size: 26rpx;
  609. color: $text-color-assist;
  610. margin-right: 16rpx;
  611. margin-bottom: 16rpx;
  612. &.default {
  613. background-color: $color-primary;
  614. color: $text-color-white;
  615. }
  616. }
  617. }
  618. }
  619. }
  620. }
  621. }
  622. .action {
  623. display: flex;
  624. align-items: center;
  625. justify-content: space-between;
  626. background-color: $bg-color-grey;
  627. height: 120rpx;
  628. padding: 0 26rpx;
  629. .left {
  630. flex: 1;
  631. display: flex;
  632. flex-direction: column;
  633. justify-content: center;
  634. margin-right: 20rpx;
  635. overflow: hidden;
  636. .price {
  637. font-size: $font-size-lg;
  638. color: $text-color-base;
  639. }
  640. .props {
  641. color: $text-color-assist;
  642. font-size: 24rpx;
  643. width: 100%;
  644. overflow: hidden;
  645. text-overflow: ellipsis;
  646. white-space: nowrap;
  647. }
  648. }
  649. .btn-group {
  650. display: flex;
  651. align-items: center;
  652. justify-content: space-around;
  653. .number {
  654. font-size: $font-size-base;
  655. width: 44rpx;
  656. height: 44rpx;
  657. line-height: 44rpx;
  658. text-align: center;
  659. }
  660. .btn {
  661. padding: 0;
  662. font-size: $font-size-base;
  663. width: 44rpx;
  664. height: 44rpx;
  665. line-height: 44rpx;
  666. border-radius: 100%;
  667. }
  668. }
  669. }
  670. .add-to-cart-btn {
  671. display: flex;
  672. justify-content: center;
  673. align-items: center;
  674. background-color: $color-primary;
  675. color: $text-color-white;
  676. font-size: $font-size-base;
  677. height: 80rpx;
  678. border-radius: 0 0 12rpx 12rpx;
  679. }
  680. }
  681. .cart-box {
  682. position: absolute;
  683. bottom: 30rpx;
  684. left: 30rpx;
  685. right: 30rpx;
  686. height: 96rpx;
  687. border-radius: 48rpx;
  688. box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.2);
  689. background-color: #FFFFFF;
  690. display: flex;
  691. align-items: center;
  692. justify-content: space-between;
  693. z-index: 9999;
  694. .cart-img {
  695. width: 96rpx;
  696. height: 96rpx;
  697. position: relative;
  698. margin-top: -48rpx;
  699. }
  700. .pay-btn {
  701. height: 100%;
  702. padding: 0 30rpx;
  703. color: #FFFFFF;
  704. border-radius: 0 50rpx 50rpx 0;
  705. display: flex;
  706. align-items: center;
  707. font-size: $font-size-base;
  708. }
  709. .mark {
  710. padding-left: 46rpx;
  711. margin-right: 30rpx;
  712. position: relative;
  713. .tag {
  714. background-color: $color-warning;
  715. color: $text-color-white;
  716. display: flex;
  717. justify-content: center;
  718. align-items: center;
  719. font-size: $font-size-sm;
  720. position: absolute;
  721. right: -10rpx;
  722. top: -50rpx;
  723. border-radius: 100%;
  724. padding: 4rpx;
  725. width: 40rpx;
  726. height: 40rpx;
  727. opacity: .9;
  728. }
  729. }
  730. .price {
  731. flex: 1;
  732. color: $text-color-base;
  733. }
  734. }
  735. .cart-popup {
  736. .top {
  737. background-color: $bg-color-primary;
  738. color: $color-primary;
  739. padding: 10rpx 30rpx;
  740. font-size: 24rpx;
  741. text-align: right;
  742. }
  743. .cart-list {
  744. background-color: #FFFFFF;
  745. width: 100%;
  746. overflow: hidden;
  747. min-height: 1vh;
  748. max-height: 60vh;
  749. .wrapper {
  750. height: 100%;
  751. display: flex;
  752. flex-direction: column;
  753. padding: 0 30rpx;
  754. margin-bottom: 156rpx;
  755. .item {
  756. display: flex;
  757. justify-content: space-between;
  758. align-items: center;
  759. padding: 30rpx 0;
  760. position: relative;
  761. &::after {
  762. content: ' ';
  763. position: absolute;
  764. bottom: 0;
  765. left: 0;
  766. width: 100%;
  767. background-color: $border-color;
  768. height: 2rpx;
  769. transform: scaleY(.6);
  770. }
  771. .left {
  772. flex: 1;
  773. display: flex;
  774. flex-direction: column;
  775. overflow: hidden;
  776. margin-right: 30rpx;
  777. .name {
  778. font-size: $font-size-sm;
  779. color: $text-color-base;
  780. }
  781. .props {
  782. color: $text-color-assist;
  783. font-size: 24rpx;
  784. overflow: hidden;
  785. text-overflow: ellipsis;
  786. white-space: nowrap;
  787. }
  788. }
  789. .center {
  790. margin-right: 120rpx;
  791. font-size: $font-size-base;
  792. }
  793. .right {
  794. display: flex;
  795. align-items: center;
  796. justify-content: space-between;
  797. .btn {
  798. width: 46rpx;
  799. height: 46rpx;
  800. border-radius: 100%;
  801. padding: 0;
  802. text-align: center;
  803. line-height: 46rpx;
  804. }
  805. .number {
  806. font-size: $font-size-base;
  807. width: 46rpx;
  808. height: 46rpx;
  809. text-align: center;
  810. line-height: 46rpx;
  811. }
  812. }
  813. }
  814. }
  815. }
  816. }
  817. </style>