123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- <template>
- <view class="home">
- <!-- 搜索框 -->
- <van-search :value="value" placeholder="请输入搜索关键词" />
- <!-- <Test></Test>> -->
- <!-- 轮播图 -->
- <view class="uni-margin-wrap">
- <swiper class="swiper" circular :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval"
- :duration="duration">
- <swiper-item v-for="(item,index) in bannerList" :key="index">
- <image class="pictures" :src="item.imgUrl" mode=""></image>
- </swiper-item>
- </swiper>
- </view>
- <!-- 商品分类 -->
- <van-grid>
- <van-grid-item icon="new-arrival-o" text="新品推荐" />
- <van-grid-item icon="underway-o" text="限时特惠" />
- <van-grid-item icon="hot-o" text="每日疯抢" />
- <van-grid-item icon="coupon-o" text="领优惠劵" />
- </van-grid>
- <!-- 通知 -->
- <van-notice-bar left-icon="volume-o" :scrollable="false">
- <swiper class="noticeSwiper" vertical="true" :indicator-dots="false" :autoplay="3000" >
- <swiper-item v-for="(item,index) in noticeList" :key="index">
- <view class="title">
- {{item.title}}
- </view>
- </swiper-item>
- </swiper>
- </van-notice-bar>
- <!-- 商品 -->
- <view class="product" v-for="(item,index) in prodList" :key="index">
- <view class="title">
- <text>{{item.title}}</text>
- <text>查看更多</text>
- </view>
- <view class="product_list">
- <view class="main" v-for="(item1,index1) in item.productDtoList" :key="index1" @click.native="goDetail(item1)">
- <image :src="item1.pic" mode=""></image>
- <view class="name">
- {{item1.prodName}}
- </view>
- <view class="price">
- ¥{{item1.price}}
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- banner,
- notice,
- product
- } from '../../api/home.js';
- export default {
- data() {
- return {
- value: "",
- bannerList: [],
- indicatorDots: true,
- autoplay: true,
- interval: 2000,
- duration: 500,
- noticeList:[],
- prodList: []
- }
- },
- onLoad() {
- uni.startPullDownRefresh();
- setTimeout(()=>{
- banner().then(res => {
- this.bannerList = res;
- }),
- notice().then(res => {
- console.log(res)
- this.noticeList = res.records;
- }),
- product().then(res => {
- this.prodList = res;
- console.log(this.prodList, '商品')
- })
- },1000)
- },
- onPullDownRefresh() {
- setTimeout(function () {
- uni.stopPullDownRefresh();
- }, 2000);
- },
- methods: {
- goDetail(value) {
- console.log(value)
- uni.navigateTo({
- // url:"/pages/detail/detail"
- url: `/pages/detail/detail?id=${value.prodId}`
- })
- }
- }
- }
- </script>
- <style lang='less'>
- .uni-margin-wrap {
- width: 100%;
- .swiper {
- height: 430rpx;
- .swiper-item {
- display: block;
- height: 430rpx;
- line-height: 430rpx;
- text-align: center;
- }
- }
- }
- .pictures {
- width: 100%;
- height: 100%;
- }
- .noticeSwiper {
- width: 668rpx;
- }
- .product {
- .title {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin: 20rpx 10rpx;
- font-size: 28rpx;
- }
- .title text:last-child {
- color: #ccc;
- font-size: 21rpx;
- }
- .product_list {
- display: flex;
- flex-wrap: wrap;
- .main {
- width: 33%;
- display: flex;
- flex-direction: column;
- align-items: center;
- margin: 18rpx 0;
- image {
- width: 200rpx;
- height: 200rpx;
- border-radius: 8rpx;
- }
- .name {
- width: 200rpx;
- font-size: 22rpx;
- overflow:hidden;
- text-overflow:ellipsis;
- display:-webkit-box;
- -webkit-box-orient:vertical;
- -webkit-line-clamp:2;
- }
- .price {
- width: 200rpx;
- color: #f00;
- }
- }
- }
- }
- </style>
|