define(['zepto','medtap','swiper','https://review-formal.iplusmed.com/Common/javaScript/beforeSubmitTest.js?v=2.0'],function($, medtap, swiper, beforeSubmit){
	
	var inital = {
		portType:getEnvironment(),
		init:function(){
			inital.getCart();
			inital.getCategory();
		},
		//获取购物车
		getCart:function(){
			medtap.jzz(1);
			medtap._ajax({
				url:'/shop/cart/getCart',
				type:'get',
				portType: inital.portType,
				data:{
					
				},
				success:function(res){
					if(res.success == true){
						medtap.jzz(0);
						var list = res.content.cartVO.hasOwnProperty('cartDetail') ? res.content.cartVO.cartDetail : [],
							products = [];
						window.allNumber = 0;
						for(var i = 0;i < list.length;i++){
							var item = list[i];
							var obj = {};
							if(item.onsale == false){
								
							}else{
								obj.pid = item.goodsId;
								obj.pimageUrl = item.goodsCoverImg;
								obj.pname = item.goodsName;
								obj.pnumber = item.amount;
								obj.selectHas = false;
								obj.isVirtual = item.goodsIsVirtual;
								obj.isCrossBorder = item.goodsIsCrossBorder;
								obj.price = Number(item.goodsRealPrice).toFixed(2);
								window.allNumber += item.amount;
								products.push(obj);
							}
						}
						localStorage.shopJson_products = JSON.stringify(products);
						$('.shoppingNum').text(window.allNumber);
						if ($('.shoppingNum').text() >= 1) {
							$('.shoppingNum').show();
						} else {
							$('.shoppingNum').hide();
						}
					}else{
						//medtap.winPop(res.resultDesc);
					}
				}
				
			})
		},
		getCategory:function(){
			medtap.jzz(1);
			medtap._ajax({
				url:'/shop/goods/listGoodsCategory',
				type:'get',
				portType:inital.portType,
				data:{
					
				},
				success:function(res){
					if(res.success == true){
						var list = res.content.goodsCategoryVOList,
							types = ['热门商品'],
							goodsCategoryIds = [''];
						[].forEach.call(list,function(item){
							types.push(item.content);
							goodsCategoryIds.push(item.node + '-' + item.categoryId);
						});
						inital.initSwiper(types,goodsCategoryIds);
					}else{
						medtap.winPop(res.resultDesc);
					}
				}
			})
		},
		initSwiper:function(types, goodsCategoryIds){
			var typeHtml = '';
			for (index in types) {
				typeHtml += '<div class="swiper-slide">' + types[index] + '</div>'
			}
			$('.category-wrapper').html(typeHtml);
			$('.category-wrapper div').eq(0).addClass('on');
			var swiper1 = new Swiper('.category-container', {
				slidesPerView: 6
			});
			$('.category-wrapper').on('click', 'div', function() {
				$(this).addClass('on').siblings().removeClass('on');
				var index = $(this).index(),
					offset = 1,
					limit = 10;
				window.queryGoods(offset, limit, goodsCategoryIds[index]);
			});
		}
	}
	inital.init();
	
	window.viewDidAppear = function() {
		inital.getCart();
	}
	/* 基础参数定义 */
	var shopJson_products,
		productsList,
		itemList,
		advertType = "shop-wechat",
		offset = 1,
		limit = 10;
	
	window.allNumber = 0;
	
	var appShelf = {
		firstLoad: false,
		canScroll: true,
		goodsCategoryId: '',
		portType:getEnvironment(),
		agencyId:medtap.getRequest('agencyId'),
		userId:medtap.getRequest('userShareId'),
		shareUrl:'',
		init:function(){
			/* 初始化页面控件 */
			$(".bottomBar").show();
			$(".shoppingCar").show();
			appShelf.shareUrl = medtap.getGlobalInterfacePath(appShelf.portType) + '/wechat/oauth_stepEnd?type=SUPER_MARKET';
			appShelf.getAuthPage();
			appShelf.initBanners();
			appShelf.initQueryGoods(1, 10, '');
		},
		initBanners:function(){
			medtap._ajax({
				url:'/operation/banner/listBanner',
				portType:appShelf.portType,
				type: 'get',
				async: true,
				dataType: 'json',
				data:{
					advertType: advertType,
				},
				success:function(res){
					if(res.success == true){
						var banners = res.content.bannerVOList;
						appShelf.initSwiper(banners);
					}else{}
				}
			})
		},
		initSwiper:function(banners){
			var _this = this,
				str = '<div class="swiper-wrapper banner-wrapper">';
			for (var i = 0, len = banners.length; i < len; i++) {
				var item = banners[i];
				str += '<div class="swiper-slide" style="height:2.8rem" tourl="' + item.bannerUrl +
					'" type="' + item.redirectType + '"><img src=' + item.bannerImg + '></div>';
			};
			str += '</div>';
			$('.banner').html(str);
			var mySwiper = new Swiper('.banner', {
				autoplay: 5000,
				autoplayDisableOnInteraction: false,
			});
			$('.banner-wrapper').on('click', '.swiper-slide', function() {
				var tourl = $(this).attr('tourl');
				var type = $(this).attr('type');
				if (type == 0) {
					return
				} else {
					if (tourl.indexOf('http') == 0) {
						medtap.pushNewWindow(tourl);
					} else {
						return
					}
				}
			});
		},
		/* 分享配置 */
		initShareShopPage:function(){
			medtap._ajax({
				url:'/wechat/fetchWechatTicket',
				type:'get',
				async:false,
				portType:appShelf.portType,
				data:{
					url: window.location.href
				},
				success:function(data){
					if(data.success == true){
						var res = data.content;
						wx.config({
							debug: false,
							appId: res.appId, // 必填,公众号的唯一标识
							timestamp: res.timestamp, // 必填,生成签名的时间戳
							nonceStr: res.nonceStr, // 必填,生成签名的随机串
							signature: res.signature, // 必填,签名,见附录1
							jsApiList: [
								'updateTimelineShareData',
								'updateAppMessageShareData'
							]
						})
					}
				},
				error: function() {}
			})
			wx.ready(function() {
				//分享给朋友
				wx.updateAppMessageShareData({
					title: '易加医抗癌超市-您的抗癌宝库',
					desc: '易加医抗癌超市众多商品火热促销中,不可错过,点击查看!', // 分享描述
					link: appShelf.shareUrl,
					imgUrl: 'https://cdn.iplusmed.com/static/images/entrance_upermarket.png', // 分享图标
					type: 'link', // 分享类型,music、video或link,不填默认为link
					dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
					success: function() {
						if (!(/iphone|ipad/gi).test(navigator.userAgent)) {}
					},
					cancel: function() {
						if (!(/iphone|ipad/gi).test(navigator.userAgent)) {}
					}
				});
				//分享到朋友圈
				wx.updateTimelineShareData({
					title: '易加医抗癌超市-您的抗癌宝库', // 分享标题
					link: appShelf.shareUrl,
					imgUrl: 'https://cdn.iplusmed.com/static/images/entrance_upermarket.png', // 分享图标
					success: function() {
						if (!(/iphone|ipad/gi).test(navigator.userAgent)) {}
					},
					cancel: function() {
						if (!(/iphone|ipad/gi).test(navigator.userAgent)) {}
					}
				});
			});
			window.shareShopPage = appShelf.initShareShopPage;
		},
		/* 获取分享人信息 */
		getUserShareInfo:function(){
			medtap._ajax({
				url:'/common/share/getSharerByToken',
				type:'post',
				portType:appShelf.portType,
				contentType: "application/json",
				data:{
					
				},
				success:function(res){
					if(res.success == true){
						if(res.content.clientType == 'USER'){
							var userId = res.content.clientId;
							appShelf.shareUrl += '&userShareId=' + userId;
						}else if(res.content.clientType == 'AGENCY'){
							var agencyId = res.content.clientId;
							appShelf.shareUrl +='&agencyId=' + agencyId
						}else{
							
						}
						appShelf.initShareShopPage();
					}else{
						appShelf.initShareShopPage();
					}
				}
			})
		},
		getAuthPage:function(){
			medtap._ajax({
				url:"/wechat/authPage/getByType",
				type:'get',
				portType:appShelf.portType,
				data:{
					type:'SUPER_MARKET'
				},
				success:function(res){
					var data = res.content.result;
					appShelf.shareUrl = data.authUrl;
					appShelf.getUserShareInfo();
					
				}
			})
		},
		/* 初始化商品列表 */
		initQueryGoods:function(offset,limit,goodsCategoryId){
			appShelf.offset = offset;
			appShelf.limit = limit;
			appShelf.goodsCategoryId = goodsCategoryId;
			medtap.jzz(1);
			medtap._ajax({
				url:'/shop/goods/listGoods',
				portType:appShelf.portType,
				type:'get',
				data:{
					offset: appShelf.offset,
					limit: appShelf.limit,
					goodsCategory: !!goodsCategoryId ? goodsCategoryId : '',
					isHot: !!goodsCategoryId ? '' : "1"
				},
				success:function(res){
					medtap.jzz(0)
					if(res.success == true){
						var list = res.content.goodsDetailVOList;
						getItems(list);
						if(list.length > 0){
							appShelf.canScroll = true;
						}else{
							appShelf.canScroll = false;
							medtap.winPop('没有更多数据了');
						}
						appShelf.offset++;
						appShelf.firstLoad = true;
					}else{
						
					}
				}
			});
			function getItems(list){
				var p = "";
				for (var i = 0, len = list.length; i < len; i++) {
					var item = list[i],
						productPrice = Number(item.realPrice), //售价
						originalPrice = Number(item.originalPrice), //原价
						vipPrice = Number(item.memberPrice); //会员价
					var isThird = item.isThird;
				
					if (isThird == true) {
						if (vipPrice != 0) {
							//有会员价
							if (vipPrice != productPrice) {
								//会员价不等于售价
								p += '<li listId=' + item.goodsDetailId + ' data-third=true>' +
									'<img class="picture" imgId=' + item.goodsDetailId + ' src= "' +
									item
									.coverImg + '"/>' +
									'<div id="addNone" amountUpperLimit="' + (item.amountUpperLimit ||
										'') +
									'" amountLowerLimit="' + (item.amountLowerLimit || '') + '" pid=' +
									item
									.goodsDetailId + '  pname=' + item.goodsName + '  price=' +
									productPrice +
									' pimageUrl=' + item.coverImg +
									' pnumber="1" select="true" isVirtual="' +
									item.virtual + '" isCrossBorder="' + item.crossBorder + '">' +
									'<div class="name">' + item.goodsName + '</div>' +
									'<div class="theprice">' +
									'<span class="price"><em>¥</em>' + productPrice +
									'</span></br><span class="vipPrice"><em>¥</em>' + vipPrice +
									'<span class="nor-txt">会员价</span></span>' +
									'</div>' +
									'</div>' +
									'</div>' +
									'</li>';
							} else {
								if (productPrice == originalPrice) {
									p += '<li listId=' + item.goodsDetailId + ' data-third=true>' +
										'<img class="picture" imgId=' + item.goodsDetailId + ' src= "' +
										item
										.coverImg + '"/>' +
										'<div id="addNone" amountUpperLimit="' + (item
											.amountUpperLimit || '') +
										'" amountLowerLimit="' + (item.amountLowerLimit || '') +
										'" pid=' + item
										.goodsDetailId + '  pname=' + item.goodsName + '  price=' +
										productPrice +
										' pimageUrl=' + item.coverImg +
										' pnumber="1" select="true" isVirtual="' +
										item.virtual + '" isCrossBorder="' + item.crossBorder + '">' +
										'<div class="name">' + item.goodsName + '</div>' +
										'<div class="theprice">' +
										'<span class="price"><em>¥</em>' + productPrice +
										'</span>' +
										'</div>' +
										'</div>' +
										'</div>' +
										'</li>';
								} else {
									p += '<li listId=' + item.goodsDetailId + ' data-third=true>' +
										'<img class="picture" imgId=' + item.goodsDetailId + ' src= "' +
										item
										.coverImg + '"/>' +
										'<div id="addNone" amountUpperLimit="' + (item
											.amountUpperLimit || '') +
										'" amountLowerLimit="' + (item.amountLowerLimit || '') +
										'" pid=' + item
										.goodsDetailId + '  pname=' + item.goodsName + '  price=' +
										productPrice +
										' pimageUrl=' + item.coverImg +
										' pnumber="1" select="true" isVirtual="' +
										item.virtual + '" isCrossBorder="' + item.crossBorder + '">' +
										'<div class="name">' + item.goodsName + '</div>' +
										'<div class="theprice">' +
										'<span class="price"><em>¥</em>' + productPrice +
										'</span></br><span class="orginPrice"><em>¥</em>' +
										originalPrice + '</span>' +
										'</div>' +
										'</div>' +
										'</div>' +
										'</li>';
								}
							}
						} else {
							if (productPrice == originalPrice) {
								p += '<li listId=' + item.goodsDetailId + ' data-third=true>' +
									'<img class="picture" imgId=' + item.goodsDetailId + ' src= "' +
									item
									.coverImg + '"/>' +
									'<div id="addNone" amountUpperLimit="' + (item.amountUpperLimit ||
										'') +
									'" amountLowerLimit="' + (item.amountLowerLimit || '') + '" pid=' +
									item
									.goodsDetailId + '  pname=' + item.goodsName + '  price=' +
									productPrice +
									' pimageUrl=' + item.coverImg +
									' pnumber="1" select="true" isVirtual="' +
									item.virtual + '" isCrossBorder="' + item.crossBorder + '">' +
									'<div class="name">' + item.goodsName + '</div>' +
									'<div class="theprice">' +
									'<span class="price"><em>¥</em>' + productPrice +
									'</span>' +
									'</div>' +
									'</div>' +
									'</div>' +
									'</li>';
							} else {
								p += '<li listId=' + item.goodsDetailId + ' data-third=true>' +
									'<img class="picture" imgId=' + item.goodsDetailId + ' src= "' +
									item
									.coverImg + '"/>' +
									'<div id="addNone" amountUpperLimit="' + (item.amountUpperLimit ||
										'') +
									'" amountLowerLimit="' + (item.amountLowerLimit || '') + '" pid=' +
									item
									.goodsDetailId + '  pname=' + item.goodsName + '  price=' +
									productPrice +
									' pimageUrl=' + item.coverImg +
									' pnumber="1" select="true" isVirtual="' +
									item.virtual + '" isCrossBorder="' + item.crossBorder + '">' +
									'<div class="name">' + item.goodsName + '</div>' +
									'<div class="theprice">' +
									'<span class="price"><em>¥</em>' + productPrice +
									'</span></br><span class="orginPrice"><em>¥</em>' + originalPrice +
									'</span>' +
									'</div>' +
									'</div>' +
									'</div>' +
									'</li>';
							}
						}
				
					} else {
						if (vipPrice != 0) {
							//有会员价
							if (vipPrice != productPrice) {
								//会员价不等于售价
								p += '<li listId=' + item.goodsDetailId + ' data-third=false>' +
									'<img class="picture" imgId=' + item.goodsDetailId + ' src= "' +
									item
									.coverImg + '"/>' +
									'<div id="add" amountUpperLimit="' + (item.amountUpperLimit || '') +
									'" amountLowerLimit="' + (item.amountLowerLimit || '') + '" pid=' +
									item
									.goodsDetailId + '  pname=' + item.goodsName + '  price=' +
									productPrice + ' pimageUrl=' + item.coverImg +
									' pnumber="1" select="true" isVirtual="' + item.virtual +
									'" isCrossBorder="' + item.crossBorder + '">' +
									'<div class="name">' + item.goodsName + '</div>' +
									'<div class="theprice">' +
									'<span class="price"><em>¥</em>' + productPrice +
									'</span><br/><span class="vipPrice"><em>¥</em>' + vipPrice +
									'<span class="nor-txt">会员价</span></span>' +
									'<div class="addBtn" pid=' + item.goodsDetailId + '  pname=' + item
									.goodsName + '  price=' + productPrice + ' pimageUrl=' + item
									.coverImg +
									' pnumber="1" select="true">' +
									'</div>' +
									'</div>' +
									'</div>' +
									'</li>';
							} else {
								//会员价等于售价
								if (productPrice == originalPrice) {
									//售价等于原价
									p += '<li listId=' + item.goodsDetailId + ' data-third=false>' +
										'<img class="picture" imgId=' + item.goodsDetailId + ' src= "' +
										item
										.coverImg + '"/>' +
										'<div id="add" amountUpperLimit="' + (item.amountUpperLimit ||
											'') +
										'" amountLowerLimit="' + (item.amountLowerLimit || '') +
										'" pid=' + item
										.goodsDetailId + '  pname=' + item.goodsName + '  price=' +
										productPrice + ' pimageUrl=' + item.coverImg +
										' pnumber="1" select="true" isVirtual="' + item.virtual +
										'" isCrossBorder="' + item.crossBorder + '">' +
										'<div class="name">' + item.goodsName + '</div>' +
										'<div class="theprice">' +
										'<span class="price"><em>¥</em>' + productPrice +
										'</span>' +
										'<div class="addBtn" pid=' + item.goodsDetailId + '  pname=' +
										item
										.goodsName + '  price=' + productPrice + ' pimageUrl=' + item
										.coverImg +
										' pnumber="1" select="true">' +
										'</div>' +
										'</div>' +
										'</div>' +
										'</li>';
								} else {
									p += '<li listId=' + item.goodsDetailId + ' data-third=false>' +
										'<img class="picture" imgId=' + item.goodsDetailId + ' src= "' +
										item
										.coverImg + '"/>' +
										'<div id="add" amountUpperLimit="' + (item.amountUpperLimit ||
											'') +
										'" amountLowerLimit="' + (item.amountLowerLimit || '') +
										'" pid=' + item
										.goodsDetailId + '  pname=' + item.goodsName + '  price=' +
										productPrice + ' pimageUrl=' + item.coverImg +
										' pnumber="1" select="true" isVirtual="' + item.virtual +
										'" isCrossBorder="' + item.crossBorder + '">' +
										'<div class="name">' + item.goodsName + '</div>' +
										'<div class="theprice">' +
										'<span class="price"><em>¥</em>' + productPrice +
										'</span></br><span class="orginPrice"><em>¥</em>' +
										originalPrice +
										'</span>' +
										'<div class="addBtn" pid=' + item.goodsDetailId + '  pname=' +
										item
										.goodsName + '  price=' + productPrice + ' pimageUrl=' + item
										.coverImg +
										' pnumber="1" select="true">' +
										'</div>' +
										'</div>' +
										'</div>' +
										'</li>';
								}
							}
						} else {
							//无会员价
							if (productPrice == originalPrice) {
								p += '<li listId=' + item.goodsDetailId + ' data-third=false>' +
									'<img class="picture" imgId=' + item.goodsDetailId + ' src= "' +
									item
									.coverImg + '"/>' +
									'<div id="add" amountUpperLimit="' + (item.amountUpperLimit || '') +
									'" amountLowerLimit="' + (item.amountLowerLimit || '') + '" pid=' +
									item
									.goodsDetailId + '  pname=' + item.goodsName + '  price=' +
									productPrice + ' pimageUrl=' + item.coverImg +
									' pnumber="1" select="true" isVirtual="' + item.virtual +
									'" isCrossBorder="' + item.crossBorder + '">' +
									'<div class="name">' + item.goodsName + '</div>' +
									'<div class="theprice">' +
									'<span class="price"><em>¥</em>' + productPrice +
									'</span>' +
									'<div class="addBtn" pid=' + item.goodsDetailId + '  pname=' + item
									.goodsName + '  price=' + productPrice + ' pimageUrl=' + item
									.coverImg +
									' pnumber="1" select="true">' +
									'</div>' +
									'</div>' +
									'</div>' +
									'</li>';
							} else {
								p += '<li listId=' + item.goodsDetailId + ' data-third=false>' +
									'<img class="picture" imgId=' + item.goodsDetailId + ' src= "' +
									item
									.coverImg + '"/>' +
									'<div id="add" amountUpperLimit="' + (item.amountUpperLimit || '') +
									'" amountLowerLimit="' + (item.amountLowerLimit || '') + '" pid=' +
									item
									.goodsDetailId + '  pname=' + item.goodsName + '  price=' +
									productPrice + ' pimageUrl=' + item.coverImg +
									' pnumber="1" select="true" isVirtual="' + item.virtual +
									'" isCrossBorder="' + item.crossBorder + '">' +
									'<div class="name">' + item.goodsName + '</div>' +
									'<div class="theprice">' +
									'<span class="price"><em>¥</em>' + productPrice +
									'</span></br><span class="orginPrice"><em>¥</em>' + originalPrice +
									'</span>' +
									'<div class="addBtn" pid=' + item.goodsDetailId + '  pname=' + item
									.goodsName + '  price=' + productPrice + ' pimageUrl=' + item
									.coverImg +
									' pnumber="1" select="true">' +
									'</div>' +
									'</div>' +
									'</div>' +
									'</li>';
							}
						}
					}
				}
				if (appShelf.offset == 1) {
					$(".productList").html(p);
				} else {
					$(".productList").append(p);
				}
				$('.addBtn').html($('#home_list_shopping').html());
			}
			window.queryGoods = appShelf.initQueryGoods;
		},
		bind:function(){
			//商品添加到购物车功能
			$('.productList').on("click", "#add", function() {
				var pid = $(this).attr("pid"),
					pname = $(this).attr("pname"),
					price = $(this).attr("price"),
					pimageUrl = $(this).attr("pimageUrl"),
					pnumber = $(this).attr("pnumber"),
					selectHas = $(this).attr("select"),
					isVirtual = $(this).attr("isVirtual"),
					isCrossBorder = $(this).attr("isCrossBorder"),
					amountLowerLimit = $(this).attr("amountLowerLimit") || 0,
					amountUpperLimit = $(this).attr("amountUpperLimit") || 999,
					json_product = {};
				shopJson_products = JSON.parse(localStorage.shopJson_products);
				amountLowerLimit = Number(amountLowerLimit);
				amountUpperLimit = Number(amountUpperLimit);
				var isHas = false;
				//此次要购物车 和商品 要新增的数量,默认为0
				var newNumber = 0;
				//数量添加
				for (var i = 0; i < shopJson_products.length; i++) {
					//商品存在的话判断商品的上下限, 
					//如果商品存在,且存在数量上限,则商品数目加1,否则 数量不增加
					//如果商品存在,但不存在商品数量上限,则数量加1
					if (shopJson_products[i].pid == pid) {
						var nowNumber = shopJson_products[i].pnumber;
						if (amountUpperLimit > nowNumber) {
							newNumber = 1;
						} else {
							newNumber = 0;
						}
						shopJson_products[i].pnumber = nowNumber + newNumber;
						$('.shoppingNum').text(window.allNumber + newNumber);
						localStorage.shopJson_products = JSON.stringify(shopJson_products);
						isHas = true;
					}
				}
				//商品不存在时,添加新商品, 
				//如果商品最少购买数目大于1,则此次新增数目为商品下限,
				if (!isHas) {
					json_product.pid = pid;
					json_product.pname = pname;
					json_product.price = price;
					json_product.pimageUrl = pimageUrl;
					if (amountLowerLimit > 1) {
						newNumber = amountLowerLimit;
					} else {
						newNumber = 1;
					}
					json_product.pnumber = newNumber;
					json_product.selectHas = selectHas;
					json_product.isVirtual = isVirtual;
					json_product.isCrossBorder = isCrossBorder;
					json_product.amountLowerLimit = amountLowerLimit;
					shopJson_products.push(json_product);
					localStorage.shopJson_products = JSON.stringify(shopJson_products);
					$('.shoppingNum').text(Number(window.allNumber) + newNumber);
					$('.shoppingNum').show();
				}
				window.allNumber = Number(window.allNumber) + Number(newNumber);
				if (newNumber <= 0) {
					medtap.pop('不能购买更多了哟~');
					return;
				}
				//商品添加到购物车动画
				$(".yuan").css({
					"transform": "translate3d(0,0rem,0)",
					"-webkit-transform": "translate3d(0,0rem,0)",
					"transition": "all 0.4s ease-in-out",
					"-webkit-transition": "all 0.4s ease-in-out",
					"opacity": "1"
				});
				setTimeout(function() {
					$(".yuan").css({
						"transform": "translate3d(0,-1.8rem,0)",
						"-webkit-transform": "translate3d(0,-1.8rem,0)",
						"transition": "all 0s ease-in-out",
						"-webkit-transition": "all 0s ease-in-out",
						"opacity": "0"
					});
				}, 400);
				var list = [];
				for (var i = 0, len = shopJson_products.length; i < len; i++) {
					var obj = {},
						item = shopJson_products[i];
					obj.amount = item.pnumber;
					obj.goodsId = item.pid;
					list.push(obj);
				}
				saveCart(list);
				function saveCart(list) {
					medtap.jzz(1);
					medtap._ajax({
						url: '/shop/cart/saveCart',
						type: 'post',
						async: true,
						contentType: "application/json",
						portType:appShelf.portType,
						data: {
							goods:list
						},
						success: function(data) {
							medtap.jzz(0);
							if (data.success) {
								//保存新的购物车信息到数据库
							} else {
								medtap.winPop(data.resultDesc);
							}
						},
						error: function(err) {
						}
					});
				}
			});
			/* 进入商品详情页 */
			$('.productList').on("click", ".picture", function() {
				var isThird = $(this).parent().attr('data-third');
				var imgId = $(this).attr("imgId");
				if (isThird == 'true') {
					medtap.pushNewWindow('productDetailForThird.html?goodsId=' +imgId + "&agencyId=" + appShelf.agencyId +'&userShareId=' + appShelf.userId);
				} else {
					medtap.pushNewWindow('productDetails.html?goodsId=' + imgId + "&agencyId=" + appShelf.agencyId + '&userShareId=' + appShelf.userId);
				}
			});
			/* 进入订单列表页 */
			$('.orderIconoff').on('click',function(){
				medtap.pushNewWindow('newOrderlist.html?agencyId=' + appShelf.agencyId+ '&userShareId=' + appShelf.userId);
			});
			$('#end').on('click',function(){
				medtap.pushNewWindow('shopCart.html?agencyId=' + appShelf.agencyId + '&userShareId=' + appShelf.userId);
			});
		},
		initScroll: function() {
			$(window).scroll(function() {
				if ($(document).height() - $(this).scrollTop() - $(this).height() < 60) {
					if (appShelf.firstLoad == false) {
						return;
					}
					if (appShelf.canScroll == true) {
						appShelf.canScroll = false;
						queryGoods(appShelf.offset, appShelf.limit, appShelf.goodsCategoryId);
					}
				}
			})
		}
	};
	appShelf.init();
	appShelf.bind();
	appShelf.initScroll();
	
})