mui.plusReady(function() {

	window.addEventListener('reload', function(e) { //执行刷新
		location.reload();
	});
	var self = plus.webview.currentWebview();
	//console.log(self);
	var shopId = self.id;
	//console.log(shopId);
	var page = 1;
	var pageSize = 10;
	var isloading = false;
	getRecommend(page, pageSize);

	function getRecommend(page, pageSize) {
		var recommenddata = {
			page: page ? page : 1,
			pageSize: pageSize ? pageSize : 10
		}
		recommenddata.shopId = shopId
		if (isloading == true) {
			return;
		} else {
			isloading = false;
		}
		isloading == true
		JZL.ajax(qlgUrl("app/shops/getSpecs"), recommenddata, function(data) {
			//console.log(data);
			if (data.status == 1) {
				var html = '';
				var data = data.data;
				if ('' == data.Rows) {
					//console.log("去" );
					$('.con').append(
						'<p style="float: left;width: 100%;text-align: center;padding-bottom: 9px;">没有更多数据</p>');
					return;
				}
				$.each(data.Rows, function() {
					html += '<div class="row shadown_wai" data-id="' + this.id + '"><label>' + this.setName +
						'</label><div class="caozuo"><span class="bj"><img src="../img/bianji.png"></span><span class="del"><img src="../img/delete.png"></span></div></div>'

					if (page == 1) {
						$('.con_con').html(html);
					} else {
						$('.con_con').append(html);
					}

				})
			} else {
				mui.alert(data.msg)
			}
			isloading == false;
		})

	}

	document.querySelector('.mui-scroll-wrapper').addEventListener('scroll', function(e) {
		if (scroll.y == scroll.maxScrollY) {
			if (isloading == true) {
				page++;
				getRecommend(page, pageSize);
			}
		}
	})
	var specCatsId = "";
	mui('.con').on('tap', '.bj', function() {

		// //console.log(1);
		specCatsId = $(this).parent().parent().attr("data-id");
		//console.log(specCatsId);
		var setName = $(this).parent().parent().find("label").text();
		//console.log(setName);

		JZL.openWindow("addproperties.html", parseInt(shopId), {
			"specCatsId": specCatsId,
			"setName": setName
		})
	})
	//删除
	$('.con').on('tap', '.del', function() {
		specCatsId = $(this).parent().parent().attr("data-id");

		if (confirm('确认删除？')) {
			JZL.ajax(qlgUrl('app/shops/delSpecSet'), {
				id: specCatsId,
				shopId: shopId
			}, function(data) { //服务器返回响应，根据响应结果，分析是否登录成功；  
				// var data = toJson(data, 1);
				//console.log(1);
				//console.log(data);
				if (data.status == 1) {

					location.reload()
				} else {
					mui.alert(data.msg)
				}
			})

		}
	})

	$('.add1').on('tap', function() {
		JZL.openWindow('addproperties.html',parseInt(shopId));
	})

})
