<template>
	<view class="page">
		<view class="coupon-tab" >
			<view class="tab" :class="{'action':TabShow===0}" @click="onCouponTab(0)">
				<text style="margin-bottom: 20rpx;">全部</text>
				<text class="line"></text>
			</view>
			<view class="tab" :class="{'action':TabShow===1}" @click="onCouponTab(1)">
				<text style="margin-bottom: 20rpx;">未处理</text>
				<text class="line"></text>
			</view>
			<view class="tab" :class="{'action':TabShow===2}" @click="onCouponTab(2)">
				<text style="margin-bottom: 20rpx;">已处理</text>
				<text class="line"></text>
			</view>
		</view>
		<view class="listBox" >
			<view class="content" >
				<!-- 列表 -->
				<view class="user-list">
					<view class="list" v-for="item in list" @click="maptaskdetail(item)">
						<view class="title">
							<view>{{item.taskName}}</view>
							<!-- <text>{{item.taskStatus}}</text> -->
						</view>
						<view class="more-content">
							<view class="more-content-img"><text class="more-content-text" :style="item.taskStatus=='已处理'?'background: #00D970;':''">{{item.taskStatus}}</text>
								<image src="../../static/right.png"></image>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				TabShow: 0,
				nvConfig: {
					title: "巡检任务",
					bgColor: "#ffffff",
					color: "#000000",
					fixedAssist: {
						hide: true,
					},
				},
				list: [],
				pages: {
					pageNum: 1,
					pageSize: 10,
					taskStatus: '',
					toUser: uni.getStorageSync('USERS_KEY').phonenumber
				}
			}
		},
		onPageScroll(e) {
			this.$refs.nv.pageScroll(e)
		},
		computed: {
			pageTop() {
				return parseInt(88 * uni.getSystemInfoSync().windowWidth / 750) + uni.getSystemInfoSync().statusBarHeight
			}
		},
		onShow() {
			this.getwdrwlist();
		},
		methods: {
			// 获取我的任务的列表
			getwdrwlist() {
				this.API.getwdrwlist(this.pages).then(res => {
					console.log("我的任务列表", res);
					this.list = res.rows
				})
			},
			onCouponTab(type) {
				this.TabShow = type;
				if (type == 0) {
					this.pages.taskStatus = ''
				}
				if (type == 1) {
					this.pages.taskStatus = '未处理'
				}
				if (type == 2) {
					this.pages.taskStatus = '已处理'
				}

				this.getwdrwlist();
			},
			maptaskdetail(info) {
				var info = JSON.stringify(info)
				uni.navigateTo({
					url: '/pages/maptaskdetail/maptaskdetail?info=' + info
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	@import 'maptask.scss';
</style>