<!-- 任务中心 -->
<template>
	<view class="container">
		<!-- <u-navbar :background="background" :is-back="false" :title="title" :border-bottom="false"></u-navbar> -->
		<view class="task_bg u-relative"></view>
		
		
		<view class="content u-relative" v-if="list.length">
			
			<view class="cell flex justify-between" v-for="(item,index) in list" :key="index"  >
				<image class="cell_icon" :src="'../../static/images/task/member_bg.png'"></image>
				<view class="name u-font-24 text-bold ">已领取</view>
			</view>

		</view>
	
	</view>
</template>

<script>
	export default {
		
		data() {
			return {
				title: '',
				background: {
					backgroundImage: 'linear-gradient(to right, #DDEAFC 0%, #C8DBFA 49%, #AFC9F6 100%)'
				},
				list: [],
			
				isShowMoneyPay: true,
			}
		},
		onShow() {
			this.getTaskdata()
			this.$Request.getT("app/common/type/919", {}).then(res => {
				if (res.code == 0) {
					const sysInfo = uni.getSystemInfoSync();
					let isIos = sysInfo.platform == 'ios'
					this.isShowMoneyPay = !(res.data.value == '1' && isIos)
				}
			});
		},
		methods: {
			/**
			 * 跳转
			 * @param {Object} item
			 */
			goNav( item ) {
				// jumpType (integer, optional): 跳转类型 1 内部路径 2 外部路径 ,
				// type (integer, optional): 任务类型 1 普通任务 2 打卡任务 9 其它 ,
				// buttonUrl
				if ( item.jumpType == 0) {
					this.taskReceive(item.id)
				} else if ( item.jumpType == 1) {
					uni.navigateTo({
						url: item.buttonUrl
					})
				} else if( item.jumpType == 3) {
					uni.switchTab({
						url: item.buttonUrl
					})
				} else if( item.jumpType == 2) {
					plus.runtime.openURL(item.buttonUrl)
				}
				
			},
			
			/**
			 * 领取
			 */
			taskReceive(id) {
				let data = {
					id: id
				}
				this.$Request.getT('app/taskCenter/taskReceive', data).then(res => {
					if (res.code == 0 ) {
						uni.showToast({
							title: id==15?'签到成功':'领取成功',
							icon: 'none'
						})
						setTimeout(()=>{
							this.getTaskdata()
							this.getsignIn()
						},1000)
					} else {
						uni.switchTab({
							url: "/pages/index/index"
						})
					}
				})
			},
			
			/**
			 * 获取任务列表
			 */
			getTaskdata() {
			
				this.$Request.getT('app/discSpinning/selectDiscSpinning', {}).then(res => {
					if (res.code == 0 ) {
						this.list = res.data
					}
					uni.stopPullDownRefresh();
				})
			},
			
		}
	}
</script>

<style lang="scss">
	.container{
		width: 100%;
		height: 100vh;
		// display: flex;
		// flex-direction: column;
		.task_bg{
			width: 100%;
			height: 100%;
			position: absolute;
			top: 0;
			background: url('../../static/images/task/prize_bg.png') no-repeat top center / cover;
			
		}
		
		.content{
			z-index: 9;
			padding: 370rpx 28rpx 0 28rpx;
			display: flex;
			flex-direction: row;
			flex-wrap: wrap;
			justify-content: space-between;
			.cell{
				display: flex;
				flex-direction: column;
				align-items: center;
				background: linear-gradient( 315deg, #FFFFFF 0%, #F9E3D9 100%);
				border-radius: 32rpx 32rpx 32rpx 32rpx;
				border: 4rpx solid #FFFFFF;
				margin-bottom: 48rpx;
				padding: 36rpx 28rpx;
				.cell_icon{
					width: 244rpx!important;
					height: 198rpx!important;
					border-radius: 16rpx!important;
					margin-bottom: 32rpx;
				}
				
				.name{
					font-weight: bold;
					font-size: 28rpx;
					color: #333333;
				}
				
			}
		
		}
	
	}
	

</style>