<template>
	<view class="content">
		<!-- <view class="status_bar"></view>
		<view class="content-money">
			<view class="money-box">
				<view class="goback-box" @click="toBack">
					<image class="goback" src="../../static/img/back.png" mode=""></image>
					</view>
				<view class="header">商品管理</view>
			</view>
		</view> -->
		<view class="commodity-box">
			<view class="commodity" v-for="item in orderList">
				<view class="commodity-detail">
					<view class="commodity-img"><image :src="item.image" mode=""></image></view>
					<view class="commodity-content">
						<view class="top">{{item.store_name}}</view>
						<view class="bottom">
							<view class="price">
								<text class="text">￥</text>
								{{item.price}}
							</view>
							<view class="status">库存：{{item.in_stock}}</view>
						</view>
					</view>
				</view>
			</view>
			<uni-load-more :status="loadingType"></uni-load-more>
		</view>
	</view>
</template>

<script>
import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
import { goods } from '@/api/merchant.js'
export default {
	data() {
		return {
			loadingType: 'more',
			orderList: [],
			page: 1, //当前页面
			limit: 20 //每次信息条数
		};
	},
	onLoad() {
		this.loadData();
	},
	onReachBottom() {
		this.loadData();
	},
	methods: {
		loadData() {
			let obj = this;
			console.log('加载数据');
			if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
				return;
			}
			obj.loadingType = 'loading'
			goods({page:obj.page,limit:obj.limit}).then(({data}) =>{
				console.log(data)
				obj.orderList = obj.orderList.concat(data.data);
				obj.page ++
				if (data.data.length == obj.limit) {
					obj.loadingType = 'more';
				} else {
					obj.loadingType = 'noMore';
				}
			})
		},
		// 点击返回 我的页面
		toBack() {
			uni.navigateBack({
				
			})
		},
		choose() {
			this.isBian = !this.isBian;
		},
		nav(url){
			uni.navigateTo({
				url
			})
		}
	}
};
</script>

<style lang="scss">
page,
.content {
	background: $page-color-base;
	height: 100%;
}

.swiper-box {
	height: calc(100% - 40px);
}

.list-scroll-content {
	height: 100%;
}
.status_bar {
	height: var(--status-bar-height);
	width: 100%;
	background: #ffffff;
}
.money-box {
	height: 80rpx;
	color: #000000;
	text-align: center;
	font-size: 35rpx;
	position: relative;
	background-color: #FFFFFF;
	.header {
		position: absolute;
		left: 0;
		top: 0;
		width: 100%;
		height: 80rpx;
		font-size: 32rpx;
		font-weight: 700;
		z-index: 99;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.goback-box {
		position: absolute;
		left: 24rpx;
		top: 0;
		height: 80rpx;
		display: flex;
		align-items: center;
	}
	.goback {
		z-index: 100;
		width: 20rpx;
		height: 34rpx;
	}
}

.commodity-box {
	width: 750rpx;
	// margin: 20rpx 0;
	// background-color: #FFFFFF;

	.commodity {
		width: 750rpx;

		background-color: #ffffff;
		.checkbox1 {
			font-size: 44rpx;
			line-height: 1;
			padding: 4rpx;
			color: $font-color-disabled;
			background: red;
			border-radius: 50rpx;
		}

		.commodity-detail {
			padding: 30rpx 0;
			padding: 30 34rpx 0 30rpx;
			display: flex;

			.commodity-img {
				margin: 0 30rpx;
				width: 147rpx;
				height: 146rpx;
				border-radius: 10rpx;

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

			.commodity-content {
				width: 500rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				padding: 10rpx 0;
				.top {
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
					font-size: 28rpx;
					font-family: PingFangSC;
					font-weight: 500;
					color: #333333;
				}

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

					.price {
						font-size: 36rpx;
						font-family: PingFang SC;
						font-weight: bold;
						color: #fd5b23;
						.text {
							font-size: 24rpx;
							font-family: PingFang SC;
							font-weight: bold;
							color: #fd5b23;
						}
					}

					.status {
						padding: 6rpx;
						background: #fee1d7;
						border-radius: 5rpx;
						font-size: 20rpx;
						font-family: PingFangSC;
						font-weight: 500;
						color: #fd5b23;
					}
				}
			}
		}
	}
}

</style>
