<template>
	<view class="total-page page-box task-bg">
		<Nav :title="'创建任务'" :genre="1" is_fixed></Nav>
		<TaskImgTab @setProductId="setProductId" :list-type="1"></TaskImgTab>
		<view class="sys-background-fff m-20 p-20 r-20">
			<view class="creation_item row-justify-sb center line-60 sys-bg-BFD2CC r-20 p-30 m-b20"
				v-for="(item,index) in creationList" :key="index" @click="onCeationTask(item)">
				<view class="row-c">
					<image class="wh-60 m-r20" :src="item.product_icon" mode="aspectFill"></image>
					<text class="size-28 text-color-12 sys-weight-400">{{item.product_name}}</text>
				</view>
				<image class="wh-45" src="https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/task/task-arrows.png" mode="aspectFill"></image>
			</view>
		</view>
    <en-blank v-if="creationList.length<=0"></en-blank>
	</view>
</template>

<script>
	import TaskImgTab from "@/common/task/task_ima_tab.vue"
  import {getTaskType} from "@/api/task";
  import EnBlank from "@/components/en-utils/en-blank/en-blank.vue";

	export default {
		components: {
      EnBlank,
			TaskImgTab,
		},
		data() {
			return {
        typeId:2,
				creationList: [ ]
			}
		},
    mounted() {
      this.getTaskType()
    },
    methods: {
      setProductId(typeId){
        if(this.typeId!==typeId){
          this.typeId=typeId
          this.getTaskType()
        }

      },
      getTaskType(){
        getTaskType({'productType':this.typeId}).then((res)=>{
          if(res.code===1){
            this.creationList=res.data;
          }
        })
      },
			onCeationTask(item) {
				uni.navigateTo({
					url: `/page_task/information/information?title=${item.product_name}&productId=${item.id}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.creation_item:last-child {
		margin-bottom: 0;
	}
</style>
