<template>
<view class="appCotent">
<view>
    <custom-tarbar :selected="3"></custom-tarbar>
    <view class="shop">
        <div class="my__search"  @click='goSearch'>
            <u-search placeholder="搜搜你最想知道的" :showAction='false' bgColor='#ffffff' v-model="keyword"></u-search>
        </div>
        <div class="shop__swiper">
            <view class="u-demo-block">
                <u-swiper :list="list3" previousMargin="30" nextMargin="30" circular :autoplay="false" height='150' radius="5" bgColor="#ffffff"></u-swiper>
            </view>
        </div>
        <div class="view__content">
            <div class="view__title">超低价养车好物</div>
            <div class="shop__list2">
                <div class="shop__item2" v-for="(vo,inx) in mallList" :key="inx" @click="goDetail(vo.id)">
                    <div class="item2__img">
                        <image :src="getImage(vo.mainImgUrl)" />
                    </div>
                    <div class="item2__title">{{vo.title}}</div>
                    <div class="item2__price">￥{{vo.currentPrice/100}}</div>
                </div>
            </div>
        </div>
        <div class="shop__list__one">
            <div class="view__title">车主精选 养车必备</div>
            <div class="list__one__items">
                <div class="one__item" v-for="(vo,inx) in boutiqueMallList" :key="inx" @click="goDetail(vo.id)">
                    <div class="one__item__img">
                        <image :src="getImage(vo.mainImgUrl)" />
                    </div>
                    <div class="one__item__title">
                        {{vo.title}}
                    </div>
                    <div class="one__item__price">
                        ￥{{vo.currentPrice/100}}<span class="num__two">￥{{vo.originalPrice/100}}</span>
                    </div>
                </div>
            </div>
        </div>
    </view>
    <u-gap bgColor="transparent" height="60"></u-gap>

</view>
</view>
</template>

<script>
import customTarbar from '@/common/wxcomponents/custom-tarbar/custom-tarbar.vue';
export default {
    components: {
        'custom-tarbar': customTarbar
    },
    data() {
        return {
            keyword: '',
            list3: [
                'https://cdn.uviewui.com/uview/swiper/swiper3.png',
                'https://cdn.uviewui.com/uview/swiper/swiper2.png',
                'https://cdn.uviewui.com/uview/swiper/swiper1.png',
            ],
			//普通商品列表
			mallList: [],
			//精品商品
			boutiqueMallList: [],
        }
    },
    methods: {
        goSearch() {
            uni.navigateTo({
                url: '/pagesC/pages/shop/search'
            })
        },
        goDetail(id) {
            uni.navigateTo({
                url: '/pagesC/pages/shop/detail?id=' + id
            })
        },
		getMallList(){
			let opts = { url: '/app/mall/list', method: 'get' };
			this.http.httpTokenRequest(opts, {classification: "1"}).then(res => {
				if (res.data.code == 200) {
					this.mallList = res.data.data.rows
				}
			})
		},
		getBoutiqueMallList(){
			let opts = { url: '/app/mall/list', method: 'get' };
			this.http.httpTokenRequest(opts, {classification: "2"}).then(res => {
				if (res.data.code == 200) {
					this.boutiqueMallList = res.data.data.rows
				}
			})
		},
		getImage(imageUrl){
			return imageUrl;
		},
    },
	onShow() {
		this.getMallList()
		this.getBoutiqueMallList()
	}
};
</script>

<style lang="scss" scoped>
.shop {
    height: 100%;

    .shop__list__one {
        padding: 0 30rpx;
        background: #f9f9f9;

        .list__one__items {
            display: flex;
            align-items: center;
            justify-content: space-between;
            flex-wrap: wrap;

            .one__item {
                width: 48%;
                background: #FFFFFF;
                box-shadow: 0rpx 0rpx 28rpx 1rpx rgba(232, 232, 232, 0.2);
                border-radius: 20rpx;
                margin-bottom: 30rpx;

                .one__item__img {
                    width: 100%;
                    height: 320rpx;
                    background: #FFD4D4;
                    border-radius: 20rpx;

                    image {
                        width: 100%;
                        height: 100%;
                        border-radius: 20rpx;
                    }
                }

                .one__item__title {
                    font-size: 32rpx;
                    font-family: PingFang SC;
                    font-weight: 500;
                    color: #333333;
                    margin: 20rpx 0;
                    text-indent: 20rpx;
                    margin-bottom: 10rpx;
                }

                .one__item__price {
                    font-size: 24rpx;
                    font-family: PingFang SC;
                    font-weight: 500;
                    color: #E1251B;
                    text-indent: 20rpx;
                    padding-bottom: 20rpx;

                    span {
                        font-size: 20rpx;
                        font-family: PingFang SC;
                        font-weight: 500;
                        color: #999999;
                    }
                }
            }
        }
    }

    .my__search {
        padding: 30rpx;
    }

    .view__title {

        font-size: 38rpx;
        font-family: PingFang SC;
        font-weight: bold;
        color: #333333;
        position: relative;
        z-index: 999;
        margin-bottom: 30rpx;
    }

    .view__title::before {
        content: "";
        width: 76rpx;
        height: 14rpx;
        display: inline-block;
        background: url('@/static/move-car/love-car1.png') no-repeat;
        background-size: contain;
        position: absolute;
        bottom: 7rpx;
        z-index: -1;

    }

    .shop__swiper {
        margin-bottom: 30rpx;
    }

    .view__content {
        padding: 40rpx;
        background: #FFFFFF;
        box-shadow: 0rpx 0rpx 28rpx 1rpx rgba(232, 232, 232, 0.2);
        border-radius: 20rpx;
        margin-bottom: 40rpx;

        .shop__list2 {
            display: flex;
            align-items: center;
            justify-content: space-between;

            .shop__item2 {
                width: 25%;

                .item2__img {
                    margin-bottom: 20rpx;
                    text-align: center;

                    image {
                        width: 145rpx;
                        height: 145rpx;
                    }
                }

                .item2__title {
                    font-size: 28rpx;
                    font-family: PingFang SC;
                    font-weight: 500;
                    color: #333333;
                    line-height: 42rpx;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                    overflow: hidden;
                }

                .item2__price {
                    font-size: 24rpx;
                    font-family: PingFang SC;
                    font-weight: 500;
                    color: #E1251B;
                    line-height: 42rpx;
                }
            }
        }

    }
}
</style>
