307 lines
12 KiB
JavaScript
307 lines
12 KiB
JavaScript
$('.recommend_title img').eq(0).attr('src', hyhImgUrl('static/app2/img/goods_title.png'));
|
||
$('.recommend_title img').eq(1).attr('src', hyhImgUrl('static/app2/img/coupon_title.png'));
|
||
$('.recommend_title img').eq(0).css('display', 'none');
|
||
$('.recommend_title img').eq(1).css('display', 'none');
|
||
var shopId = localStorage.getItem('shopId');
|
||
mui.plusReady(function() {
|
||
// var data = JSON.parse(localStorage.getItem('shop_data'));
|
||
// var Intent = plus.android.importClass("android.content.Intent");
|
||
// //console.log(Intent)
|
||
//
|
||
mui.ajax(ectUrl('app/Shops/getHome'), {
|
||
data: {
|
||
shopId: shopId
|
||
},
|
||
dataType: 'json', //服务器返回json格式数据
|
||
type: 'post', //HTTP请求类型
|
||
timeout: 10000, //超时时间设置为10秒;
|
||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||
|
||
if (data.status == 1) {
|
||
var data = data.data;
|
||
if (data.shop.shopAds.length > 0) {
|
||
var html = '';
|
||
$.each(data.shop.shopAds, function() {
|
||
html += '<div class="swiper-slide"><img src="' + ectImgUrl(this.adImg) + '" /></div>'
|
||
});
|
||
$('#top_banner .swiper-wrapper').html(html);
|
||
var swiper = new Swiper('#top_banner', {
|
||
pagination: '#top_banner_pagination',
|
||
spaceBetween: 0,
|
||
loop: true,
|
||
autoplay: 3500,
|
||
autoplayDisableOnInteraction: false
|
||
});
|
||
$('#top_banner').height($('#top_banner').width() * 420 / 715);
|
||
$('#top_banner img').height($('#top_banner img').width() * 420 / 715);
|
||
} else {
|
||
$('#top_banner').remove()
|
||
}
|
||
|
||
if (data.couponList.coupons.length > 0) {
|
||
var html_ = '';
|
||
$.each(data.couponList.coupons, function(num) {
|
||
html_ += '<div class="swiper-slide home_yhj" data-couponId="' + this.couponId + '"><img src=" ' +
|
||
ectImgUrl('static/app2/img/bg_' + (num % 3 + 1) + '.png') +
|
||
'" alt="" /><p class="p1">点击领取</p><p class="p2">满' + this.useMoney + '使用</p><p class="p3">' + this.couponValue +
|
||
'</p></div>'
|
||
});
|
||
$('#timer_swiper .swiper-wrapper').html(html_);
|
||
$('.recommend_title img').eq(0).css('display', 'block');
|
||
var swiper = new Swiper('#timer_swiper', {
|
||
slidesPerView: 2.3,
|
||
paginationClickable: true,
|
||
spaceBetween: 0,
|
||
freeMode: true
|
||
});
|
||
$('#timer_swiper .swiper-slide img').height($('#timer_swiper .swiper-slide img').width() * 140 / 300);
|
||
$('#timer_swiper .swiper-slide').height($('#timer_swiper .swiper-slide').width() * 190 / 300);
|
||
} else {
|
||
$('.time').css('display', 'none');
|
||
}
|
||
|
||
// var html3 = '';
|
||
// $.each(data.shopcats, function() {
|
||
// html3 += '<div data-catId="' + this.catId + '" class="l_block">' + this.catName + '</div>';
|
||
// });
|
||
// $('.label').html(html3);
|
||
// $('.l_block').each(function(num) {
|
||
// if((num + 1) % 4 == 0) {
|
||
// $(this).addClass('lbrr');
|
||
// }
|
||
// })
|
||
var html4 = '';
|
||
if (data.rec == '') {
|
||
$('.recommend_title').eq(1).css('display', 'none');
|
||
} else {
|
||
$.each(data.rec, function() {
|
||
html4 += '<div class="recommend_con_block shadown_wai" data-goodsId="' + this.goodsId +
|
||
'"><img class="rcb_img" src="' + ectImgUrl(this.goodsImg) +
|
||
'" alt="" /><div class="rcb_con"><div class="rcb_title"><span style="display:none;">自营</span>' + this.goodsName +
|
||
'</div><div class="rcb_pay">¥' + this.shopPrice +
|
||
'<span style="display:none;">满减</span></div><div class="rcb_bottom"><span>可用木吉抵扣20%货款</span></div></div><img class="icon_icon" style="display:none;"src="../img/icon_sscl.png" alt="" /></div>'
|
||
});
|
||
$('.recommend_con').html(html4);
|
||
$('.recommend_title img').eq(1).css('display', 'block');
|
||
$('.rcb_img').height($('.rcb_img').width())
|
||
}
|
||
} else {
|
||
mui.alert(data.msg)
|
||
}
|
||
},
|
||
error: function(xhr, type, errorThrown) { //异常处理;
|
||
// mui.alert(type);
|
||
}
|
||
});
|
||
//领取优惠券
|
||
$('.time').on('tap', '.home_yhj', 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);
|
||
mui.alert(data.msg);
|
||
|
||
},
|
||
error: function(xhr, type, errorThrown) { //异常处理;
|
||
// mui.alert(type);
|
||
}
|
||
});
|
||
})
|
||
$('.recommend_con').on('tap', '.recommend_con_block', function() {
|
||
var good_id = $(this).attr('data-goodsId');
|
||
mui.openWindow({
|
||
url: 'details.html',
|
||
id: 'details.html' + good_id,
|
||
styles: {
|
||
top: '0px', //新页面顶部位置
|
||
bottom: '0px', //新页面底部位置
|
||
width: '100%', //新页面宽度,默认为100%
|
||
height: '100%' //新页面高度,默认为100%
|
||
},
|
||
extras: {
|
||
data_id: good_id
|
||
// ..... //自定义扩展参数,可以用来处理页面间传值
|
||
},
|
||
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, //等待框背景区域高度,默认根据内容自动计算合适高度
|
||
// ......
|
||
}
|
||
}
|
||
})
|
||
})
|
||
localStorage.setItem('shop_data', '');
|
||
})
|
||
|
||
setInterval(function() {
|
||
$('.cnxh_block img').height($('.cnxh_block img').width());
|
||
$('.cnxh_block').height($('.cnxh_block').width() * 266 / 198);
|
||
}, 200)
|
||
|
||
var scheme = "";
|
||
var arr = [];
|
||
var title = {};
|
||
$('.go').on("tap", function() {
|
||
if (0 == arr.length) {
|
||
//console.log(111)
|
||
}
|
||
//底部弹出选择地图软件
|
||
plus.nativeUI.actionSheet({
|
||
title: "请选择!",
|
||
cancel: "取消",
|
||
buttons: arr
|
||
}, function(e) {
|
||
var title = arr[e.index - 1].title;
|
||
// var i1 = new Intent();
|
||
switch (title) {
|
||
case "百度地图":
|
||
// plus.runtime.openURL( "baidumap://map/direction?origin=latlng:39.98871,116.43234|name:我的位置&destination=40.007623,116.360582&mode=driving&src=webapp.navi.hanguosoft.yinyijianghu", function(error){ alert("打开百度地图失败")});
|
||
launchTest()
|
||
// if (plus.os.name == "Android") {
|
||
// plus.runtime.launchApplication({
|
||
// pname: "com.android.browser",
|
||
// extra: {
|
||
// // url: "://map/direction?origin=latlng:33,33|name:我的位置&destination=latlng:43.335,39.966|name:beijing&mode=driving",
|
||
// // url:"://map/direction?destination=latlng:33,44|name:geijign&mode=driving&" + // 导航路线方式
|
||
// // "region=武汉"
|
||
//
|
||
// url:"http://www.html5plus.org"
|
||
//
|
||
// // url :"baidumap://map/direction?origin=name:对外经贸大学|latlng:39.98871,116.43234&destination=西直门&coord_type=bd09ll&mode=transit"
|
||
// // url : "http://api.map.baidu.com/direction?origin=latlng:42.111,111|name:当前位置&destination=latlng:31,111|name:终点&mode=driving®ion=中国&output=html"
|
||
// }
|
||
// }, function(e) {
|
||
// alert("Open system default browser failed: " + e.message);
|
||
//
|
||
// });
|
||
// } else if (plus.os.name == "iOS") {
|
||
// plus.runtime.launchApplication({
|
||
// action: "://map/direction?origin=latlng:114,33|name:我的位置&destination=latlng:116.335, 39.966|name:beijing&mode=driving"//"第三方提供的uri"
|
||
// }, function(e) {
|
||
// alert("Open system default browser failed: " + e.message);
|
||
// });
|
||
// }
|
||
break;
|
||
case "高德地图":
|
||
|
||
}
|
||
});
|
||
|
||
|
||
|
||
})
|
||
var maps=[{pname:'com.baidu.BaiduMap',action:'baidumap',name:'百度地图'},{pname:'com.autonavi.minimap',action:'iosamap',name:'高德地图'},{pname:'com.google.android.apps.maps',action:'com.google.android.apps.maps',name:'谷歌地图'},{pname:'com.tencent.map',action:'com.google.android.apps.maps',name:'腾讯地图'}]
|
||
// checkApp("com.baidu.BaiduMap", "baidumap", "百度地图")
|
||
// checkApp("com.autonavi.minimap", "iosamap", "高德地图")
|
||
// checkApp("com.google.android.apps.maps", "com.google.android.apps.maps", "谷歌地图")
|
||
// 判断地图软件是否安装
|
||
// maps= toJson(maps)
|
||
// //console.log(maps)
|
||
// $.each(maps,function(i,v){
|
||
//
|
||
// var that=this
|
||
//
|
||
// checkApp(that.pname, that.action, that.name)
|
||
// })
|
||
// function checkApp(pn, ac, name) {
|
||
// if (plus.runtime.isApplicationExist({
|
||
// pname: pn,//包名
|
||
// action: ac //ios包名
|
||
// })) {
|
||
// // //console.log("微信应用已安装");
|
||
// title = {
|
||
// title: name
|
||
// };
|
||
// arr.push(title)
|
||
// } else {
|
||
// // //console.log("微信应用未安装");
|
||
// // title={};
|
||
// // arr.push(title)
|
||
//
|
||
// }
|
||
// }
|
||
|
||
function launchTest() {
|
||
if (plus.os.name == "Android") {
|
||
plus.runtime.launchApplication( {pname:"com.baidu.BaiduMap"
|
||
,extra:{url:"://map/direction?origin=name:对外经贸大学|latlng:39.98871,116.43234&destination=西直门&coord_type=bd09ll&mode=transit&sy=3&index=0&target=1&src=andr.baidu.openAPIdemo"}}, function ( e ) {
|
||
alert( "Open system default browser failed: " + e.message );})
|
||
// plus.runtime.launchApplication({
|
||
//
|
||
// pname: "com.baidu.BaiduMap",
|
||
// // pname: "bdapp",
|
||
//
|
||
// // http://uri.amap.com/navigation?from=" + fromLongitude + "," + fromLatitude + "&to="+ longitude + "," + latitude + "&mode=car&src=nyx_super;
|
||
//
|
||
// extra: {
|
||
// url:"baidumap://map/bikenavi?origin=39.98871,116.43234&destination=39.91441,116.40405&coord_type=bd09ll&src=andr.baidu.openAPIdemo"
|
||
// // url:"bdapp://map/direction?destination=latlng:31,111|name:终点&mode=driving®ion=中国&src=andr.baidu.openAPIdemo"
|
||
// // url:"http://baidu.com"
|
||
// // url:"com.baidu.BaiduMap://map/direction?origin=中关村&destination=五道口&mode=driving®ion=北京 "
|
||
// // url: "://map/direction?origin=latlng:114,33|name:我的位置&destination=latlng:116.335,39.966|name:beijing&mode=driving"
|
||
// }
|
||
// }, function(e) {
|
||
// alert("Open system default browser failed: " + e.message);
|
||
//
|
||
// });
|
||
} else if (plus.os.name == "iOS") {
|
||
plus.runtime.launchApplication({
|
||
action: "第三方提供的uri"
|
||
}, function(e) {
|
||
alert("Open system default browser failed: " + e.message);
|
||
});
|
||
}
|
||
}
|
||
|
||
launchTest()
|
||
|
||
|
||
|
||
|
||
|
||
|
||
mui('.gothere').on("tap", ".gt_con", function(e) {
|
||
var idx = $(this).index();
|
||
var html = '';
|
||
|
||
switch (idx) {
|
||
case 0:
|
||
|
||
break;
|
||
case 1:
|
||
|
||
break;
|
||
case 2:
|
||
// $('.gt_con_con1').css('display','none')
|
||
|
||
$('.gt_con_con').toggle()
|
||
html =
|
||
'<div class="row shadown_wai"><div class="name"><label class="label-idx" for="">姓名:</label><label class="label-val" for="">张三</label></div><div class="name"><label class="label-idx" for="">电话:</label><label class="label-val" for=""><a href="tel:13482378262">13482378262</label></div></div>'
|
||
$('.row .name').css("width", "60%")
|
||
$('.gt_con_con').html(html)
|
||
break;
|
||
|
||
}
|
||
})
|