<template>
	<view>
		<view class="listCardlog" v-for="(item,index) in plist" :key="index" @tap="goDetail(item.comjobs.id)">
			<view class="listCardlog-item">
				<view class="item-left">
					<image class="item-icon" :src="$getImageUrl('static/images/applet/index/cardA.png')"
						mode="widthFix"></image>
					<view class="item-content bold">
						{{item.comjobs.title}}
						<text class="text-red text-sm">(按月)</text>
						<text class="text-red text-sm" v-if="item.comjobs.wtype==2">(按时)</text>
						<text class="text-red text-sm" v-if="item.comjobs.wtype==3">(按件)</text>
						<text class="text-red text-sm" v-if="item.comjobs.wtype==4">(按项目)</text>
					</view>
				</view>
				<view class="item-right">
					<!-- <image class="item-icon" :src="$getImageUrl('static/images/applet/index/cardD.png')"
							mode="widthFix"></image> -->
					<view class="item-content small" style="color: #c3c3c3;" @tap.stop="delLog(index, item.id)">取消报名
					</view>
				</view>
			</view>
			<view class="listCardlog-item">
				<view class="item-left">
					<image class="item-icon" :src="$getImageUrl('static/images/applet/comJobs/icon-sum.png')" mode="widthFix"></image>
					<view class="item-content red">{{item.comjobs.zwagall}}</view>
				</view>
				<view class="item-right">
					<!-- <image class="item-icon" src="../../static/images/comJobs/icon-pageView.png" mode="widthFix">
						</image> -->
					<view class="item-content red small">{{item.status_text}}</view>
				</view>
			</view>
			<view class="listCardlog-tag">
				<view v-for="(titem,tindex) in item.comjobs.tags" :key="tindex" class="tag-item">{{titem}}</view>
			</view>
			<view class="listCardlog-item">
				<view class="item-left">
					<!-- <image class="item-icon" src="../../static/images/comJobs/icon-sum.png" mode="widthFix"></image> -->
					<view class="item-content bold">{{item.comjobs.worker.title}}</view>
				</view>
				<view class="item-right">
					<image class="item-icon" :src="$getImageUrl('static/images/applet/comJobs/icon-pageView.png')" mode="widthFix">
					</image>
					<view class="item-content small">浏览量:{{item.comjobs.volume}}</view>
				</view>
			</view>
			<view style="height: 1rpx;"></view>
		</view>

		<block v-for="(item,index) in plist" :key="index" v-if="false">
			<view class="cu-card dynamic no-card solid-bottom echo-comjobs-item padding-top-sm padding-lr-sm radius">
				<view class="cu-item shadow padding-top-sm padding-bottom" @tap="goDetail(item.comjobs.id)">
					<view class="padding-lr flex justify-between align-center">
						<view class="basis-lg text-bold text-df text-cut">
							{{item.comjobs.title}}
							<text class="text-red text-sm" v-if="item.comjobs.wtype==1">(按月)</text>
							<text class="text-red text-sm" v-if="item.comjobs.wtype==2">(按时)</text>
							<text class="text-red text-sm" v-if="item.comjobs.wtype==3">(按件)</text>
							<text class="text-red text-sm" v-if="item.comjobs.wtype==4">(按项目)</text>
						</view>
						<view class="basis-sm text-cut text-right text-gray text-sm">
							<view class="basis-xs text-cut text-right text-gray text-sm"
								@tap.stop="delLog(index, item.id)">取消报名</view>
						</view>
					</view>
					<view class="padding-lr flex justify-between align-bottom">
						<view class="basis-lg text-bold text-df text-cut">
							<view><text class="text-red text-bold">{{item.comjobs.zwagall}}</text></view>
						</view>
						<view class="basis-sm text-cut text-right text-red text-sm">
							{{item.status_text}}
						</view>
					</view>
					<view class="padding-lr padding-tb-xs text-cut">
						<view v-for="(titem,tindex) in item.comjobs.tags" :key="tindex"
							class="cu-tag light bg-blue lg echo-tags-item">{{titem}}</view>
					</view>
					<view class="padding-lr text-cut text-sm flex justify-between align-center">
						<view class="basis-lg text-df text-cut">{{item.comjobs.worker.title}}</view>
						<view class="basis-sm text-cut text-right text-sm">
							浏览量:{{item.comjobs.volume}}
						</view>
					</view>
				</view>
			</view>
		</block>
		<uni-load-more :status="pstatus"></uni-load-more>
	</view>
