<template>
	<view class="myProductStyle" :style="{'height':contentHeight}">
		<view style="width: 100%;height: 100%;">
			<u-empty v-if="g.length==0" text="暂无数据" mode="data"></u-empty>
			<template v-if="g.length > 0">
				<view  
				  style="
						height: calc(100vh);
						width: calc(100vw);
						overflow: hidden;
						padding: 10px 0;
				  ">
					<scroll-view
						:scroll-y="true"
						:enable-back-to-top="true"
						:enable-flex="true"
						@scrolltolower="lower"
						:style="{ height: '100%' }">
						<view style="display: flex;flex-direction: column;align-items: center;">
							<view v-for="(item, index) in g" :key="index" class="listbox">
								<view class="box_c" >
									<image :src="item.CoverImage" style="width: 65px;height: 65px;border-radius: 6px;"></image>	
									<view style="width: calc(100vw - 30px - 65px - 15px);display: flex;flex-direction: column;margin-left: 15px;">
										<view class="box_c_name">{{item.Name}}</view>
									</view>
								</view>
								<view class="SupplierListstyle">
									<view class="Sitem" v-for="(x, index2) in item.SupplierSpecificationList" :key="index2" v-if='item.showdetail == true || index2==0' @click=" isdetail(index,index2) ">
										<view class="Sitem_gg" >
											<text v-for="(j, index3) in x.attr_list" :key="index3">{{j.attr_group_name}}:{{j.attr_name}}{{x.attr_list.length==index3+1?'':','}}</text>
										</view>
										<view class="Sitem_k">库存{{x.stock}}</view>
										<view class="Sitem_k">成本价{{x.costPrice}}</view>
										<view class="Sitem_k" :style="{color:mainColor}">￥{{x.price}}</view>
										<u-icon name="arrow" v-if='item.showdetail==false && index2==0' ></u-icon>
										<u-icon name="arrow-down" v-if='item.showdetail==true && index2==0'></u-icon>
									</view>
								</view>
								
							</view>
						</view>
							<u-loadmore
							  :status="status"
							  :load-text="loadText"
							  :font-size="24"
							  :margin-top="20"
							  :margin-bottom="20"
							  bg-color="#f3f4f6"
							/>
					</scroll-view>
					
				</view>
			</template>
		</view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageTitle: "我的产品",
				contentHeight:0,
				mainColor:'',
				secondary:'',
				g:[],
				
				msg:{
					pageIndex: 1,
					pageSize:10,
					SupplierIds:0
				},
				SelectBillState:0,
				page_count:1,
				status: "loadmore",
				loadText: {
				  loadmore: "轻轻上拉，加载更多",
				  loading: "努力加载中",
				  nomore: "没有更多了",
				},
			}
		},
	
		created(){
			 this.contentHeight = this.$utils.calcContentHeight(-40)+'px';
			 this.mainColor = this.$uiConfig.mainColor;
			 this.secondary = this.$uiConfig.secondary;
			uni.setNavigationBarTitle({
			  title: this.pageTitle,
			});
		},
		onLoad(options){
			if(options){
				this.msg.SupplierIds = options.ID
			}
			 this.init()
		},
		mounted() {
			
		},
		methods: {
			init(){
				
				uni.showLoading({
					title: '加载中'
				});
				this.request2(
				  {
				  	url: '/api/AppletUser/GetAppletGoodsPageList',
				  	data: this.msg
				  },
							
				  (res) => {
					 
					uni.hideLoading();
					let data  = res.data.pageData
					data.forEach(x=>{
						x.showdetail = false
					})
					this.g = this.g.concat(data);
					console.log(this.g)
					this.page_count = res.data.pageCount;
					if (this.page_count == 1) {
					  this.status = "nomore";
					}
					
				  }
			);
			},
			
			lower(e) {
			  if (this.msg.pageIndex < this.page_count) {
				this.msg.pageIndex++;
				this.status = "loading";
				this.init();
			  } else {
				this.status = "nomore";
			  }
			},
			isdetail(index,index2){
				if(index2==0){
					this.g[index].showdetail = !this.g[index].showdetail;
					this.$forceUpdate()
				}
				
			},	
		}
	}
</script>

<style>
.myProductStyle{
	background: #FAF8F9;
	
}

	.myProductStyle .listbox{
		width: 100%;
		margin-bottom: 10px;
		padding: 15px;
		background: #fff;
		display: flex;
		flex-direction: column;
		align-items: center
		
	}
	.myProductStyle .box_t{
		display: flex;
		flex-direction: row;
		align-items: center;
		width: 100%;
		overflow: hidden;
		height: 32px;
	}
	.myProductStyle .box_c{
		display: flex;
		flex-direction: row;
		
		width: 100%;
		overflow: hidden;
		margin-top: 15px;
	}
	.myProductStyle .box_c_name{
		text-overflow: -o-ellipsis-lastline;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 3;
		line-clamp: 3;
		-webkit-box-orient: vertical;
		font-size: 13px;
		color: #111111;
	}
	.myProductStyle .box_r_b{
		width: 100%;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		margin-top: 3px;
	}
	.myProductStyle .OrderNoStyle{
		width: 100%;
		height: 35px;
		background: #F8F6F5;
		display: flex;
		flex-direction: row;
		align-items: center;
		font-size: 11px;
		color: #888888;
		margin-top: 15px;
		
	}
	.myProductStyle .SupplierListstyle{
		width: 100%;
		background: #F8F6F5;
		display: flex;
		flex-direction: column;
		align-items: center;
		margin-top: 10px;
	}
	.myProductStyle .Sitem{
		width: 96%;
		display: flex;
		flex-direction: row;
		align-items: center;
		font-size: 11px;
		color: #888888;
		height: 35px;
		margin-left: 2%;
		
	}
	.myProductStyle .Sitem_gg{
		width: 35%;
		text-overflow: -o-ellipsis-lastline;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		line-clamp: 1;
		-webkit-box-orient: vertical;
	}
	.Sitem_k{
		width: 20%;
		text-align: center
	}
</style>

