標籤:

活動頁

活動頁

$(function() { var tarr = []; var numberShop = 0; //獲取購物車的數量 $.ajax({ type: "post", url: commonsUrl + /api/gxsc/get/goods/car/commodity/info + versioninfos, data: { "ss": getCookie(openid) }, success: function(data) { if(data.code == 1) { //請求成功 console.log(data); var arr = data.result.info; $.each(arr, function(k, v) { $.each(v.goods_list, function(key, value) { //console.log(value.number); numberShop += parseInt(value.number) }) }) console.log(numberShop + iiiiiii) $(.shopCar span).html(numberShop); } else { layer.msg(data.msg); } } }); //獲取新發布的商品 $.ajax({ type: "post", dataType: json, url: commonsUrl + api/gxsc/get/new/commodity/class + versioninfos, data: { "flag": 1, //返利區 "page": 1 //請求參數 openid }, success: function(data) { console.log(data) if(data.code == 1) { //請求成功 var con = data.result; if(con.length != 0) { console.log(con); var html = ; $.each(con, function(k, v) { var goods_id = con[k].goods_id; //商品id var goods_name = con[k].goods_name; //商品名稱 var images = con[k].image; //商品圖片 var price = con[k].price; //商品價格 var num = con[k].num; //庫存 var time = con[k].time; //商品上架時間 var sales = con[k].sales; //商品銷量 console.log(goods_id); html += <div class="shopBox" goods_id= + goods_id + onclick="goDetail( + goods_id + )"> + <div class="shopImg"><img src= + images + /></div> + <div class="shopName"> + goods_name + </div> + <div class="shopMessage"> + <div class="shops"> + <span class="shopPrice">¥ + price + </span> + <span class="fan"></span> + </div> + <div class="toBuy">立即搶購</div> + </div> + </div> }); $(.shop_Box).append(html); //動態顯示商品列表 } else { $(.newBox).hide(); } } else { layer.msg(data.msg); } } }); //banner圖輪播 $.ajax({ type: "post", dataType: json, url: commonsUrl + api/gxsc/get/banner/list + versioninfos, success: function(data) { console.log(data) if(data.code == 1) { //請求成功 var con = data.result; // var sort = con.sort; //排序 //---------------循環圖片(輪播圖)----- $.each(con, function(k, v) { var src = con[k].img_url; //圖片地址 var imgId = con[k].id; //圖片id var sort = con[k].sort; //排序 var imgUrl = con[k].url; //商品id console.log(imgUrl); var t = "<div class=swiper-slide><a href=javascript:void(0) imgId="+imgId+" onclick=goDetails(" + imgId + ") imgurl=" + imgUrl + " class=atts> <img src=" + src + " imgUrl=" + imgUrl + " /></a></div>"; $(.swiper-wrapper).append(t); }); } //swiper插件實現輪播圖 var mySwiper = new Swiper(.swiper-container, { autoplay: 5000, //可選選項,自動滑動 loop: true, pagination: .swiper-pagination, }); } }); //-----------搜索---------- $(function() { $(".searchSub").click(function() { var shopName = $(".insearch").val(); console.log(shopName); if(shopName == "" || shopName == undefined) { layer.msg("商品名稱不能為空"); } else { location.href = "searchShopList.php?vid=1&shopName=" + shopName; } }) }) $(".atts").click(function(){ var ss=$(this).attr("imgUrl"); console.log(ss); })});function goDetails(imgId) { var imgUrl=$(this).attr("imgurl"); console.log(imgUrl+"ooooo"); console.log(imgId); if(imgUrl == || imgUrl == undefined || imgUrl == null) { console.log("imgId是空的,不跳轉到列表頁"); } else { //location.href="promotion.php?imgId="+imgId// }}function goDetail(goods_id) { // console.log(goods_id); location.href = "shopDetails.php?goods_id=" + goods_id;};function waitting() { layer.msg(暫未開通,敬請期待哦!)};

推薦閱讀:

科技公司為何使用人類幫助人工智慧?
計算機建模是下一個科技浪潮的風口浪尖!
WebSocket 和HTTP的區別及原理
10個已滅絕動物的生前錄像
微軟宣布10月2日舉辦硬體新品發布會

TAG:科技 |