$(function(){
pushHistory();
window.addEventListener("popstate", function(e) {
location.href=base+"/mobile/index.jsp";
}, false);
});
function pushHistory() {
var state = {
title: "title",
url: "#"
};
if(window.history.length==1){
window.history.pushState(state, "title", "#");
}
}
var id=mobile.getUrlVars("id");
var merchant;
mui.init();
/**
*初始化、添加监听
*/
mui.ready(function(){
getMerchant();
$(".productList").on("tap", "li", function(){
if ($(this).attr("product_type")=="10"){
location.href=base+"/mobile/productDetail.jsp?id="+$(this).attr("data-id");
}else if ($(this).attr("product_type")=="20"){
location.href=base+"/mobile/cutProductDetail.jsp?id="+$(this).attr("data-id");
}
});
$(".icon-dianhua").on("tap",function(){
location.href = 'tel:'+merchant.mobile;
});
$(".address").on("tap",function(){
var locations=bd09togcj02(merchant.longitude,merchant.latitude);
wx.ready(function(){
wx.openLocation({
latitude: locations[1], // 纬度,浮点数,范围为90 ~ -90
longitude: locations[0], // 经度,浮点数,范围为180 ~ -180。
name: merchant.merchant_name, // 位置名
address: merchant.address, // 地址详情说明
scale: 28, // 地图缩放级别,整形值,范围从1~28。默认为最大
infoUrl: '' // 在查看位置界面底部显示的超链接,可点击跳转
});
});
});
});
//获取商品信息
function getMerchant(){
mobile.ajaxPost(base+"/merchant/getMerchant",{id:id},function(json){
merchant = json.data;
console.info(json);
share.title=merchant.merchant_name;
//share.link=location.href;
share.imgUrl=imgUrl+merchant.merchant_img1;
$("title").html(merchant.merchant_name);
$(".visit_num").html(merchant.visit_num);
$(".merchant_name").html(merchant.merchant_name);
$(".open_time").html("营业时间:"+merchant.start_hour+"-"+merchant.end_hour);
$(".address").html(''+ merchant.address);
if(merchant.has_wifi=="1"){
$(".has_wifi").removeClass("mui-hidden");
}
if(merchant.has_park=="1"){
$(".has_park").removeClass("mui-hidden");
}
if(merchant.has_ac=="1"){
$(".has_ac").removeClass("mui-hidden");
}
if(merchant.has_box=="1"){
$(".has_box").removeClass("mui-hidden");
}
if(merchant.has_wifi=="0"&&merchant.has_park=="0"&&merchant.has_ac=="0"&&merchant.has_box=="0"){
$(".has_wifi").parents("ul").remove();
}
var arr = [];
if(merchant.merchant_img1){
arr.push(merchant.merchant_img1);
}
if(merchant.merchant_img2){
arr.push(merchant.merchant_img2);
}
if(merchant.merchant_img3){
arr.push(merchant.merchant_img3);
}
if(merchant.product&&merchant.product.length>0){
var html=[];
jQuery.each(merchant.product,function(id,item){
html.push('');
html.push('');
html.push('
'+item.comment_content+'
'); html.push(''+item.create_time+'
'); html.push('