<template>
	<view>
		<!-- 		<image src="../../static/images/top-bg.png"></image> -->
		<!-- <navigation-bar :title="title" background-color="#fff" front-color="#000000" :left-button="null" /> -->
		<uni-nav-bar color="#fff" height="60" left-icon="back" @clickLeft="back()" right-icon="list" :border="false" backgroundColor="#0081ff" :title="title" />
		</u-navbar>
		<u-list v-if="active==1" class="list" width="100%" @scrolltolower="scrolltolower">
			<u-list-item v-for="(item, index) in goods" :key="index">
				<view class="item-box">
					<view class="goods-item">
						<u-row>
							<u-col span="5" @click="toDetails(item.id)">
								<u--image :showLoading="true" src="" width="270rpx" height="220rpx"></u--image>
							</u-col>
							<u-col span="7">
								<view class="t1 txt" @click="toDetails(item.id)">
									<text>{{item.goodsName}}</text>
									<!-- <text>[老板力荐]鲜活小龙虾(帮剪头去虾线)约250g/份</text> -->
								</view>
								<view class="txt">
									<text v-if="item.grossWeight">{{item.grossWeight}}吨</text>
								</view>
								<view class="txt" v-if="item.tradeAreaName">
									<u-tag style="width: 250rpx" :text="item.tradeAreaName" plain size="mini"></u-tag>
								</view>
								<view class="t4">
									<view class="price">￥{{item.price}}</view>
									<view class="car">
										<u-icon color="#fff" name="shopping-cart-fill" size="30"></u-icon>
									</view>
								</view>
							</u-col>
						</u-row>
					</view>
				</view>
			</u-list-item>
		</u-list>
		<order v-if="active==3"></order>
		<view class="tab">
			<view :class="active==item.id ? 'active-btn' : 'tabBtn'" v-for="item in tabList" :key="item.id"
				@click="tabClick(item.id)">{{item.name}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loadmoreStatus: 'loadmore',
				goods: [],
				active: 1,
				title: '一级市场',
				tabList: [{
						id: 1,
						name: "市场"
					},
					{
						id: 2,
						name: "购物车"
					},
					{
						id: 3,
						name: "订单列表"
					}
				]
			}
		},
		onLoad() {
			this.getGoodsList()
		},
		// onShow() {
		// 	var a = document.getElementsByClassName('uni-page-head-hd')[0]
		// 	a.style.display = 'none';
		// },
		methods: {
			getGoodsList() {
				this.http.request({
					url: '/level-one-server/TbGoodsTransit/getTransitList',
					success: res => {
						this.goods = res.data.data;
						this.goods.forEach((item, index) => {
							if (index === this.goods.length - 1) {
								this.loadmoreStatus = 'nomore'
							} else {
								this.loadmoreStatus = 'loadmore'
							}
						})
					}
				});
			},
			scrolltolower() {
				this.getGoodsList()
			},
			toDetails(id) {
				this.$common.to('/pages/goodsDetails/goodsDetails?id=' + id)
			},
			change(index) {
				console.log(index)
				this.active = index
			},
			tabClick(id) {
				this.active = id
				if (id == 1) {
					this.title = '一级市场'
				} else if (id == 2) {
					this.title = '购物车'
				} else {
					this.title = '订单列表'
				}
			},
			back() {
				uni.navigateBack({
					delta: 1
				})
			},
			rightClick() {
				console.log('rightClick');
			},
		}
	}
</script>

<style>
	page {
		background-image: url(../../static/images/top-bg.png);
		background-size: 100% 400rpx;
		background-repeat: no-repeat;
		background-position: top;
		background-color: #f3f4f6;
	}

	.list {
		height: auto;
		border-radius: 10rpx;
		margin: 15rpx;
	}

	.tab {
		position: fixed;
		bottom: 1rpx;
		width: 100%;
		height: 100rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-top: #CFCFCF 1rpx solid;
	}

	.goods-item {
		margin-bottom: 8rpx;
	}

	.item-box {
		height: 230rpx;
		width: 90%;
		padding: 20rpx;
		background-color: #fff;
		border: 1rpx #FFF solid;
		margin: 10rpx 0rpx;
		border-radius: 10rpx;
	}
	
	.txt{
		/* height: 50rpx; */
		margin-bottom: 20rpx;
	}
	
	.t1{
		font-size: 32rpx;
		font-weight: bold;
		word-wrap: break-word;
		position: relative;
		top: 1rpx;
		right: 5rpx;
	}
	
	.t4{
		display: flex;
		position: relative;
		bottom: 1rpx;
		right: 5rpx;
	}
	
	.price{
		color: #ef732a;
		width: 400rpx;
		font-weight: bold;
	}
	
	.car{
		background-color: #0081ff;
		width: 60rpx;
		height: 60rpx;
		border-radius: 30rpx;
		text-align: center;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.tabBtn {
		width: 35%;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		margin: 0 30rpx;
	}

	.active-btn {
		width: 35%;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #fff;
		background-color: #00BFFF;
	}
</style>