var numberset = 0;
var funcA = function (e, ins) {
  // console.log('source is', JSON.stringify(e))
	var instance = ins.selectComponent('.rightConten');
	var scrollTop = e.detail.scrollTop;
	var dataset = JSON.parse(JSON.stringify(instance.getDataset()));
	var ind = checkarr(scrollTop,dataset.listheight,dataset);

	// console.log(scrollTop,ind,dataset.intoselect,numberset);
	console.log(dataset.listheight);
	// console.log(scrollTop,ind,dataset.listheight[ind],dataset.listheight[ind + 1]);
	var leftTitle = '.leftTitle'+ind
	if (numberset != ind) {
		numberset = ind;
		ins.callMethod('setIntoselect', ind);
		for (var index = 0; index < dataset.listheight.length; index++) {
			var leftItem = '.leftTitle'+index
			if (ins.selectComponent(leftItem)) {
				ins.selectComponent(leftItem).setStyle({
					"color": dataset.datas.first_tab_color
				}).setStyle({
					"background-color": dataset.datas.first_tab_bg_color
				})
			}
		}
		ins.selectComponent(leftTitle).setStyle({
			"color": dataset.datas.first_tab_active_color
		}).setStyle({
			"background-color": dataset.datas.first_tab_active_bg_color
		})
	}else{
		for (var index = 0; index < dataset.listheight.length; index++) {
			var leftItem = '.leftTitle'+index
			if (ins.selectComponent(leftItem)) {
				ins.selectComponent(leftItem).setStyle({
					"color": dataset.datas.first_tab_color
				})
			}
		}
	}

	var str = '#a' + ind + ' .right-two-title';
	if(scrollTop < (dataset.listheight[ind-1]-100) || scrollTop > (dataset.listheight[ind+1]-100) || scrollTop < (dataset.listheight[ind]+70)) {
		for (var index1 = 0; index1 < dataset.listheight.length; index1++) {
			var strItem = '#a' + index1 + ' .right-two-title'
			var showItem = '.showByFixed'+ index1
			if (ins.selectComponent(strItem) && ins.selectComponent(strItem).hasClass('isfix')) {
				if(dataset.datas.show_first_tab){
					ins.selectComponent(strItem).removeClass('classView').removeClass('isfix').addClass('classViewTwo').addClass('nonefix').addClass('nonefix')
				}else{
					ins.selectComponent(strItem).removeClass('classView').removeClass('isfix').addClass('classView').addClass('nonefix').addClass('nonefix')
				}
				ins.selectComponent(showItem).setStyle({
					"display": 'none'
				})
			}
		}
	}else if (scrollTop >= (dataset.listheight[ind]+50) && scrollTop < (dataset.listheight[ind + 1]+100)) {
		for (var index1 = 0; index1 < dataset.listheight.length; index1++) {
			var strItem = '#a' + index1 + ' .right-two-title'
			var showItem = '.showByFixed'+ index1
			if (ins.selectComponent(strItem) && ins.selectComponent(strItem).hasClass('isfix')) {
				if(dataset.datas.show_first_tab){
					ins.selectComponent(strItem).removeClass('classView').removeClass('isfix').addClass('classViewTwo').addClass('nonefix').addClass('nonefix')
				}else{
					ins.selectComponent(strItem).removeClass('classView').removeClass('isfix').addClass('classView').addClass('nonefix').addClass('nonefix')
					ins.selectComponent(strItem).setStyle({
						"left": '0',
						"width":'100%'
					})
				}
				ins.selectComponent(showItem).setStyle({
					"display": 'none'
				})
			}
		}
		if (ins.selectComponent(str) && ins.selectComponent(str).hasClass('nonefix')) {
			var showItem1 = '.showByFixed'+ ind
			ins.selectComponent(str).removeClass('classViewTwo').removeClass('nonefix').addClass('isfix').addClass('classView')
			ins.selectComponent(showItem1).setStyle({
				"display": 'flex'
			})
		}
	}

			}
function checkarr(Top, min,dataset) {
	var ind;
	for (var i = 0; i < min.length; i++) {
		if (Top >= (min[i]) && Top < min[i + 1]) {
			ind = i;
		}
	}
	return ind;
}
module.exports = {
  funcA: funcA
}
