<template>
	<view class="se-p-20 se-pb-200">
		<view v-if="list.length>0">
			<view class="se-grid-2 se-pt-10">
				<view class="items-box se-br-5 se-px-10 se-pos" v-for="(items,indexs) in list" :key="indexs">
					<text class="se-status se-bgc-gray" v-if="items.status==2">未通过</text>
					<text class="se-status se-bgc-blue" v-if="items.status==1">已通过</text>
					<text class="se-status se-bgc-red" v-if="items.status==0">审核中</text>
					<image class="se-w-p-100 se-h-200 se-bgc-f5 se-br-5  se-py-5" :src="items.images[0]" mode=""  @click="onDetail(items)"></image>
					<view class="se-c-black se-fs-24 se-fw-6 se-mt-10"  @click="onDetail(items)">
						{{ items.goodsName }}
					</view>
					<view class="se-flex se-flex-ff-rw se-mt-10"  v-if="items.categoryoneName!='环卫设备及配件'" @click="onDetail(items)">
						<view class="se-tag">
							{{items.brand}}
						</view>
						<view class="se-tag">
							{{items.goodsTime}}
						</view>
						<view class="se-tag">
							{{items.mileage}}公里
						</view>
					</view>
					<view class="se-flex se-flex-h-sb se-w-p-100 se-pt-20"  @click="onDetail(items)">
						<view class="se-fs-24 se-display-ib">
							<text class="se-c-orange se-fs-26 se-fw-6"><text class="se-fs-24">￥</text>{{items.price}}<text class="se-fs-24">元</text><text class="se-fs-24" v-if="items.cartypeId=='1875536807086256130'">/月</text></text>
						</view>
					</view>
					<view class="se-flex se-flex-h-sb se-w-p-100 se-pt-20">
						<text class="se-fs-22 se-c-white se-br-5 se-bgc-red se-px-10 se-py-5 se-br-5" @click="onDel(items)">删除</text>
						<text class="se-fs-22 se-c-white se-br-5 se-bgc-blue se-px-10 se-py-5 se-br-5" @click="onEdit(items)">修改</text>
					</view>
				</view>
			</view>
			<u-empty v-if="list && list.length==0" mode="list"></u-empty>
		</view>
		<view v-else>
			<u-empty mode="list" ></u-empty>
		</view>
		<view class="se-pos-fixed se-flex-h-c se-bs-t se-w-750 se-h-200" style="background-color: #fff;bottom: 0;left: 0;">
			<view @click="onApply()" class="se-mb-20 se-br-20 se-w-400 se-ml-20 se-flex-h-c se-h-80 se-lh-80 se-ta-c se-fs-32 se-c-white se-bgc-green">
				<text class="se-ml-10">立即发布</text>
			</view>
		</view>
	</view>
</template>
<script>
	import { queryGoodsList,deleteGoods } from "@/common/api.js"
	export default{
		data(){
			return{
				pageNo:1,
				pageSize:10,
				list:[]
			}
		},
		onLoad(options) {
			this.onPageList()
		},
		onPullDownRefresh() {
			let that = this
			that.pageNo =  1
			that.list = []
			that.onPageList()
		},
		onReachBottom() {
			let that = this
			that.pageNo = that.pageNo + 1
			that.onPageList()
		},
		methods:{
			onDetail(event){
				uni.navigateTo({
					url:"/pages_subpack/detail/index?goodsId="+event.id
				})
			},
			onApply(){
				uni.navigateTo({
					url:"/pages_subpack/release/index"
				})
			},
			onPageList(){
				let that = this
				let params={
					pageNo:that.pageNo,
					pageSize:that.pageSize,
					token:uni.getStorageSync('token')
				}
				queryGoodsList(params).then(response=>{
					console.info("queryApplyList",response)
					response.result.records.forEach((items,indexs)=>{
						if(items.image){
							items.images = items.image.split(',')
						}else{
							items.images = []
						}
						if(items.imageBack){
							items.imageBacks = items.imageBack.split(',')
						}else{
							items.imageBacks = []
						}
						if(items.imageCab){
							items.imageCabs = items.imageCab.split(',')
						}else{
							items.imageCabs = []
						}
						if(items.imageFront){
							items.imageFronts = items.imageFront.split(',')
						}else{
							items.imageFronts = []
						}
						if(items.imageLeft){
							items.imageLefts = items.imageLeft.split(',')
						}else{
							items.imageLefts = []
						}
						if(items.imageRight){
							items.imageRights = items.imageRight.split(',')
						}else{
							items.imageRights = []
						}
					})
					that.list = that.list.concat(response.result.records)
				}).catch(error=>{
					
				})
			},
			onDel(event){
				let that = this
				uni.showModal({
					title:"温馨提示",
					content:"确定删除当前数据？",
					cancelText:"取消",
					confirmText:"确定",
					success:(res)=> {
						console.info(res)
						if(res.confirm==true){
							deleteGoods({goodsId:event.id}).then(response=>{
								uni.$u.toast('删除成功')
								that.pageNo =  1
								that.list = []
								that.onPageList()
							}).catch(error=>{
								
							})
						}
					}
				})
			},
			onEdit(event){
				uni.navigateTo({
					url:"/pages_subpack/release/index?id="+event.id
				})
			}
		}
	}
</script>

<style>
	page{
		background-color: #f5f5f5;
	}
	.items-box{
		background: #ffffff;
		border-radius: 8rpx;
		box-shadow: 0rpx 4rpx 16rpx 0rpx rgba(0,0,0,0.05); 
		padding: 20rpx;
	}
	.se-status{
		padding: 5rpx 10rpx;
		border-radius: 5rpx 0 0 0;
		border: 2rpx solid rgba(0,0,0,0.00);
		font-size: 18rpx;
		font-family: PingFang SC, PingFang SC-Bold;
		font-weight: 700;
		text-align: center;
		color: #ffffff;
		position: absolute;
		left: 0px;
		top: 0px;
	}
	.se-tag{
		padding: 5rpx 10rpx;
		background: #fff2df;
		border-radius: 4rpx;
		border: 2rpx solid rgba(0,0,0,0.00);
		font-size: 16rpx;
		font-family: PingFang SC, PingFang SC-Bold;
		font-weight: 700;
		text-align: center;
		color: #fab143;
		margin-left: 10rpx;
	}
	
	.se-tag:first-child{
		margin-left: 0rpx;
	}
</style>