</template>

<script>
	import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue";
	var _this;
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				userinfo: {},
				pstatus: 'more',
				ppage: 1,
				psize: 20,
				plist: []
			};
		},
		onLoad: function() {
			_this = this;
			_this.userinfo = _this.checkLogin("/pages/comjobs/log");
			if (_this.userinfo === false) {
				return false;
			}
			_this.getMore();
		},
		onPullDownRefresh: function() {
			_this.ppage = 1;
			_this.pstatus = 'more';
			_this.plist = [];
			_this.getMore();
		},
		onReachBottom: function() {
			if (_this.pstatus !== 'more') {
				return;
			}
			_this.getMore();
		},
		methods: {
			delLog: function(index, logid) {
				uni.showModal({
					title: '温馨提示',
					content: '确定要删除吗？',
					success(res) {
						if (res.confirm) {
							_this.$req.ajax({
								path: "comjobs/dellog",
								data: {
									logid: logid,
									userid: _this.userinfo.id
								}
							}).then((data) => {
								_this.plist.splice(index, 1);
							}).catch((err) => {
								uni.showModal({
									title: '信息提示',
									content: err,
									showCancel: false
								});
							});
						}
					}
				});

			},
			getMore: function() {
				_this.$req.ajax({
					path: "comjobs/listlog",
					data: {
						ppage: _this.ppage,
						psize: _this.psize,
						userid: _this.userinfo.id
					}
				}).then((data) => {
					_this.pstatus = data.pstatus;
					_this.plist = _this.plist.concat(data.plist);
					_this.ppage += 1;
					console.log("数据", _this.plist)
					uni.stopPullDownRefresh();
				}).catch((err) => {
					uni.showModal({
						title: '信息提示',
						content: err,
						showCancel: false
					});
				});
			},
			goDetail: function(comjobsid) {
				uni.navigateTo({
					url: '/pages/comjobs/detail?comjobsid=' + comjobsid
				});
			},
			goShop: function(workerid) {
				uni.navigateTo({
					url: '/pages/worker/shop?workerid=' + workerid
				});
			},
		}
	}
</script>

<style lang="scss">
	.listCardlog {
		margin: 0 20rpx 40rpx;
		padding: 28rpx 24rpx 0;
		background-color: #FFFFFF;
		border-radius: 12rpx;

		.listCardlog-tag {
			display: flex;
			flex-wrap: wrap;

			.tag-item {
				margin-left: 15rpx;
				background: #E6F2FF;
				font-size: 20rpx;
				color: #CA151C;
				padding: 5rpx 12rpx;
				margin-bottom: 20rpx;
				white-space: nowrap;
				text-overflow: ellipsis;
				white-space: nowrap;
				overflow: hidden;
			}
		}


		.listCardlog-item {
			display: flex;
			margin-bottom: 28rpx;

			.item-left {
				width: 60%;
				display: flex;
				align-items: center;

				.item-icon {
					width: 30rpx;
					height: 30rpx;
					margin-right: 15rpx;
				}

				.item-content {
					flex: 1;
					font-size: 28rpx;
					color: #747474;
					overflow: hidden;
					text-overflow: ellipsis;
					-webkit-line-clamp: 1;
					display: -webkit-box;
					-webkit-box-orient: vertical;
				}

				.bold {
					font-size: 28rpx;
					font-weight: 600;
					color: #383838;
				}

				.red {
					font-size: 28rpx;
					font-weight: 600;
					color: #CA151C;
				}
			}

			.item-right {
				width: 35%;
				margin-left: 15rpx;
				display: flex;
				justify-content: flex-end;

				.item-icon {
					width: 30rpx;
					height: 30rpx;
					margin-right: 15rpx;
				}

				.item-content {
					// flex: 1;
					font-size: 28rpx;
					line-height: 35rpx;
					color: #747474;
					// overflow: hidden;
					// text-overflow: ellipsis;
					// -webkit-line-clamp: 1;
					// display: -webkit-box;
					// -webkit-box-orient: vertical;
				}

				.bold {
					font-size: 28rpx;
					font-weight: 600;
					color: #383838;
				}

				.red {
					font-size: 28rpx;
					font-weight: 600;
					color: #CA151C;
				}

				.small {
					font-size: 24rpx;
				}
			}
		}
	}
</style>