index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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. <u-swiper :list="swiperList" previousMargin="20" nextMargin="20" circular height="200" @change="e => current = e.current" :autoplay="true" @click="handleSwiperClick">
  11. <view slot="indicator" class="indicator">
  12. <view class="indicator__dot" v-for="(item, index) in swiperList" :key="index" :class="[index === current && 'indicator__dot--active']">
  13. </view>
  14. </view>
  15. </u-swiper>
  16. <!--宫格菜单按钮-->
  17. <view class="mt-40-r mb-30-r">
  18. <u-grid :border="false" col="4"><u-grid-item v-for="(item,index) in menuList" :key="index">
  19. <u-icon :name="item.icon" :size="40"></u-icon>
  20. <text class="grid-title">{{item.title}}</text>
  21. </u-grid-item>
  22. </u-grid>
  23. </view>
  24. <!--消息滚动栏-->
  25. <u-notice-bar style="padding: 13px 12px" :text="noticeList" mode="link" direction="column" @click="click"></u-notice-bar>
  26. <!--商品展示栏-->
  27. <view>
  28. <u-gap height="180" bgColor="#398ade"></u-gap>
  29. <view class="prod-block">
  30. <view class="bloc-header">
  31. <text class="bloc-title">每日上新</text>
  32. <text class="see-more">查看更多</text>
  33. </view>
  34. <u-grid class="prod-grid" :border="false" col="3">
  35. <u-grid-item class="prod-item-box" v-for="(item,index) in productList" :key="index">
  36. <view class="prod-item">
  37. <u--image class="prod-image" width="230rpx" height="230rpx" :src="item"></u--image>
  38. <view class="item-info">
  39. <view class="info-text">
  40. <u--text :lines="2" size="14px" color="#333333" text="山不在高,有仙则名。水不在深,有龙则灵。斯是陋室,惟吾德馨。"></u--text>
  41. </view>
  42. <view class="price-and-cart">
  43. <u--text-price color="red" size="12" integerSize="18" :text="233.33"></u--text-price>
  44. <u-icon name="shopping-cart" color="#2979ff" size="28"></u-icon>
  45. </view>
  46. </view>
  47. </view>
  48. </u-grid-item>
  49. </u-grid>
  50. </view>
  51. </view>
  52. <view>
  53. <view class="prod-block half">
  54. <view class="bloc-header">
  55. <text class="bloc-title">商品热卖</text>
  56. <text class="more">更多 &gt;</text>
  57. </view>
  58. <u-grid class="prod-grid" :border="false" col="2">
  59. <u-grid-item class="prod-item-box" v-for="(item,index) in productList" :key="index">
  60. <view class="prod-item">
  61. <u--image class="prod-image" width="345rpx" height="345rpx" :src="item"></u--image>
  62. <view class="item-info">
  63. <view class="info-text">
  64. <u--text :lines="1" size="14px" color="#333333" text="山不在高,有仙则名。水不在深,有龙则灵。斯是陋室,惟吾德馨。"></u--text>
  65. <u--text :lines="1" size="12px" color="#939393" text="斯是陋室,惟吾德馨。"></u--text>
  66. </view>
  67. <view class="price-and-cart">
  68. <u--text-price color="red" size="12" integerSize="18" :text="233.33"></u--text-price>
  69. <u-icon name="shopping-cart" color="#2979ff" size="28"></u-icon>
  70. </view>
  71. </view>
  72. </view>
  73. </u-grid-item>
  74. </u-grid>
  75. </view>
  76. </view>
  77. <view>
  78. <view class="prod-block list">
  79. <view class="bloc-header">
  80. <text class="bloc-title">更多宝贝</text>
  81. <text></text>
  82. </view>
  83. <u-list class="prod-list" @scrolltolower="scrolltolower">
  84. <u-list-item v-for="(item, index) in productList" :key="index">
  85. <view class="prod-item">
  86. <u--image class="prod-image" width="210rpx" height="210rpx" :src="item"></u--image>
  87. <view class="item-info">
  88. <view class="info-text">
  89. <u--text :lines="2" size="14px" color="#333333" text="山不在高,有仙则名。水不在深,有龙则灵。斯是陋室,惟吾德馨。"></u--text>
  90. <u--text :lines="1" size="12px" color="#939393" text="斯是陋室,惟吾德馨。"></u--text>
  91. </view>
  92. <view class="price-and-cart">
  93. <u--text-price color="red" size="12" integerSize="18" :text="233.33"></u--text-price>
  94. <u-icon name="shopping-cart" color="#2979ff" size="28"></u-icon>
  95. </view>
  96. </view>
  97. </view>
  98. </u-list-item>
  99. </u-list>
  100. </view>
  101. </view>
  102. <u-gap height="5px"></u-gap>
  103. <!--加载更多-->
  104. <u-loadmore fontSize="32rpx" :status="status" :loading-text="loadingText" :loadmore-text="loadmoreText" :nomore-text="nomoreText"/>
  105. <u-gap height="10px"></u-gap>
  106. </view>
  107. </template>
  108. <script>
  109. import {getBannerData,getNoticeData} from "../../common/api";
  110. export default {
  111. components: {
  112. },
  113. data() {
  114. return {
  115. current: 0,
  116. currentNum: 0,
  117. bannerList: [
  118. 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
  119. 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
  120. 'https://cdn.uviewui.com/uview/swiper/swiper1.png',],
  121. menuList: [{icon: 'gift', title: '热门推荐'}, {icon: 'star', title: '收藏转发'}, {icon: 'thumb-up', title: '点赞投币'}, {icon: 'heart', title: '感谢支持'}],
  122. noticeList:[
  123. '寒雨连江夜入吴',
  124. '平明送客楚山孤',
  125. '洛阳亲友如相问',
  126. '一片冰心在玉壶'
  127. ],
  128. productList: [
  129. 'https://cdn.uviewui.com/uview/album/1.jpg',
  130. 'https://cdn.uviewui.com/uview/album/2.jpg',
  131. 'https://cdn.uviewui.com/uview/album/3.jpg',
  132. 'https://cdn.uviewui.com/uview/album/4.jpg',
  133. 'https://cdn.uviewui.com/uview/album/5.jpg',
  134. ],
  135. status: 'nomore',
  136. loadingText: '努力加载中...',
  137. loadmoreText: '轻轻上拉',
  138. nomoreText: '实在没有了...'
  139. }
  140. },
  141. onLoad() {
  142. //this.loadBannerData();
  143. //this.loadNoticeData();
  144. },
  145. methods: {
  146. loadBannerData() {
  147. getBannerData().then(res => {
  148. this.bannerList = res.data;
  149. }).catch(err => {
  150. //console.log(err)
  151. })
  152. },
  153. loadNoticeData() {
  154. getNoticeData().then(res => {
  155. this.noticeList = res.data;
  156. }).catch(err => {
  157. //console.log(err)
  158. })
  159. },
  160. handleSearchClick(e) {
  161. console.log('监听点击准备跳转页面')
  162. },
  163. handleSwiperClick(index){
  164. console.log('点击了图片索引值:',index)
  165. }
  166. },
  167. computed: {
  168. swiperList(){
  169. return this.bannerList.map(item => {
  170. if (item){
  171. return item;
  172. }
  173. })
  174. },
  175. noticeTextList() {
  176. return this.noticeList.map(item => {
  177. if (item.title){
  178. return item.title;
  179. }
  180. })
  181. }
  182. }
  183. }
  184. </script>
  185. <style lang="scss" scoped>
  186. .search-wrap {
  187. background: #ffffff;
  188. padding: 20rpx;
  189. }
  190. .indicator {
  191. @include flex(row);
  192. justify-content: center;
  193. &__dot {
  194. height: 15rpx;
  195. width: 15rpx;
  196. border-radius: 100rpx;
  197. background-color: rgba(255, 255, 255, 0.35);
  198. margin: 0 10rpx;
  199. transition: background-color 0.3s;
  200. &--active {
  201. background-color: #ffffff;
  202. }
  203. }
  204. }
  205. .grid-title {
  206. line-height: 50rpx;
  207. font-size: 26rpx;
  208. }
  209. .prod-block {
  210. margin-top: -160px;
  211. .bloc-header {
  212. display: flex;
  213. flex-direction: row;
  214. align-items: center;
  215. justify-content: space-between;
  216. padding: 10rpx 30rpx;
  217. .bloc-title {
  218. color: #ffffff;
  219. font-size: 34rpx;
  220. }
  221. .see-more {
  222. color: #ffffff;
  223. background: #3c9cff;
  224. padding: 0 30rpx;
  225. height: 50rpx;
  226. line-height: 50rpx;
  227. border-radius: 50rpx;
  228. font-size: 24rpx;
  229. }
  230. }
  231. &.half, &.list {
  232. margin-top: 0;
  233. .bloc-header {
  234. margin-top: 50rpx;
  235. margin-bottom: 20rpx;
  236. .bloc-title {
  237. color: #333333;
  238. }
  239. .more {
  240. font-size: 24rpx;
  241. }
  242. }
  243. }
  244. .prod-grid {
  245. width: 730rpx;
  246. margin: 0 auto;
  247. .prod-item-box {
  248. padding: 10rpx;
  249. .prod-item {
  250. background: #fff;
  251. border-radius: 10rpx;
  252. box-shadow: -1rpx 1rpx 2rpx #afd3f5, 1rpx 1rpx 0rpx #afd3f5;
  253. justify-content: left;
  254. /deep/ * {
  255. border-radius: 10rpx 10rpx 0 0;
  256. }
  257. .item-info {
  258. padding: 15rpx;
  259. .info-text {
  260. padding-bottom: 15rpx;
  261. }
  262. .price-and-cart {
  263. display: flex;
  264. justify-content: space-between;
  265. }
  266. }
  267. }
  268. }
  269. }
  270. }
  271. .prod-list {
  272. height: auto !important;
  273. .prod-item {
  274. padding: 20rpx;
  275. background: #fff;
  276. display: flex;
  277. flex-direction: row;
  278. justify-content: space-between;
  279. border-bottom: 1rpx solid #f3f3f3;
  280. .prod-image {
  281. border-radius: 10rpx;
  282. /deep/ * {
  283. border-radius: 10rpx;
  284. }
  285. }
  286. .item-info {
  287. padding: 20rpx 30rpx;
  288. .info-text {
  289. padding-bottom: 15rpx;
  290. }
  291. .price-and-cart {
  292. display: flex;
  293. justify-content: space-between;
  294. }
  295. }
  296. }
  297. }
  298. </style>