<template>
	<view class="order view">
		<view class="status_bar" :style="navHeight"></view>
		<view class="listview">
			<view class="cell-list">
				<view class="cell-list-block" @click="goOrder('breakwords-clue')">
					<image class="icon-address" src="@/static/image/home_report@3x.png" mode="aspectFit"></image>
					<view class="cell-list-block__content">
						<text class="cell-list-block__title">提报线索</text>
						<!-- <text class="cell-list-block__desc">Account inquiry</text> -->
					</view>
					<image class="icon-arrow" src="@/static/image/arrow_r@3x.png" mode="aspectFit"></image>
					<!-- 上传图片功能不能使用，上传图片是上传什么格式？支持base64,16进制 -->
				</view>
				<view class="cell-list-block" @click="goOrder('breakwords-market')">
					<image class="icon-address" src="@/static/image/home_marketclue@3x.png" mode="aspectFit"></image>
					<view class="cell-list-block__content">
						<text class="cell-list-block__title">市场线索</text>
						<!-- <text class="cell-list-block__desc">Market support fee inquiry</text> -->
					</view>
					<image class="icon-arrow" src="@/static/image/arrow_r@3x.png" mode="aspectFit"></image>
				</view>
				<view class="cell-list-block" @click="goOrder('breakwords-mission')">
					<image class="icon-address" src="@/static/image/home_breakmission@3x.png" mode="aspectFit"></image>
					<view class="cell-list-block__content">
						<text class="cell-list-block__title">违约任务</text>
						<!-- <text class="cell-list-block__desc">Market support fee inquiry</text> -->
					</view>
					<text class="dot" v-if="unreadCount">{{unreadCount}}</text>
					<image class="icon-arrow" src="@/static/image/arrow_r@3x.png" mode="aspectFit"></image>
				</view>
				<view class="cell-list-block" @click="goOrder('breakwords-handle')">
					<image class="icon-address" src="@/static/image/home_breakrule@3x.png" mode="aspectFit"></image>
					<view class="cell-list-block__content">
						<text class="cell-list-block__title">违约处理</text>
						<!-- <text class="cell-list-block__desc">Market support fee inquiry</text> -->
					</view>
					<image class="icon-arrow" src="@/static/image/arrow_r@3x.png" mode="aspectFit"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		apiGetMissionList,
	} from '@/servers/breakwords.js'
	
	import {
		mapState
	} from 'vuex'


	export default {
		data() {
			return {
				condition: {
					currentPage: 1,
					pageSize: 100,
					distributer: true,
					userId: '',
					type: 0, // 全部9 代办0 已办2
				},
				agentNum: 0,
			}
		},
		computed: {
			navHeight() {
				return {
					'height': `${this.sysinfo.safeArea.top + 44}px`
				}
			},
			...mapState(['sysinfo', 'userInfo']),
			unreadCount() {
				return this.agentNum - 0 > 0 ? this.agentNum - 99 > 0 ? '99+' : this.agentNum : ''
			},
		},
		onShow() {
			this.condition.userId = this.userInfo.code
			this.apiGetMissionList()
		},
		methods: {
			async apiGetMissionList(){
				const params = {
					...this.condition,
				}
				try{
					const res = await apiGetMissionList(params)
					this.agentNum = res && res.data && res.data.count || 0
					if(res.result === "F"){
						uni.showToast({
							title: res.message,
							icon: 'none',
							duration: 1500
						});
					}
				}catch(e){
					uni.showToast({
						title: '服务异常',
						icon: 'none',
						duration: 1500
					});
				}
			},
			goOrder(type) {
				uni.navigateTo({
					url: `/pages/${type}/${type}`
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.view {
		flex-direction: column;
	}

	/* #ifndef APP-PLUS */
	page {
		width: 100%;
		min-height: 100%;
		display: flex;
		background: #fff;
	}

	.status_bar {
		height: var(--status-bar-height);
	}

	/* #endif */

	.order {
		flex: 1;
		background: #fff;
		padding: 0 32rpx;
	}

	.listview {
		flex: 1;
		flex-direction: column;
		padding-top: 64rpx;
	}

	.cell-list {
		flex-direction: column;
	}

	.icon-address {
		width: 88rpx;
		height: 88rpx;
		margin-right: 24rpx;
		margin-top: 20rpx;
	}

	.cell-list-block__content {
		display: flex;
		flex: 1;
		flex-direction: column;
	}

	.cell-list-block__title {
		color: #333;
		font-size: 28rpx;
		font-weight: 500;
		flex: 1;
		align-items: center;
		margin-bottom: 4rpx;
	}

	.cell-list-block__desc {
		color: #acacac;
		font-size: 12px;
	}

	.icon-arrow {
		width: 12rpx;
		height: 20rpx;
	}

	.cell-list-block {
		display: flex;
		height: 77px;
		margin-bottom: 24rpx;
		background: #f8f9fa;
		border-radius: 8px;
		padding: 0 36rpx 0 16rpx;
		align-items: center;
	}
	.dot {
		width: 44rpx;
		height: 36rpx;
		line-height: 36rpx;
		background: #ff0f00;
		border-radius: 18rpx;
		color: #fff;
		font-size: 22rpx;
		margin-right: 28rpx;
		text-align: center;
	}
</style>
