<template name="mytask">
	<view>
		<image mode="widthFix" style="width: 100%;" :src="tasklist.taskimage" v-if="tasklist.taskimage"></image>
		<view class="cu-bar margin-top bg-white">
			<view class="action">
				<text class="cuIcon-title text-blue"></text>
				新手任务
			</view>
		</view>
		<view class="cu-list menu">
			<view class="cu-item">
				<view class="content padding-tb-sm">
					<view>
						<text class="cuIcon-wenzi text-blue margin-right-xs f45"></text>
						完善简历
						<view class="cu-tag bg-orange margin-left sm">+{{tasklist.improveresume}}</view>
					</view>
					<view class="text-gray text-sm padding-left">
						让企业更容易找到您，顺便把钱赚了
					</view>
				</view>
				<view class="action">
					<button role="button" class="cu-btn bg-blue shadow" @click="goPage('/pages/my/myinfo')" v-if="is_perfect == 2">马上完善</button>
					<button role="button" class="cu-btn bg-gray shadow" v-if="is_perfect == 1">已完善</button>
				</view>
			</view>
			<view class="cu-item">
				<view class="content padding-tb-sm">
					<view>
						<text class="cuIcon-card text-orange margin-right-xs f45"></text>
						实名认证
						<view class="cu-tag bg-orange margin-left sm">+{{tasklist.certification}}</view>
					</view>
					<view class="text-gray text-sm padding-left">
						实名认证，更有保障
					</view>
				</view>
				<view class="action">
					<button role="button" class="cu-btn bg-blue shadow" @click="goPage('/pages/my/myauth')" v-if="is_auth == 2">马上认证</button>
					<button role="button" class="cu-btn bg-gray shadow" v-if="is_auth == 1">已认证</button>
				</view>
			</view>
			<view class="cu-item">
				<view class="content padding-tb-sm">
					<view>
						<text class="cuIcon-forwardfill text-green margin-right-xs f45"></text>
						入职成功
						<view class="cu-tag bg-orange margin-left sm">+{{tasklist.entry}}</view>
					</view>
					<view class="text-gray text-sm padding-left">
						即有工作，又有钱赚，一箭双雕
					</view>
				</view>
				<view class="action">
					<button role="button" class="cu-btn bg-blue shadow" @click="goNavPage('/pages/comjobs/comjobs')">找工作</button>
				</view>
			</view>
		</view>
		<!-- <view class="cu-bar margin-top bg-white">
			<view class="action">
				<text class="cuIcon-title text-blue"></text>
				每日任务
			</view>
		</view>
		<view class="cu-list menu">
			<view class="cu-item">
				<view class="content padding-tb-sm">
					<view>
						<text class="cuIcon-edit text-purple margin-right-xs f45"></text>
						签到
						<view class="cu-tag bg-orange margin-left sm">+{{tasklist.signin}}</view>
					</view>
					<view class="text-gray text-sm padding-left">
						连续签到赚积分
					</view>
				</view>
				<view class="action">
					<button role="button" class="cu-btn bg-blue shadow" @click="signin()" v-if="is_signin == 2">签到</button>
					<button role="button" class="cu-btn bg-gray shadow" v-if="is_signin == 1">已签</button>
				</view>
			</view>
			<view class="cu-item">
				<view class="content padding-tb-sm">
					<view>
						<text class="cuIcon-share text-mauve margin-right-xs f45"></text>
						分享岗位
						<view class="cu-tag bg-orange margin-left sm">+{{tasklist.sharejob}}</view>
					</view>
					<view class="text-gray text-sm padding-left">
						进度{{share_num}}/{{tasklist.sharejobnum}}，每天前{{tasklist.sharejobnum}}分享，可获取奖励
					</view>
				</view>
				<view class="action">
					<button role="button" class="cu-btn bg-blue shadow" @click="goNavPage('/pages/comjobs/comjobs')">去分享</button>
				</view>
			</view>
		</view> -->
	</view>
</template>

<script>
	var _this;
	export default {
		data() {
			return {
				userinfo : {},
				tasklist : {
					improveresume : "",
					certification : "",
					entry : "",
					signin : "",
					sharejob : "",
					sharejobnum : "",
					taskimage : "",
				},
				is_perfect : 2,
				is_auth : 2,
				share_num : 0,
				is_signin : 2,
			}
		},
		onLoad: function() {
			_this = this;
			//#ifdef APP-PLUS
			_this.appplatform = uni.getSystemInfoSync().platform;
			//#endif
			_this.userinfo = uni.getStorageSync('userinfo') || null;
			_this.is_perfect = _this.userinfo.is_perfect
			_this.is_auth = _this.userinfo.is_auth
			_this.$req.ajax({
				title: "加载中...",
				path: "my/task",
				data: {
					userid: _this.userinfo.id
				}
			}).then((data) => {
				_this.tasklist = data.tasklist;
				_this.share_num = data.share_num;
				_this.is_signin = data.is_signin;
			});
			
		},
		methods: {
			goPage: function(pageurl) {
				uni.navigateTo({
					url: pageurl,
					fail: function() {
						uni.switchTab({
							url: pageurl
						});
					}
				});
			},
			goNavPage: function(pageurl) {
				uni.redirectTo({
					url: pageurl
				});
			},
			signin: function() {
				_this.$req.ajax({
					path: "my/signin",
					title: "签到中...",
					data: {
						userid: _this.userinfo.id
					}
				}).then((data) => {
					uni.showModal({
						title: '信息提示',
						content: '签到成功',
						showCancel: false
					});
					_this.is_signin = 1;
				})
			},
		},
	}
</script>

<style>
	.cu-list.menu>.cu-item .content .cu-tag.sm{font-size: 22rpx;}
	.f45 {font-size: 45rpx;}
</style>