<template>
	<view class="newPeople">
		<!-- <view class="header">
			<view class="inputSearch" @click="clickSearch">
				<image src="@/static/img/search.png"></image>
				请输入关键词
			</view>
		</view> -->
		<!-- <data-list :data='data'></data-list> -->
		<view class="good-wrap">
			<view class="good" v-for="item in list"
				@click="navto('/pages/product/wholesaleDetail?id=' + item.id + '&time=' + item.time_id + '&status=' + item.status + '&is_new=' + is_new)">
				<image :src="item.image" mode="" class="goo-img"></image>
				<view class="good-tit clamp">
					{{item.title}}
				</view>
				<view class="good-price flex">
					<view class="new-price">
						¥{{item.price}}
					</view>
					<view class="old-price">
						¥{{item.ot_price}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import {
		loadIndexs
	} from '@/api/index.js';
	import {
		getUserInfo
	} from '@/api/user.js'
	import dataList from '@/components/datalist.vue'
	import {
		getNewList
	} from '@/api/whole.js'
	export default {
		data() {
			return {
				list: [],
				is_new: 1,
				// data: {
				// 	page: 1,
				// 	limit: 10,
				// 	sum: 0,
				// 	loadingType: 'loadmore',
				// 	data: []
				// }
			}
		},
		components: {
			dataList
		},
		onLoad() {
			this.getNewList()
			this.getUserInfo()
		},
		// mounted() {
		// 	this.init()
		// },
		methods: {
			...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
			getUserInfo() {
				getUserInfo().then(res => {
					console.log(res)
					this.setUserInfo(res.data);
					this.is_new = res.data.is_whole
				})
			},
			navto(url) {
				uni.navigateTo({
					url: url
				})
			},
			// 點擊搜索框
			clickSearch() {
				uni.navigateTo({
					url: '/pages/product/search'
				});
			},
			init() {
				this.getData()
			},
			getNewList() {
				getNewList().then(res => {
					console.log(res, 'getNewList')
					this.list = res.data
				})
			},
			getData() {
				loadIndexs().then(res => {
					this.data = res.data.info.bastList
					this.loadingType = 'nomore'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	$grey: #95A0B1;
	$text: #333333;
	$red: #FF4C4C;

	.newPeople {
		.header {
			background-color: #fff;
			padding: 30rpx;

			.inputSearch {
				line-height: 35rpx;
				text-align: center;
				color: $grey;
				padding: 10rpx 20rpx;
				border-radius: 50rpx;
				background-color: $page-color-base;

				image {
					width: 32rpx;
					height: 32rpx;
					margin: 0 20rpx;
					margin-bottom: -3rpx;
				}
			}
		}

		.list {
			padding: 20rpx;
			display: flex;
			justify-content: space-between;
			flex-wrap: wrap;

			.item {
				background-color: #fff;
				border-radius: 10rpx;
				overflow: hidden;
				// box-shadow: 2rpx 2rpx 10rpx #e1e1e1;
				margin: 10rpx 0;
				width: 48%;
				height: 0;
				padding-bottom: calc(48% + 120rpx);

				.img {
					border-radius: 10rpx;
					overflow: hidden;
					width: 100%;
					height: 0;
					padding-bottom: 100%;

					image {
						width: 100%;
						height: 100%;
					}
				}

				.name {
					margin: 0 10rpx;
					font-size: 30rpx;
					font-weight: bold;
				}

				.allprice {
					padding: 20rpx 0;

					.price {
						color: $red;
					}

					.ot-price {
						color: $grey;
						text-decoration: line-through;
						font-size: 26rpx;
					}
				}
			}
		}

		.load {
			text-align: center;
			color: $grey;
			font-size: 28rpx;
		}
	}

	.good-wrap {
		display: flex;
		// padding: 0 0 20rpx 20rpx;
		padding-left: 20rpx;
		padding-top: 20rpx;
		flex-wrap: wrap;
	}

	.good {
		width: 345rpx;
		height: 480rpx;
		margin-right: 20rpx;
		margin-bottom: 20rpx;
		background: #FFFFFF;
		box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
		border-radius: 10rpx;

		.goo-img {
			width: 345rpx;
			height: 345rpx;
			border-radius: 10rpx 10rpx 0 0;
			background-color: #bfa;
		}

		.good-tit {
			padding: 15rpx 20rpx;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #333333;
			// line-height: 35rpx;
		}

		.good-price {
			padding-left: 20rpx;
			justify-content: flex-start;

			.new-price {
				font-size: 36rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #FF4C4C;
			}

			.old-price {
				padding-left: 8rpx;
				font-size: 26rpx;
				font-family: PingFang SC;
				font-weight: bold;
				text-decoration: line-through;
				color: #999999;

			}
		}
	}
</style>
