<template>
	<view v-if="isShow">
		<block v-if="pageList && pageList.length > 0">
			<view class="tits dflex">
				<view class="flex">所有类目</view>
			</view>
			<view class="list">
				<view class="li" v-for="(item, index) in pageList" :key="index">
					<view class="lit ddflex" @click="selectNode(item)">
						<view class="flex">{{ item.dictName}}</view>

						<view class="del">
							<image
								:src="'/match/static/images/' + (categoryList==item.dictValue ? 'checkBox_h' : 'checkBox') + '.png'">
							</image>
						</view>
					</view>
					
				</view>
			</view>
			<view class="btns" @click="submitSave()">确定</view>

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

<script>
	const req = require('../../utils/request.js');
	const util = require('../../utils/util.js');
	var app = getApp();
	export default {
		data() {
			return {
				isShow: false,
				pageList: [],
				categoryList: '', //选择的类目
			};
		},

		onLoad(opt) {
			let pages = getCurrentPages(); //获取所有页面栈实例列表
			let prevPage = pages[pages.length - 2]; //上一页页面实例
			this.categoryList = JSON.parse(JSON.stringify(prevPage.$vm.matchType)); //上页面选中的成员
			console.log('this.deptObj》》》》》》》',this.categoryList);
		},

		onShow() {
			this.getList();
		},
		methods: {
			
			selectNode(item){
				if(this.categoryList!=item.dictValue){
					this.categoryList = item.dictValue
				}else{
					this.categoryList = ''
				}
			},
			
			submitSave() {
				let pages = getCurrentPages(); //获取所有页面栈实例列表
				let prevPage = pages[pages.length - 2]; //上一页页面实例
				prevPage.$vm.matchType = this.categoryList; //修改上一页
				uni.navigateBack({
					delta: 1
				});
			},

			
			getList() {
				uni.showLoading({
					title: '加载中'
				});
				let params = {
					dictType:'match_type'
				};
				req.getRequest('/api/other/dict/info', params, res => {
					if (res && res.length > 0) {
						res.map(it => {
							it.isOperate = false;
							it.isShowChildren = true;
							return it;
						});
					}
					this.pageList = res;
					this.isShow = true;
					uni.hideLoading();
				});
			},
			
			jumpUrl(url) {
				uni.navigateTo({
					url: url
				});
			},
		}
	};
</script>

<style>
	@import './sort.css';
</style>