var data = ''; var data_saleSpec = {} var arry_str = ''; var data_bak = {}; var shopQQ = ''; var shopTle = ''; var shopName=''; var isDefaultArr = []; var token = localStorage.getItem('token'); var isShowWhsle = 0; var seckilling_end_time = '' var shareImgThumbs = []; var shares = null; var img_data=''; var Intent = null, File = null, Uri = null, main = null; //点击遮罩关闭 $('.cclass_con').before('
') $('.header_con').append('桔子抢购
距结束还剩
'; $('.miaosha').html(html_miaosha); $('.cclass_con .cc2 p').html(data_s.specPrice); $('.miaosha').css('display', 'block'); $('.price').css('display', 'none'); $('.price_old').css('display', 'none'); countTime(); $('.mujidikou').css('display', 'none'); } } } // H5 plus事件处理 function plusReady() { updateSerivces(); if(plus.os.name == "Android") { main = plus.android.runtimeMainActivity(); Intent = plus.android.importClass("android.content.Intent"); File = plus.android.importClass("java.io.File"); Uri = plus.android.importClass("android.net.Uri"); } } if(window.plus) { plusReady(); } else { document.addEventListener("plusready", plusReady, false); } /** * * 更新分享服务 */ function updateSerivces() { plus.share.getServices(function(s) { shares = {}; for(var i in s) { var t = s[i]; shares[t.id] = t; } }, function(e) { plus.nativeUI.toast("获取分享服务列表失败:" + e.message); }); } /** * 分享操作 * @param {JSON} sb 分享操作对象s.s为分享通道对象(plus.share.ShareService) * @param {Boolean} bh 是否分享链接 */ function shareAction(sb, bh) { if(!sb || !sb.s) { plus.nativeUI.toast("无效的分享服务!"); return; } var msg = { content: sharehrefDes.value, extra: { scene: sb.x }, type: "web" }; if(bh) { msg.href = sharehref.value; if(sharehrefTitle && sharehrefTitle.value != "") { msg.title = sharehrefTitle.value; } if(sharehrefDes && sharehrefDes.value != "") { msg.content = sharehrefDes.value; } // msg.thumbs = ["_www/logo.png"]; msg.thumbs = $('.swiper-slide img').eq(0).attr('src') ? [$('.swiper-slide img').eq(0).attr('src') + '/thumb60'] : ["_www/logo.png"]; msg.pictures = ["_www/logo.png"]; } else { if(pic && pic.realUrl) { msg.pictures = [pic.realUrl]; } } // 发送分享 if(sb.s.authenticated) { // plus.nativeUI.toast("---已授权---"); shareMessage(msg, sb.s); } else { plus.nativeUI.toast("---未授权---"); sb.s.authorize(function() { shareMessage(msg, sb.s); }, function(e) { plus.nativeUI.toast("认证授权失败:" + e.code + " - " + e.message); }); } } /** * 发送分享消息 * @param {JSON} msg * @param {plus.share.ShareService} s */ function shareMessage(msg, s) { // plus.nativeUI.toast(JSON.stringify(msg)); s.send(msg, function() { plus.nativeUI.toast("分享到\"" + s.description + "\"成功! "); }, function(e) { plus.nativeUI.toast("分享到\"" + s.description + "\"失败 "); }); } // 分析链接 function shareHref() { var shareBts = []; // 更新分享列表 var ss = shares['weixin']; ss && ss.nativeClient && (shareBts.push({ title: '微信朋友圈', s: ss, x: 'WXSceneTimeline' }), shareBts.push({ title: '微信好友', s: ss, x: 'WXSceneSession' })); // 弹出分享列表 shareBts.length > 0 ? plus.nativeUI.actionSheet({ title: '分享注册链接', cancel: '取消', buttons: shareBts }, function(e) { (e.index > 0) && shareAction(shareBts[e.index - 1], true); }) : plus.nativeUI.plus.nativeUI.toast('当前环境无法支持分享链接操作!'); } function whslePrice(num, arry_str) { for(var i in data_saleSpec) { if(i == arry_str) { // if(num >= (+(data_saleSpec[i].initNum)) && data_saleSpec[i].whslePrice > 0) { if(isShowWhsle == 1 && data_saleSpec[i].whslePrice > 0) { $('.cclass_con .cc2 o').html('批发单价:¥' + data_saleSpec[i].whslePrice); $('.cclass_con .cc2 l').html('起批数:' + data_saleSpec[i].initNum + '件'); } } } for(var i in data_saleSpec) { if(i == arry_str) { $('.cclass_con .cc2 p').html('¥' + data_saleSpec[i].specPrice); } } } mui.plusReady(function() { var self = plus.webview.currentWebview(); var goodsType; if (self.goodsType) { goodsType=self.goodsType; } var goodsId = self.data_id; var isEct = self.isEct; var isMiaosha = self.isMiaosha; var MiaoshaSaleSpec = self.MiaoshaSaleSpec; var specsId = ''; from_id = self.from_id?self.from_id:0 // //console.log(isMiaosha) // isMiaosha = 1; // MiaoshaSaleSpec = '0'; // console.log(goodsId) // mui.ajax(hyhUrl('app/Goods/detail'), { mui.ajax(qlgUrl('app/Goods/detail'), { data: { goodsId: goodsId // goodsId: 1206 // goodsId: 1203 }, dataType: 'json', //服务器返回json格式数据 type: 'post', //HTTP请求类型 timeout: 10000, //超时时间设置为10秒; success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功; // console.log(data) var data = toJson(data); // console.log(data.status) if(data.status == 1) { // mui.alert('加载失败请重试!'); data = data.data; data_bak = data; shopQQ = data.shop.shopQQ; shopTel = data.shop.phone; var isEct = data.isEct; shopName = data.shop.shopName; // if(!shopQQ && shopTel) { $('#lxkf').html('客服
') // } if(1 == data.isFavorites){ $('#scbtn img').attr('src','../img/likelogo1.png') $('#scbtn p').html("已收藏") } var html = '市场价 ¥' + data.marketPrice + '
¥' + data.shopPrice + '
市场价 ¥' + data.marketPrice + '
' + data.goodsTips + '
'; } if(data.isFreeShipping == '1') { html += '商品评价(' + data.appraiseNum + ')
' + data.oneAppraises.loginName + '
' + data.shop.shopName + '
' + this.name + '
' $.each(this.list, function() { // //console.log(this.itemId) html1 += '¥' + this.couponValue + '
满' + this.useMoney + '元使用桔子抢购
距结束还剩
'; $('.miaosha').html(html_miaosha); $('.miaosha').css('display', 'block'); $('.price').css('display', 'none'); $('.price_old').css('display', 'none'); countTime(); } else if(data_saleSpec[arry_str] && data_saleSpec[arry_str].is_seckilling && data_saleSpec[arry_str].is_seckilling == 1) { miaoshaSaleSpec(data_saleSpec[arry_str].id, data_saleSpec); } else if(isMiaosha == 1) { miaoshaSaleSpec(MiaoshaSaleSpec, data_saleSpec); } // } else { $.each(isDefaultArr, function() { var that = this; $('.cclass1 .block').each(function() { if($(this).attr('data-itemId') == that) { $(this).addClass('on'); $(this).parent().attr('data-class', that); } }) }) } } else if(data.status == -22) { alert(data.msg); mui.back(); } }, error: function(xhr, type, errorThrown) { //异常处理; //console.log(errorThrown); } }); var scroll = mui('.mui-scroll-wrapper').scroll({ //flick 减速系数,系数越大,滚动速度越慢,滚动距离越小,默认值0.0006 deceleration: 0.002 }); var show_img=false; //导航栏渐变 document.querySelector('.mui-scroll-wrapper').addEventListener('scroll', function(e) { var num; if(scroll.y >= -387 && scroll.y < 0) { num = scroll.y / -387; // //console.log('渐变',num) $('.header1').css({ 'display': 'block', 'opacity': num }) if(false == show_img){ show_img=true; $('.imgcon').html(img_data); } var num1 = 0.2 - num * 0.2; } else if(scroll.y >= 0) { num = 0; // //console.log('透明',num) $('.header1').css({ 'display': 'none', 'opacity': num }) } else if(scroll.y < -387) { num = 1; // //console.log('不透明',num) $('.header1').css({ 'display': 'block', 'opacity': num }) } //导航栏自动切换 if($('.imgcon').offset().top >= 66) { $('#nav1').addClass("on").siblings().removeClass('on'); } else if($('.imgcon').offset().top < 66) { $('#nav3').addClass("on").siblings().removeClass('on'); } }) mui('.header').on('tap', '.icon-cart', function() { JZL.openWindow('shoppingcart.html','shoppingcart.html'); }); //点击导航栏跳转 mui('.nav').on('tap', '#nav1', function() { mui('.mui-scroll-wrapper').scroll().scrollTo(0, 0, 100); $('#nav1').addClass("on").siblings().removeClass('on'); }); mui('.nav').on('tap', '#nav2', function() { JZL.openWindow('appraise.html','appraise.html',{goodsId: goodsId}); }); mui('.nav').on('tap', '#nav3', function() { mui('.mui-scroll-wrapper').scroll().scrollTo(0, -1124, 100); $('#nav3').addClass("on").siblings().removeClass('on'); }); mui('.con_').on('tap', '#changeclass', function() { $('#changeclass_con').show(); }) //选择类型 mui('.ccclass').on('tap', '.block', function() { $(this).addClass('on').siblings().removeClass('on'); $(this).parent().attr('data-class', $(this).attr('data-itemId')); var data_itemId = $(this).attr('data-itemId'); if($(this).attr('data-itemImg') != '') { $('.cclass_con .img').html('