index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <view class="container">
  3. <!--搜索栏-->
  4. <u-sticky style="top: 0" offset-top="0">
  5. <view class="search-wrap">
  6. <u-search placeholder="搜索" disabled height="32" :show-action="false" @click="handleSearchClick"></u-search>
  7. </view>
  8. </u-sticky>
  9. <!--轮播图-->
  10. <yd-banner :banner-list="bannerList"></yd-banner>
  11. <u-gap height="20px"></u-gap>
  12. <!--宫格菜单按钮-->
  13. <u-grid :border="false" col="4">
  14. <u-grid-item v-for="(item, index) in menuList" :key="index">
  15. <u-icon :name="item.icon" :size="40"></u-icon>
  16. <text class="grid-title">{{ item.title }}</text>
  17. </u-grid-item>
  18. </u-grid>
  19. <u-gap height="15px"></u-gap>
  20. <!--消息滚动栏-->
  21. <u-notice-bar style="padding: 13px 12px" :text="noticeList" mode="link" direction="column" @click="click"></u-notice-bar>
  22. <!--商品展示栏-->
  23. <yd-product-box :product-list="productList" :title="'每日上新'" show-type="normal"></yd-product-box>
  24. <yd-product-box :product-list="productList" :title="'热卖商品'" show-type="half"></yd-product-box>
  25. <yd-product-more :product-list="productList" :more-status="moreStatus"></yd-product-more>
  26. <u-gap height="5px"></u-gap>
  27. </view>
  28. </template>
  29. <script>
  30. import { getBannerData, getNoticeData } from '../../api/index'
  31. export default {
  32. components: {},
  33. data() {
  34. return {
  35. bannerList: [
  36. {
  37. id: 1,
  38. title: '山不在高,有仙则名',
  39. url: 'https://cdn.uviewui.com/uview/swiper/swiper1.png'
  40. },
  41. {
  42. id: 2,
  43. title: '水不在深,有龙则灵',
  44. url: 'https://cdn.uviewui.com/uview/swiper/swiper2.png'
  45. },
  46. {
  47. id: 3,
  48. title: '斯是陋室,惟吾德馨',
  49. url: 'https://cdn.uviewui.com/uview/swiper/swiper3.png'
  50. }
  51. ],
  52. menuList: [
  53. { icon: 'gift', title: '热门推荐' },
  54. { icon: 'star', title: '收藏转发' },
  55. { icon: 'thumb-up', title: '点赞投币' },
  56. { icon: 'heart', title: '感谢支持' }
  57. ],
  58. noticeList: ['寒雨连江夜入吴', '平明送客楚山孤', '洛阳亲友如相问', '一片冰心在玉壶'],
  59. productList: [
  60. {
  61. id: 1,
  62. image: 'https://cdn.uviewui.com/uview/album/1.jpg',
  63. title: '山不在高,有仙则名。水不在深,有龙则灵。斯是陋室,惟吾德馨。',
  64. desc: '山不在于高,有了神仙就会有名气。水不在于深,有了龙就会有灵气。这是简陋的房子,只是我品德好就感觉不到简陋了。',
  65. price: '13.00'
  66. },
  67. {
  68. id: 2,
  69. image: 'https://cdn.uviewui.com/uview/album/2.jpg',
  70. title: '商品222',
  71. desc: '',
  72. price: '23.00'
  73. },
  74. {
  75. id: 3,
  76. image: 'https://cdn.uviewui.com/uview/album/3.jpg',
  77. title: '商品333',
  78. desc: '商品描述信息2',
  79. price: '33.00'
  80. },
  81. {
  82. id: 4,
  83. image: 'https://cdn.uviewui.com/uview/album/4.jpg',
  84. title: '商品444',
  85. desc: '商品描述信息4',
  86. price: '43.00'
  87. },
  88. {
  89. id: 5,
  90. image: 'https://cdn.uviewui.com/uview/album/5.jpg',
  91. title: '商品555',
  92. desc: '商品描述信息5',
  93. price: '53.00'
  94. }
  95. ],
  96. moreStatus: 'nomore'
  97. }
  98. },
  99. onLoad() {
  100. this.loadBannerData()
  101. this.loadNoticeData()
  102. },
  103. methods: {
  104. loadBannerData() {
  105. getBannerData().then(res => {
  106. this.bannerList = res.data
  107. })
  108. },
  109. loadNoticeData() {
  110. getNoticeData().then(res => {
  111. this.noticeList = res.data
  112. })
  113. },
  114. handleSearchClick(e) {
  115. uni.$u.route('/pages/search/search')
  116. }
  117. },
  118. computed: {
  119. noticeTextList() {
  120. return this.noticeList.map(item => {
  121. if (item.title) {
  122. return item.title
  123. }
  124. })
  125. }
  126. }
  127. }
  128. </script>
  129. <style lang="scss" scoped>
  130. .search-wrap {
  131. background: $custom-bg-color;
  132. padding: 20rpx;
  133. }
  134. .grid-title {
  135. line-height: 50rpx;
  136. font-size: 26rpx;
  137. }
  138. </style>