mui.plusReady(function() {
	window.addEventListener('reload', function(e) { //执行刷新
		location.reload();
	});	
	$('.orange').html("￥000.00")
	var self = plus.webview.currentWebview();
	//console.log(self);
	var shopId = self.id;
	//console.log(shopId);
	$('.seeting').on("tap", function() {
		JZL.openWindow('shopsetting.html', parseInt(shopId))
	})
	$('.money').on('tap', function() {
		JZL.openWindow('cash-out.html', parseInt(shopId))
	})
	// 		$('.money').on('tap','.myYouhuiquan_cb',function () {
	// 			var data_href=$(this).attr('data-href')
	// 			var data_expect =$(this).attr('data_expect')
	// 			//console.log(data_href)
	// 			  JZL.openWindow('income-details.html',parseInt(shopId),{data_href:data_href,data_expect:data_expect})
	// 		}) 
	//     $('.money').on('tap',function () {
	// 	  JZL.openWindow('paymentvoucher.html',parseInt(shopId))
	// })
	// 获取商家首页信息  
	JZL.ajax(qlgUrl('app/shops/shopInfo'), {
		shopId: shopId
	}, function(data) {
		//console.log(data);
		if (1 == data.status) {
			data = data.data;
			// //console.log(data.status);
			var html = "";
			var html1 = "";
			html = '<p class="myshopname">' + data.shopName + '</p><span class="shop_">' + data.userName +
				'</span><span class="shop_">' + data.phone + '</span>'
			$('.shop_info').html(html)
			$('.wait_money .orange').text('￥' + data.waitPayMoneyNum);
			$('.comp_money .orange').text('￥' + data.receivedPayMoneyNum);
			var html1 = '<div class="order_cb indent_btn" data-href="waitPay"><div class="num">' + data.waitPayNum +
				'</div><div class="orderimg"><img src="../img/daifukuan.png" /></div><p>待付款</p></div><div class="order_cb indent_btn" data-href="waitConfirm"><div class="num">' +
				data.waitConfirmNum +
				'</div><div class="orderimg"><img src="../img/pingjia.png" /></div><p>待确认</p></div><div class="order_cb indent_btn" data-href="waitDeliver"><div class="num">' +
				data.waitDeliverNum +
				'</div><div class="orderimg"><img src="../img/daifahuo.png" /></div><p>待发货</p></div><div class="order_cb indent_btn" data-href="waitReceive"><div class="num">' +
				data.waitReceiveNum +
				'</div><div class="orderimg"><img src="../img/daishouhuo.png" /></div><p>待收货</p></div><div class="order_cb indent_btn" data-href="abnormal"><div class="num">' +
				data.abnormal + '</div><div class="orderimg"><img src="../img/orderdetail.png" /></div><p>退款/售后</p></div>';
			$('.line_order .order_con').html(html1);
			$('.num').each(function() {
				if ($(this).html() == '0') {
					$(this).css('display', 'none');
				}
			})
		}else{
					mui.alert(data.msg)
				}
	})

	mui('.order').on('tap', '.indent_btn', function() {
		var data_href = this.attributes["data-href"].nodeValue;
		JZL.openWindow("shop_indent.html", data_href, {
			data_href: data_href,
			shopId: shopId
		})

	})
	mui('.order').on('tap', '.pingzheng', function() {
		// var data_href = this.attributes["data-href"].nodeValue;
		JZL.openWindow("paymentVoucher.html", parseInt(shopId))

	})
	mui('.order').on('tap', '.tixian', function() {
		// var data_href = this.attributes["data-href"].nodeValue;
		JZL.openWindow('cash-out.html', parseInt(shopId))

	})
	getRecommend(nowpage, pagesize)
	// 获取店铺商品
	var nowpage = 1;
	var pagesize = 10;
	var isload = false;

	function getRecommend(nowpage, pagesize) {
		var recommenddata = {
			nowpage: nowpage ? nowpage : 1,
			pagesize: pagesize ? pagesize : 10
		}
		recommenddata.shopId = shopId

		if (isload == true) {
			return;
		}
		isload = true
		mui.ajax(qlgUrl('app/Shopping/getShopIndexGoodsList'), {
			data: recommenddata,
			dataType: 'json', //服务器返回json格式数据  
			type: 'post', //HTTP请求类型  
			timeout: 10000, //超时时间设置为10秒；  
			success: function(data) { //服务器返回响应，根据响应结果，分析是否登录成功；  
				// //console.log(data);

				//				var data = toJson(data, 1);
				if (data.status == 1) {
					//console.log(data);

					var html = '';
					var data = data.data;
					if (data.Rows == '') {
						$('.mui-scroll').append(
							'<p style="float: left;width: 100%;text-align: center;padding-bottom: 9px;">没有更多商品</p>');

						return;
					}
					$.each(data.Rows, function() {
						html += '<div class="shop-goods-detail" data-goodsId="' + this.goodsId +
							'"><div class="sgd-list"><img class="sdg-img" src="' + hyhImgUrl(this.goodsImg) +
							'" alt=""><div class="sgd-info">' + this.goodsName +
							'</div><div class="sgd-price"><div class="market-price"><span>价格</span><span class="price">￥' + this.shopPrice +
							'</span></div><div class="youhuilv"><span>优惠率</span><span class="preference-rate">' + this.discountRate +
							'%</span></div></div></div></div>'
						// 						html += '<div class="recommend_con_block shadown_wai" data-goodsId="' + this.goodsId +
						// 							'"><img class="rcb_img" src="' + hyhImgUrl(this.goodsImg) +
						// 							'" alt="" /><div class="rcb_con"><div class="rcb_title">'+ this.goodsName + '</div><div class="rcb_pay">￥' + this.shopPrice +
						// 							' <span style="display:none;">满减</span></div><div class="rcb_bottom"><div><span>'+this.saleNum+'</span><span>人购买</span></div><div><span>优惠率&nbsp;&nbsp;&nbsp;</span><span>'+this.discountRate+'%</span></div></div></div><img style="display:none;" class="icon_icon" src="../img/icon_sscl.png" alt="" /></div>';
					});

					if (nowpage == 1) {
						// //console.log(222);
						$('.shop-goods-content').html(html);
					} else {
						$('.shop-goods-content').append(html);
					}

					// 					$('.rcb_title span').each(function() {
					// 						if ($(this).attr('data-goodsId') == 1) {
					// 							$(this).css('display', 'none');
					// 						}
					// 					})
					$('.sdg-img').height($('.sdg-img').width());

				} else{
					mui.alert(data.msg)
				}
				isload - false
			},
			error: function(xhr, type, errorThrown) { //异常处理；  
				//								mui.alert(errorThrown);      
			}
		});

	}

	document.querySelector('.mui-scroll-wrapper').addEventListener('scroll', function(e) {
		// 判断默认行为是否可以被禁用
		if (e.cancelable) {
			// 判断默认行为是否已经被禁用
			if (!e.defaultPrevented) {
				e.preventDefault();
			}
		}
		if (scroll.y == scroll.maxScrollY) {
			if (isload = true) {
				nowpage++;
				getRecommend(nowpage, pagesize);
			}
		}
	})

	$('.shop-goods').on('tap', '.shop-goods-detail', function() {
		var good_id = $(this).attr('data-goodsId');
		JZL.openWindow('details.html', parseInt(good_id), {
			shopId: shopId,
			data_id: good_id
		})

	})
















})
