<template>
	<view class="yu-home-list">
		<block v-for="(item, index) in list" :key="index" class="lists">
			<view class="home-list-item"
				:class="{'active-margin-bottom': bottomMargin, 'active-border-radius' : radius}"
				:style="{ background: backgroundColor }">
				<view class="activesTop" @tap.stop="release(1,item)">
					<image v-if="item.classify == 2" class="item-Logo" style="width: 44rpx;height: 44rpx;"
						src="/static/img/home/storeLogo.png"></image>
					<image v-if="item.classify == 1" class="item-Logo" style="width: 44rpx;height: 44rpx;" src="/static/img/my/eleicon.png">
					</image>
					<view class="ptName" v-if="item.classify == 1">饿了么任务</view>
					<view class="ptName" v-if="item.classify == 2">美团任务</view>
					<view class="jsTime" style="color: #999999;" v-if="item.status==0">待审核</view>
					<view class="jsTime" v-if="item.status==1">结束时间: {{item.endTime}}</view>
					<view class="jsTime" style="color: #FF4701;" v-if="item.status==2">已下架</view>
					<view class="jsTime" style="color: #FF4701;" v-if="item.status==3">未通过</view>
				</view>
				<view class="item-wrap" :class="{'active-border-bottom': splitLine }">
					<image :src="item.titleImg" class="item-storeImg" @tap.stop="release(1,item)"></image>
					<view class="right" @tap.stop="release(1,item)">
						<view class="tag-title">
							<view class="tag-titles">{{item.goodsTitle}}</view>
						</view>
						<view class="item-wz">
							<view style="width: 100%;display: flex;">
								<view class="item-weizhi">{{item.city}}{{item.address}}</view>
							</view>
						</view>
					</view>
					<view style="border:1upx solid #E6E6E6;margin: 20rpx 0;" v-if="item.status==2 || item.status==3 || btnType"></view>
					<view v-if="item.status==2 && item.auditContent" @tap.stop="release(1,item)">通过原因：{{item.auditContent}}</view>
					<view v-if="item.status==3 && item.auditContent" @tap.stop="release(1,item)" style="color: #FF4701;">拒绝原因：{{item.auditContent}}</view>
					<view style="text-align: right;">
						<!-- <button class="btn quxiao" v-if="item.status==0"
							@tap.stop="quxiao(2,item.goodsId)">取消活动</button> -->
						<button class="btn quxiao" v-if="item.status==2 || item.status==3"
							@tap.stop="release(1,item)">重新上架</button>
						<!-- <button v-if="!btnType" class="btn xiugai" @tap.stop="release(1,item)">修改编辑</button> -->
						<button v-if="btnType" class="btn xiugai" @tap="clickItem(item,index)">查看审核</button>
					</view>
				</view>
			</view>
		</block>
	</view>
</template>

<script>
	export default {
		name: 'taskHomeList',
		props: {
			list: {
				type: Array,
				default () {
					return [];
				}
			},
			//背景颜色
			backgroundColor: {
				type: String,
				default: '#FFFFFF'
			},
			//是否需要下方横线
			splitLine: {
				type: Boolean,
				default: false
			},
			//是否需要更改btn
			btnType: {
				type: Boolean,
				default: false
			},
			//下方20rpx margin
			bottomMargin: {
				type: Boolean,
				default: false
			},
			radius: {
				type: Boolean,
				default: false
			},
		},
		watch: {

		},
		data() {
			return {};
		},
		methods: {
			clickItem(item, index) {
				this.$emit('click', {
					item: item,
					index: index,
				});
			},
			quxiao(status, id) {
				uni.showModal({
					title: '温馨提示',
					content: status == 1 ? '您确认要重新上架当前活动吗？' : '您确认要取消当前活动吗？',
					showCancel: true,
					cancelText: '取消',
					confirmText: '确认',
					success: res => {
						if (res.confirm) {
							if (status == 1) {
								this.$queue.showLoading('提交中...');
							} else if (status == 2) {
								this.$queue.showLoading('取消中...');
							}
							this.$Request.postT('/goodsMerchant/updateGoodsStatus?goodsId=' + id + '&status=' +
								status).then(res => {
								if (res.code == 0) {
									uni.hideLoading();
									uni.$emit('update', {
										msg: '页面更新'
									});
									if (status == 1) {
										this.$queue.showToast('上架成功！');
									} else if (status == 2) {
										this.$queue.showToast('取消成功！');
									}
								} else {
									uni.hideLoading();
									this.$queue.showToast(res.msg);
								}
							});
						}
					}
				});
			},
			release(index, item) {
				// this.$queue.setData('hdItem',item)
				uni.navigateTo({
					url: '/pages/index/addTask?goodsId=' + item.goodsId
				});
			}
		}
	};
</script>

<style lang="scss" scoped>
	.yu-home-list {
		justify-content: space-between;

		.lists {
			display: inline-block;
			margin-top: 20rpx;
		}

		.home-list-item {
			// padding: 0 30upx;
			width: 100%;
			position: relative;
			background-color: #FFFFFF;
			box-sizing: border-box;

			// border-bottom: 10px solid #F5F5F5;
			.activesTop {
				height: 60rpx;
				position: relative;

				.item-Logo {
					width: 40rpx;
					margin: 10rpx;
					float: left;
					border-radius: 50%;
				}

				.ptName {
					line-height: 60rpx;
					font-size: 28rpx;
					color: #333;
				}

				.jsTime {
					position: absolute;
					line-height: 60rpx;
					right: 10rpx;
					top: 0;
					color: #333333;
					font-size: 22rpx;
				}
			}

			.item-wrap {
				padding: 20upx;
			}

			.item-storeImg {
				position: absolute;
				width: 100rpx;
				height: 100rpx;
				border-radius: 8rpx;
			}

			.right {
				padding-left: 120upx;

				.tag-title {
					display: flex;
					font-size: 30upx;
					color: #333;
					line-height: 50upx;
					align-items: center;

					.item-Logo {
						width: 40upx;
						height: 40upx;
					}

					.tag-titles {
						padding-left: 10rpx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}
				}

				.item-wz {
					display: flex;
					align-items: center;
					position: relative;
					margin-top: 16upx;
					color: #999;
					font-size: 22upx;

					.weizhi {
						width: 26rpx;
						height: 30rpx;
						margin-top: 3rpx;
					}

					.item-weizhi {
						padding-left: 10upx;
						color: #333;
						text-overflow: ellipsis;
						overflow: hidden;
						white-space: nowrap;
						font-size: 24rpx;
					}

				}
			}

			.btn {
				width: 30%;
				border: 1rpx solid #333;
				background: #fff;
				color: #333;
				font-size: 24rpx;
				height: 64rpx;
				line-height: 64rpx;
				margin: 0 20rpx;
				display: inline-block;
			}

			.xiugai {
				border: 1rpx solid #FEC103;
				background: #FEC103;
			}

			button::after {
				border: none;
			}
		}

		// 是否有底部线条
		.home-list-item .active-border-bottom {
			// border-bottom: 2rpx solid #E6E6E6;
		}

		.home-list-item:last-child .active-border-bottom {
			// 是否有底部线条
			border-bottom: 0;
		}

		// 是否圆角
		.active-border-radius {
			border-radius: 10upx;
		}

		// 是否有底部20rpx边距
		.active-margin-bottom {
			margin-bottom: 20upx;
		}

		.active-margin-bottom:last-child {
			margin-bottom: 0;
		}
	}
</style>
