You've already forked qlg.tsgz.moe
Init Repo
This commit is contained in:
874
static/app2/js/details.js
Executable file
874
static/app2/js/details.js
Executable file
@ -0,0 +1,874 @@
|
||||
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('<div class="mask" style="height:100%"></div>')
|
||||
$('.header_con').append('<a class="icon-cart"><img style="width:1.7rem;" src="'+ectImgUrl('static/app2/img/icon_cart.png')+'"</a>');
|
||||
function getNextDate(dayStr) {
|
||||
var dd = new Date(dayStr);
|
||||
dd.setDate(dd.getDate() + 1);
|
||||
var y = dd.getFullYear();
|
||||
var m = dd.getMonth() + 1; //获取当前月份的日期
|
||||
var d = dd.getDate();
|
||||
return y + "/" + m + "/" + d + " 00:00:00";
|
||||
};
|
||||
//倒计时
|
||||
function countTime() {
|
||||
|
||||
//获取当前时间
|
||||
var date = new Date();
|
||||
var now = date.getTime();
|
||||
//设置截止时间
|
||||
var endDate = new Date(getNextDate(seckilling_end_time * 1000));
|
||||
var end = endDate.getTime();
|
||||
//时间差
|
||||
var leftTime = seckilling_end_time * 1000 - now;
|
||||
//定义变量 d,h,m,s保存倒计时的时间
|
||||
var d, h, m, s;
|
||||
if(leftTime >= 0) {
|
||||
d = Math.floor(leftTime / 1000 / 60 / 60 / 24);
|
||||
h = Math.floor(leftTime / 1000 / 60 / 60);
|
||||
m = Math.floor(leftTime / 1000 / 60 % 60);
|
||||
s = Math.floor(leftTime / 1000 % 60);
|
||||
//将倒计时赋值到div中
|
||||
if(d < 10) {
|
||||
d = "0" + d;
|
||||
}
|
||||
if(h < 10) {
|
||||
h = "0" + h;
|
||||
}
|
||||
if(m < 10) {
|
||||
m = "0" + m;
|
||||
}
|
||||
if(s < 10) {
|
||||
s = "0" + s;
|
||||
}
|
||||
// $("#_d").html(d);
|
||||
$("#_h").html(h);
|
||||
$("#_m").html(m);
|
||||
$("#_s").html(s);
|
||||
}
|
||||
|
||||
//递归每秒调用countTime方法,显示动态时间效果
|
||||
setTimeout(countTime, 1000);
|
||||
|
||||
}
|
||||
|
||||
//秒杀限购四件
|
||||
var xg = '';
|
||||
$('.miaosha').append(xg);
|
||||
//秒杀规格选择
|
||||
function miaoshaSaleSpec(specId, SaleSpec) {
|
||||
for(i in SaleSpec) {
|
||||
if(SaleSpec[i].id == specId) {
|
||||
var data_sArry = i.split(':');
|
||||
var data_s = SaleSpec[i];
|
||||
arry_str = i;
|
||||
isDefaultArr = i.split(':');
|
||||
$.each(data_sArry, function() {
|
||||
var that = this;
|
||||
$('.cclass1 .block').each(function() {
|
||||
if($(this).attr('data-itemId') == that) {
|
||||
$(this).addClass('on');
|
||||
$(this).parent().attr('data-class', that);
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
seckilling_end_time = data_s.seckilling_end_time;
|
||||
html_miaosha = '<img src="../img/bg_miaosha.png"/><p class="miaosha1"><o>¥</o>' + data_s.specPrice + '</p><del class="miaosha2">¥' + data_s.marketPrice + '</del><div class="xiangou">限购四件</div><p class="miaosha3"><o id="_h">00</o>:<o id="_m">00</o>:<o id="_s">00</o></p><p class="miaosha4">桔子抢购</p><p class="miaosha5">距结束还剩</p>';
|
||||
$('.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 = '';
|
||||
// //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('<a href="tel:' + shopTel + '"><img src="../img/haitunlogo.png" /><p>客服</p></a>')
|
||||
// }
|
||||
if(1 == data.isFavorites){
|
||||
$('#scbtn img').attr('src','../img/likelogo1.png')
|
||||
$('#scbtn p').html("已收藏")
|
||||
}
|
||||
var html = '<div class="none" style="display: none;"><p>链接地址:</p><input id="sharehref" type="url" value="' + data.goods_url + '" /><p>链接标题:</p><input id="sharehrefTitle" type="text" value="' + data.goodsName + '" /><p>链接描述:</p><input id="sharehrefDes" type="text" value="' + data.goodsTips + '" /></br></div><div class="banner"><div class="swiper-container"><div class="swiper-wrapper">';
|
||||
var html2 = '';
|
||||
$.each(data.gallery, function() {
|
||||
html += '<div class="swiper-slide"><img src="' + hyhImgUrl(this) + '" /></div>';
|
||||
});
|
||||
|
||||
if(isEct == 1) {
|
||||
html += '</div></div></div><div class="con"><div class="summarize shadown_wai"><div class="miaosha" style="display:none;"></div><p class="price xxl"><o>ECT专享价</o>¥' + data.shopPrice + '</p><p class="price_old">市场价 <del>¥' + data.marketPrice + '</del></p>';
|
||||
} else {
|
||||
html += '</div></div></div><div class="con"><div class="summarize shadown_wai"><div class="miaosha" style="display:none;"></div><p class="price">¥' + data.shopPrice + '</p><p class="price_old">市场价 <del>¥' + data.marketPrice + '</del></p>';
|
||||
}
|
||||
|
||||
// var str1 = '<p class="price"><o>到手价</o>¥' + Math.round(data.shopPrice * 0.8 * 100) / 100 + '</p>'
|
||||
|
||||
html += '<p class="cname" id="shareout" style="color:black;font-size:16px"><o> ' + data.goodsName + '</o><img id="share" src="../img/share.png"/></p>';
|
||||
if(data.goodsTips) {
|
||||
html += '<p class="cname">' + data.goodsTips + '</p>';
|
||||
}
|
||||
if(data.isFreeShipping == '1') {
|
||||
html += '<div class="compilations"><span class="myf">免运费';
|
||||
} else {
|
||||
//html += '<div class="compilations"><span class="myf">不包邮';
|
||||
html += '<div class="compilations"><span class="myf">运费'+data.freight;
|
||||
}
|
||||
html += '</span><span class="yx">月销:' + data.saleNum + '件</span><span class="dz"></span></div>'
|
||||
|
||||
html += '</div><div class="guarantee shadown_wai"><div class="row clearfix yyyhhhqqq"><img src="../img/gouwuquan.png" /><span class="text">领取优惠券</span><button class="lq">领取</button></div>';//<div class="row clearfix"><span class="text1">木吉</span><span class="text">购买后可获得成交价格20%木吉</span></div>
|
||||
if(isEct != 1) {
|
||||
//html += '<div class="row clearfix mujidikou"><span class="text1">木吉</span><span class="text">本商品可用木吉抵扣20%</span></div>'
|
||||
} else {}
|
||||
if(data.promotionList != '') {
|
||||
// html += '<div class="mui-table-view-cell mui-collapse row_"><a class="mui-navigate-right" href="#">促销信息 :' + data.promotionList.rewardTitle + '</a><div class="mui-collapse-content" style="width:100%">';
|
||||
// $.each(data.promotionList.json, function() {
|
||||
// html += '<h4>满' + this.orderMoney + '元</h4>';
|
||||
//
|
||||
// if(this.favourableJson.chk0 == true) {
|
||||
// html += '<h5>减' + this.favourableJson.chk0val + '元</h5>';
|
||||
// }
|
||||
// if(this.favourableJson.chk1 == true) {
|
||||
// html += '<h5>送' + this.favourableJson.chk1val.text + '</h5>';
|
||||
// }
|
||||
// if(this.favourableJson.chk2 == true) {
|
||||
// html += '<h5>免运费</h5>';
|
||||
// }
|
||||
// if(this.favourableJson.chk3 == true) {
|
||||
// html += '<h5>送满' + this.favourableJson.chk3val.text + '元优惠券 满' + this.favourableJson.chk3val.data.useMoney + '元使用</h5>';
|
||||
// }
|
||||
//
|
||||
// });
|
||||
//
|
||||
// html += '</div></div>';
|
||||
}
|
||||
var showShopMsg = '<span class="text">正品保证 </span>';
|
||||
// if(1778 == data.shopId){
|
||||
// showShopMsg+='<span class="text">此商品拆封概不退货换</span>';
|
||||
// showShopMsg+='<span class="text">温馨提示:不支持7天无理由退货</span>';
|
||||
//
|
||||
// }
|
||||
html += '<div class="row clearfix">'+showShopMsg+'<button class="caidan" style="display:none"><img src="../img/menu.png"/></button></div></div><div class="guarantee shadown_wai" id="guarantee"><div class="row clearfix" id="changeclass"><span class="text">选择颜色分类 号码尺寸</span><button class="caidan"><img src="../img/menu.png"/></button></div></div>';
|
||||
if(data.oneAppraises == '') {
|
||||
|
||||
} else {
|
||||
var userImg = '';
|
||||
if(data.oneAppraises.userPhoto) {
|
||||
userImg = hyhImgUrl(data.oneAppraises.userPhoto);
|
||||
} else {
|
||||
userImg = '../img/mujiimg.png'
|
||||
}
|
||||
|
||||
html += '<div class="pjrk shadown_wai" style="display:block"><p class="pj_title">商品评价(' + data.appraiseNum + ')</p><div class="pj_breviary"><div class="pjbtitle clearfix"><img src="' + userImg + '" /><p>' + data.oneAppraises.loginName + '</p></div><div class="pjbcon">' + data.oneAppraises.content + '</div><div class="pjclass">' + data.oneAppraises.goodsSpecNames + '</div></div><div class="pj_all">查看全部评价</div></div>';
|
||||
}
|
||||
|
||||
img_data = data.goodsDesc.replace(/src=\"__ROOT__\//g, 'data-src="').replace(/data-echo=\"__ROOT__\//g, 'src="' + hyhImgUrl('')).replace(/src=\"\//g, 'src="' + hyhImgUrl(''));
|
||||
img_data = img_data.replace(/src=\"http\:\/\/img.heyuanhui.cn\//g,'src="' + hyhImgUrl(''));
|
||||
////console.log(img_data)
|
||||
html += '<div class="shop_info shadown_wai"><div class="shop_title clearfix"><img src="' + hyhImgUrl(data.shop.shopImg) + '" /><p data-shopId="' + data.shop.shopId + '">' + data.shop.shopName + '</p></div><div class="shopinfocon clearfix"><div class="sicl"><div class="sicl_p1">' + data.goodsCount + '</div><div class="sicl_p2">全部宝贝</div></div><div class="sicl"><div class="sicl_p1">' + data.newGoodsCount + '</div><div class="sicl_p2">上新宝贝</div></div><div class="sicl"><div class="sicl_p1">' + data.favoritesShopsNum + '</div><div class="sicl_p2">关注人数</div></div><div class="sicr"><div class="sicr_p">宝贝描述 <o>' + data.shop.goodsScore + '</o></div><div class="sicr_p">卖家服务 <o>' + data.shop.serviceScore + '</o></div><div class="sicr_p">物流服务 <o>' + data.shop.timeScore + '</o></div></div></div></div><div class="imgcon"></div></div>';
|
||||
$('.con_').html(html);
|
||||
|
||||
$('.cclass_con .img').html('<img src="' + hyhImgUrl(data.goodsImg) + '" />');
|
||||
$('.cclass_con .cc2 p').html('¥' + data.shopPrice);
|
||||
$('.cclass_con .cc2 span').html('库存' + data.goodsStock + '件');
|
||||
if(data.showWhsle == 1) {
|
||||
isShowWhsle = 1;
|
||||
}
|
||||
$('#storebtn').attr('data-shopId', data.shopId);
|
||||
$('.swiper-slide img').height($('.swiper-slide img').width());
|
||||
$('.swiper-slide').height($('.swiper-slide').width());
|
||||
//$('.swiper-slide').height($('.swiper-slide').width() * 460 / 750);
|
||||
//$('.swiper-slide img').height($('.swiper-slide img').width() * 460 / 750);
|
||||
|
||||
// $('.banner').height($('.banner').width());
|
||||
var swiper = new Swiper('.swiper-container', {
|
||||
pagination: '.swiper-pagination',
|
||||
paginationClickable: true,
|
||||
spaceBetween: 30,
|
||||
autoplay: 3000
|
||||
});
|
||||
var html1 = '';
|
||||
// var html1 = '<div class="mui-scroll-wrapper" id="hahaha"><div class="mui-scroll">';
|
||||
$.each(data.spec, function() {
|
||||
html1 += '<div class="cclass1 clearfix" data-class=""><p>' + this.name + '</p>'
|
||||
$.each(this.list, function() {
|
||||
// //console.log(this.itemId)
|
||||
html1 += '<div class="block" data-itemId="' + this.itemId + '" data-itemImg="' + this.itemImg + '">' + this.itemName + '</div>'
|
||||
});
|
||||
html1 += '</div>'
|
||||
});
|
||||
// html1+='</div></div>'
|
||||
$('.ccclass').html(html1);
|
||||
// var hahaha = mui('#hahaha').scroll();
|
||||
// $('.ccclass').height($('#hahaha').height())
|
||||
for(var i in data.saleSpec) {
|
||||
data_saleSpec[i] = data.saleSpec[i];
|
||||
// if(data.saleSpec[i]["id"] == MiaoshaSaleSpec) {
|
||||
// specsId = i
|
||||
// arry_str = i;
|
||||
// isDefaultArr = i.split(':');
|
||||
// }
|
||||
if(data.saleSpec[i]["isDefault"] == 1) {
|
||||
isDefaultArr = i.split(':');
|
||||
arry_str = i;
|
||||
}
|
||||
|
||||
}
|
||||
if(data.couponList == '') {
|
||||
$('.yyyhhhqqq').css('display', 'none');
|
||||
} else {
|
||||
$.each(data.couponList, function() {
|
||||
html2 += '<div class="thq_block"><img src="' + hyhImgUrl('static/app2/img/coupon_bg.png') + '"/><p>¥' + this.couponValue + '</p><span>满' + this.useMoney + '元使用</span><button class="lq_btn" data-couponId="' + this.couponId + '">领取</button></div>';
|
||||
});
|
||||
$('.yhqcon').html(html2);
|
||||
}
|
||||
|
||||
// if(isMiaosha == 1 || (data.is_seckilling&&data.is_seckilling == 1)||(data_saleSpec[arry_str].is_seckilling&&data_saleSpec[arry_str].is_seckilling==1)) {
|
||||
var html_miaosha = ''
|
||||
if(data.is_seckilling && data.is_seckilling == '1') {
|
||||
$('.mujidikou').css('display', 'none');
|
||||
seckilling_end_time = data.seckilling_end_time;
|
||||
html_miaosha = '<img src="../img/bg_miaosha.png"/><p class="miaosha1"><o>¥</o>' + data.shopPrice + '</p><del class="miaosha2">¥' + data.marketPrice + '</del><div class="xiangou">限购四件</div><p class="miaosha3"><o id="_h">00</o>:<o id="_m">00</o>:<o id="_s">00</o></p><p class="miaosha4">桔子抢购</p><p class="miaosha5">距结束还剩</p>';
|
||||
|
||||
$('.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('<img src="' + hyhImgUrl($(this).attr('data-itemImg')) + '" />');
|
||||
}
|
||||
|
||||
var arry = [];
|
||||
|
||||
$.each($('.cclass1'), function() {
|
||||
arry.push($(this).attr('data-class'))
|
||||
});
|
||||
arry.sort(function(a, b) {
|
||||
return a - b;
|
||||
});
|
||||
|
||||
arry_str = arry.join(':');
|
||||
|
||||
for(var i in data_saleSpec) {
|
||||
if(i == arry_str) {
|
||||
$('.cclass_con .cc2 p').html(data_saleSpec[i].specPrice);
|
||||
$('.cclass_con .cc2 span').html('库存' + data_saleSpec[i].specStock + '件');
|
||||
|
||||
if(data_saleSpec[i].is_seckilling && data_saleSpec[i].is_seckilling == 1) {
|
||||
miaoshaSaleSpec(data_saleSpec[i].id, data_saleSpec);
|
||||
} else {
|
||||
|
||||
$('.miaosha').html('');
|
||||
$('.miaosha').css('display', 'none');
|
||||
$('.price').html('¥' + data_saleSpec[i].specPrice);
|
||||
$('.price_old').html('市场价 <del>¥' + data_saleSpec[i].marketPrice + '</del>');
|
||||
$('.price').css('display', 'block');
|
||||
$('.price_old').css('display', 'block');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var num = +$('.change_num input').val();
|
||||
whslePrice(num, arry_str);
|
||||
|
||||
})
|
||||
//跳转选择类型
|
||||
|
||||
$('.footer').on('tap', '.btn_ljgm', function() {
|
||||
$('#changeclass_con').show();
|
||||
})
|
||||
//关闭
|
||||
mui('.cc2').on('tap', '.closecclass', function() {
|
||||
$('#changeclass_con').hide();
|
||||
})
|
||||
|
||||
mui('.en').on('tap', '.engwc', function() {
|
||||
$('#changeclass_con').hide();
|
||||
})
|
||||
|
||||
//改变数量
|
||||
mui('.change_num').on('tap', '.jia', function() {
|
||||
// //console.log($(this).siblings('input').val())
|
||||
var num = +$(this).siblings('input').val() + 1;
|
||||
if(num <= 0) {
|
||||
alert('购买数最小为1!');
|
||||
return;
|
||||
}
|
||||
$(this).siblings('input').val(num);
|
||||
whslePrice(num, arry_str)
|
||||
})
|
||||
mui('.change_num').on('tap', '.jian', function() {
|
||||
var num = +$(this).siblings('input').val() - 1;
|
||||
if(num <= 0) {
|
||||
alert('购买数最小为1!');
|
||||
return;
|
||||
}
|
||||
$(this).siblings('input').val(num);
|
||||
whslePrice(num, arry_str)
|
||||
})
|
||||
$('.change_num input').on('change', function() {
|
||||
var num = +$(this).val();
|
||||
|
||||
whslePrice(num, arry_str);
|
||||
})
|
||||
|
||||
mui('.mui-backdrop').on('tap', '.mask', function() {
|
||||
$('#changeclass_con').hide();
|
||||
})
|
||||
//加入购物车&购买
|
||||
mui('.en').on('tap', '.enarr', function() {
|
||||
|
||||
var that = $(this);
|
||||
// var goodsId = goodsId;
|
||||
var buyNum = $('.change_num input').val();
|
||||
var isGoodsSpecId = 0;
|
||||
var goodsSpecId = 0;
|
||||
var url = '';
|
||||
if($(this).hasClass('engwc')) {
|
||||
url = 'addCart';
|
||||
} else if($(this).hasClass('ensure')) {
|
||||
url = 'buy';
|
||||
}
|
||||
// //console.log(data_bak.isSpec)
|
||||
for(var i in data_saleSpec) {
|
||||
if(i == arry_str) {
|
||||
isGoodsSpecId = 1;
|
||||
goodsSpecId = data_saleSpec[i].id;
|
||||
}
|
||||
}
|
||||
if(isGoodsSpecId == 1) {
|
||||
// goodsSpecId = arry_str;
|
||||
} else if(data_bak.isSpec == 0) {
|
||||
goodsSpecId = 0;
|
||||
} else {
|
||||
alert('请选择商品分类!');
|
||||
return
|
||||
}
|
||||
if(goodsType==2 & $(this).hasClass('engwc')) {
|
||||
mui.alert ("助微吧商品不能加入购物车")
|
||||
return;
|
||||
}
|
||||
// //console.log(arry_str)
|
||||
// //console.log(goodsSpecId)
|
||||
that.attr('disabled', 'disabled');
|
||||
mui.ajax(hyhUrl('app/carts/' + url), {
|
||||
headers: {
|
||||
"HYH-Token": token
|
||||
},
|
||||
data: {
|
||||
if(goodsType){
|
||||
goodsType:goodsType
|
||||
},
|
||||
goodsId: goodsId,
|
||||
buyNum: buyNum,
|
||||
goodsSpecId: goodsSpecId
|
||||
|
||||
},
|
||||
dataType: 'json', //服务器返回json格式数据
|
||||
type: 'post', //HTTP请求类型
|
||||
timeout: 10000, //超时时间设置为10秒;
|
||||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||||
|
||||
data = toJson(data);
|
||||
// //console.log(data.msg);
|
||||
// //console.log(data.status);
|
||||
if(data.status == 1) {
|
||||
if(url == 'buy') {
|
||||
mui.openWindow({
|
||||
url: 'confirmOrder.html',
|
||||
id: 'confirmOrder.html',
|
||||
styles: {
|
||||
top: '0px', //新页面顶部位置
|
||||
bottom: '0px', //新页面底部位置
|
||||
width: '100%', //新页面宽度,默认为100%
|
||||
height: '100%' //新页面高度,默认为100%
|
||||
},
|
||||
extras: {
|
||||
// goodsId: goodsId
|
||||
|
||||
type: 1
|
||||
|
||||
// ..... //自定义扩展参数,可以用来处理页面间传值
|
||||
},
|
||||
createNew: false, //是否重复创建同样id的webview,默认为false:不重复创建,直接显示
|
||||
show: {
|
||||
// autoShow: true, //页面loaded事件发生后自动显示,默认为true
|
||||
// aniShow: animationType, //页面显示动画,默认为”slide-in-right“;
|
||||
// duration: animationTime, //页面动画持续时间,Android平台默认100毫秒,iOS平台默认200毫秒;
|
||||
// event: 'titleUpdate', //页面显示时机,默认为titleUpdate事件时显示
|
||||
// extras: {} //窗口动画是否使用图片加速
|
||||
},
|
||||
waiting: {
|
||||
autoShow: true, //自动显示等待框,默认为true
|
||||
title: '正在加载...', //等待对话框上显示的提示内容
|
||||
options: {
|
||||
// width: waiting - dialog - widht, //等待框背景区域宽度,默认根据内容自动计算合适宽度
|
||||
// height: waiting - dialog - height, //等待框背景区域高度,默认根据内容自动计算合适高度
|
||||
// ......
|
||||
}
|
||||
}
|
||||
})
|
||||
} else if(url == 'addCart') {
|
||||
mui.alert('添加购物车成功!')
|
||||
}
|
||||
|
||||
} else {
|
||||
mui.alert(data.msg);
|
||||
//location.reload();
|
||||
}
|
||||
|
||||
},
|
||||
error: function(xhr, type, errorThrown) { //异常处理;
|
||||
// alert(type);
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
//打开评价列表
|
||||
mui('.con_').on('tap', '.pjrk', function() {
|
||||
JZL.openWindow('appraise.html','appraise.html',{goodsId: goodsId});
|
||||
})
|
||||
$('.footer').on('tap', '#scbtn', function() {
|
||||
var goodId = goodsId;
|
||||
var that = $(this);
|
||||
if($('#scbtn p').html() == '收藏') {
|
||||
mui.ajax(qlgUrl('app/Favorites/add'), {
|
||||
|
||||
data: {
|
||||
id: goodId,
|
||||
type : 0
|
||||
},
|
||||
dataType: 'json', //服务器返回json格式数据
|
||||
type: 'post', //HTTP请求类型
|
||||
timeout: 10000, //超时时间设置为10秒;
|
||||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||||
// //console.log(data.data.goodsFavoritesNum)
|
||||
// //console.log(data.data.Rows)
|
||||
var data = toJson(data);
|
||||
if(data.status == 1) {
|
||||
$('#scbtn p').html('已收藏');
|
||||
$('#scbtn p').css('color', '#E41F4A');
|
||||
$('#scbtn img').attr('src', '../img/likelogo1.png');
|
||||
// that.addClass('gz_btn1').removeClass('gz_btn');
|
||||
} else {
|
||||
mui.alert(data.msg)
|
||||
////console.log(data.status)
|
||||
}
|
||||
|
||||
},
|
||||
error: function(xhr, type, errorThrown) { //异常处理;
|
||||
// alert(type);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mui.ajax(hyhUrl('app/Favorites/cancel'), {
|
||||
|
||||
data: {
|
||||
id: goodId,
|
||||
type : 0
|
||||
},
|
||||
dataType: 'json', //服务器返回json格式数据
|
||||
type: 'post', //HTTP请求类型
|
||||
timeout: 10000, //超时时间设置为10秒;
|
||||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||||
// //console.log(data.data.goodsFavoritesNum)
|
||||
// //console.log(data.data.Rows)
|
||||
var data = toJson(data);
|
||||
if(data.status == 1) {
|
||||
$('#scbtn p').html('收藏');
|
||||
$('#scbtn p').css('color', '#8f8f94');
|
||||
$('#scbtn img').attr('src', '../img/likelogo.png');
|
||||
// that.addClass('gz_btn1').removeClass('gz_btn');
|
||||
} else {
|
||||
mui.alert(data.msg)
|
||||
////console.log(data.status)
|
||||
}
|
||||
|
||||
},
|
||||
error: function(xhr, type, errorThrown) { //异常处理;
|
||||
// alert(type);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
})
|
||||
$('.footer').on('tap', '#storebtn', function() {
|
||||
var shopId = this.attributes["data-shopId"].nodeValue;
|
||||
JZL.openWindow('storeout.html','storeout.html'+ shopId,{shopId: shopId,shopName:shopName});
|
||||
})
|
||||
$('.con').on('tap', '.shop_title p', function() {
|
||||
var shopId = this.attributes["data-shopId"].nodeValue;
|
||||
JZL.openWindow('storeout.html','storeout.html'+ shopId,{shopId: shopId});
|
||||
})
|
||||
//弹出优惠券
|
||||
$('.con_').on('tap', '.lq', function() {
|
||||
$('#youhuiquan_con').css('display', 'block');
|
||||
})
|
||||
//关闭优惠券
|
||||
$('#youhuiquan_con').on('tap', '.thq_close', function() {
|
||||
$('#youhuiquan_con').css('display', 'none');
|
||||
})
|
||||
//领取优惠券
|
||||
$('#youhuiquan_con').on('tap', '.lq_btn', function() {
|
||||
var couponId = $(this).attr('data-couponId');
|
||||
mui.ajax(hyhUrl('addon/coupon-Coupons-receive'), {
|
||||
headers: {
|
||||
"HYH-Token": token
|
||||
},
|
||||
data: {
|
||||
couponId: couponId
|
||||
},
|
||||
dataType: 'json', //服务器返回json格式数据
|
||||
type: 'post', //HTTP请求类型
|
||||
timeout: 10000, //超时时间设置为10秒;
|
||||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||||
|
||||
var data = toJson(data);
|
||||
alert(data.msg);
|
||||
|
||||
},
|
||||
error: function(xhr, type, errorThrown) { //异常处理;
|
||||
// alert(type);
|
||||
}
|
||||
});
|
||||
})
|
||||
//联系客服
|
||||
|
||||
$('#lxkf').on('tap', function() {
|
||||
if(shopQQ) {
|
||||
// location.href="http://wpa.qq.com/msgrd?v=3&uin="+ shopQQ +"&site=qq&menu=yes";
|
||||
// mui.back();
|
||||
// window.open("http://wpa.qq.com/msgrd?v=3&uin="+ shopQQ +"&site=qq&menu=yes")
|
||||
if(plus.os.name == "iOS") {
|
||||
plus.runtime.launchApplication({
|
||||
action: "mqq://im/chat?chat_type=wpa&uin=" + shopQQ + "&version=1&src_type=web"
|
||||
}, function(e) {
|
||||
plus.nativeUI.confirm("检查到您未安装qq,请先到appstore搜索下载?", function(i) {
|
||||
if(i.index == 0) {
|
||||
iosAppstore("itunes.apple.com/cn/app/mqq/");
|
||||
}
|
||||
});
|
||||
});
|
||||
} else if(plus.os.name == "Android") {
|
||||
var Intent = plus.android.importClass('android.content.Intent');
|
||||
var Uri = plus.android.importClass('android.net.Uri');
|
||||
var main = plus.android.runtimeMainActivity();
|
||||
var uri = Uri.parse("mqqwpa://im/chat?chat_type=wpa&uin=" + shopQQ);
|
||||
main.startActivity(new Intent(Intent.ACTION_VIEW, uri));
|
||||
}
|
||||
}
|
||||
})
|
||||
//分享
|
||||
$('.con_').on('tap', '#share', function() {
|
||||
shareHref();
|
||||
})
|
||||
|
||||
|
||||
|
||||
})
|
||||
// var self = plus.webview.currentWebview();
|
||||
// //console.log(self.aaa)
|
Reference in New Issue
Block a user