You've already forked qlg.frontend
Init Repo
This commit is contained in:
323
js/storeout.js
Normal file
323
js/storeout.js
Normal file
@ -0,0 +1,323 @@
|
||||
//$('.searchcon').css('display', 'none');
|
||||
$('.title').css('width', '50%');
|
||||
$('.gz_btn').hide()
|
||||
// var data = '';
|
||||
localStorage.removeItem('shopId');
|
||||
localStorage.removeItem('shopLat');
|
||||
localStorage.removeItem('shopLng');
|
||||
localStorage.removeItem('shopName');
|
||||
localStorage.removeItem('phone');
|
||||
localStorage.removeItem('userName');
|
||||
// $('.nav').html(
|
||||
// '<a class="nav_block on" href="store_home.html"><span>首页</span></a><a class="nav_block" href="store_commodity.html"><span>商品</span></a><a class="nav_block" href="store_new.html"><span>上新</span></a><a class="nav_block" href="store_activity.html"><span>活动</span></a>'
|
||||
// );
|
||||
// $('.searchcon').html(
|
||||
// '<input type="search" name="" id="keyword" value="" placeholder="请输入搜索内容" /><button style="display: none;">搜索</button></div>'
|
||||
// );
|
||||
mui.plusReady(function() {
|
||||
var self = plus.webview.currentWebview();
|
||||
var shopId = self.shopId;
|
||||
var shopName = self.shopName;
|
||||
var shopLat="";
|
||||
var shopLng='';
|
||||
var phone='';
|
||||
var userName='';
|
||||
$('.title').html(shopName)
|
||||
localStorage.setItem('shopId', shopId);
|
||||
localStorage.setItem('shopName', shopName);
|
||||
|
||||
JZL.ajax(qlgUrl('app/shopping/getShopInfo'),{
|
||||
shopId:shopId
|
||||
},function (data) {
|
||||
// console.log(data);
|
||||
if (data.status == 1) {
|
||||
var html = '';
|
||||
var data = data.data;
|
||||
shopLat=data.lat;
|
||||
shopLng=data.lng;
|
||||
phone=data.phone;
|
||||
userName=data.userName;
|
||||
//console.log(shopLng);
|
||||
localStorage.setItem('shopLat', shopLat);
|
||||
localStorage.setItem('shopLng', shopLng);
|
||||
localStorage.setItem('phone', phone);
|
||||
localStorage.setItem('userName', userName);
|
||||
var imgs=data.shopAds.split(",");
|
||||
var firstImg = '';
|
||||
var endImg='';
|
||||
$.each(imgs, function(index,val) {
|
||||
if(index == 0) firstImg='<div class="mui-slider-item mui-slider-item-duplicate"><a href="#"><img src="'+hyhImgUrl(val)+'"></a></div>';
|
||||
if(index == imgs.length-1) endImg='<div class="mui-slider-item mui-slider-item-duplicate"><a href="#"><img src="'+hyhImgUrl(val)+'"></a></div>';
|
||||
////console.log(val);
|
||||
html+='<div class="mui-slider-item"><a href="#"><img src="'+hyhImgUrl(val)+'"></a></div>';
|
||||
//html += '<div class="swiper-slide" ><img src="' + hyhImgUrl(val) + '" alt="" /></div>';
|
||||
});
|
||||
$('#imgsw').html(html);
|
||||
$('#imgsw').prepend(endImg);
|
||||
$('#imgsw').append(firstImg);
|
||||
var slider = mui("#slider");
|
||||
slider.slider({
|
||||
interval: 2000
|
||||
});
|
||||
//$('#top_banner .swiper-wrapper').html(html);
|
||||
// var swiper = new Swiper('#top_banner', {
|
||||
// pagination: '#top_banner_pagination',
|
||||
// spaceBetween: 0,
|
||||
// loop: true,
|
||||
// autoplay: 3500,
|
||||
// autoplayDisableOnInteraction: false
|
||||
// });
|
||||
$('#slider').height($('#slider').width() * 460 / 750);
|
||||
} else{
|
||||
mui.alert(data.msg)
|
||||
}
|
||||
})
|
||||
// mui('.search').on('tap', '.classmenu', function() {
|
||||
// shopId = this.attributes["data-shopid"].nodeValue;
|
||||
// // //console.log(this.attributes["data-id"].nodeValue);
|
||||
// mui.openWindow({
|
||||
// url: 'store_class.html',
|
||||
// id: 'store_class.html',
|
||||
// styles: {
|
||||
// top: '0px', //新页面顶部位置
|
||||
// bottom: '0px', //新页面底部位置
|
||||
// width: '100%', //新页面宽度,默认为100%
|
||||
// height: '100%' //新页面高度,默认为100%
|
||||
// },
|
||||
// extras: {
|
||||
// shopId: shopId
|
||||
// // ..... //自定义扩展参数,可以用来处理页面间传值
|
||||
// },
|
||||
// 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, //等待框背景区域高度,默认根据内容自动计算合适高度
|
||||
// // ......
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// })
|
||||
// mui('.footer').on('tap', '#dpxq', function() {
|
||||
// //console.log(11);
|
||||
// var w = plus.webview.create('store_info.html');
|
||||
// w.show()
|
||||
// })
|
||||
// mui('.footer').on('tap', '#rmfl', function() {
|
||||
//
|
||||
// $('.rmfl').css('display', 'block')
|
||||
// })
|
||||
// mui('.con').on('tap', '.gz_btn', function() {
|
||||
mui('.header_con').on('tap', '.gz_btn', function() {
|
||||
// var shopId = shopId;
|
||||
var that = $(this);
|
||||
//console.log(shopId)
|
||||
mui.ajax(qlgUrl('app/Favorites/add'), {
|
||||
data: {
|
||||
id: shopId,
|
||||
type: 1
|
||||
},
|
||||
dataType: 'json', //服务器返回json格式数据
|
||||
type: 'post', //HTTP请求类型
|
||||
timeout: 10000, //超时时间设置为10秒;
|
||||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||||
//console.log(data)
|
||||
// //console.log(data.data.goodsFavoritesNum)
|
||||
// //console.log(data.data.Rows)
|
||||
var data = toJson(data);
|
||||
if (data.status == 1) {
|
||||
that.html('已关注');
|
||||
that.addClass('gz_btn1').removeClass('gz_btn');
|
||||
} else {
|
||||
////console.log(data.status)
|
||||
}
|
||||
|
||||
},
|
||||
error: function(xhr, type, errorThrown) { //异常处理;
|
||||
// mui.alert(type);
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
$('.header').on('focus', '#keyword', function() {
|
||||
$(".searchcon button").css('display', 'block');
|
||||
})
|
||||
$('.header').on('blur', '#keyword', function() {
|
||||
$(".searchcon button").css('display', 'none');
|
||||
})
|
||||
|
||||
//店铺搜索
|
||||
$(".header").on('keypress', '#keyword', function(e) {
|
||||
var keycode = e.keyCode;
|
||||
var searchName = $('#keyword').val();
|
||||
if(keycode == '13') {
|
||||
// e.preventDefault();
|
||||
// //console.log(searchName)
|
||||
//请求搜索接口
|
||||
mui.openWindow({
|
||||
url: 'shopGoodsList.html',
|
||||
id: 'shopGoodsList.html',
|
||||
styles: {
|
||||
top: '0px', //新页面顶部位置
|
||||
bottom: '0px', //新页面底部位置
|
||||
width: '100%', //新页面宽度,默认为100%
|
||||
height: '100%' //新页面高度,默认为100%
|
||||
},
|
||||
extras: {
|
||||
data_keyword: searchName
|
||||
// ..... //自定义扩展参数,可以用来处理页面间传值
|
||||
},
|
||||
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, //等待框背景区域高度,默认根据内容自动计算合适高度
|
||||
// ......
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
});
|
||||
$(".header").on('tap', '.searchcon button', function(e) {
|
||||
var searchName = $('#keyword').val();
|
||||
// e.preventDefault();
|
||||
// //console.log(searchName)
|
||||
//请求搜索接口
|
||||
mui.openWindow({
|
||||
url: 'shopGoodsList.html',
|
||||
id: 'shopGoodsList.html',
|
||||
styles: {
|
||||
top: '0px', //新页面顶部位置
|
||||
bottom: '0px', //新页面底部位置
|
||||
width: '100%', //新页面宽度,默认为100%
|
||||
height: '100%' //新页面高度,默认为100%
|
||||
},
|
||||
extras: {
|
||||
data_keyword: searchName
|
||||
// ..... //自定义扩展参数,可以用来处理页面间传值
|
||||
},
|
||||
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, //等待框背景区域高度,默认根据内容自动计算合适高度
|
||||
// ......
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
function jumpPage() {
|
||||
//跳转页面
|
||||
// var bSize = 190 + (+localStorage.getItem('ipxSizeTop')) + 'px';
|
||||
var bSize = +localStorage.getItem('topBannerheight')+42+'px';
|
||||
var subpages = ['store_home.html', 'store_commodity.html'];
|
||||
// var subpages = ['store_home.html', 'store_commodity.html', 'store_new.html', 'store_activity.html'];
|
||||
// top: bSize,
|
||||
var subpage_style = {
|
||||
top: bSize,
|
||||
bottom: '0',
|
||||
scrollIndicator: 'none'
|
||||
};
|
||||
|
||||
var aniShow = {}; //动画显示
|
||||
//当前激活选项
|
||||
var activeTab = subpages[0];
|
||||
//选项卡点击事件
|
||||
// mui('.footer').on('tap', 'a', function(e) {
|
||||
|
||||
mui('.nav').on('tap', 'a', function(e) {
|
||||
var targetTab = this.getAttribute('href');
|
||||
// //console.log(targetTab);
|
||||
if (targetTab == activeTab) {
|
||||
return;
|
||||
}
|
||||
//显示目标选项卡
|
||||
//若为iOS平台或非首次显示,则直接显示
|
||||
if (mui.os.ios || aniShow[targetTab]) {
|
||||
plus.webview.show(targetTab);
|
||||
} else {
|
||||
//否则,使用fade-in动画,且保存变量
|
||||
var temp = {};
|
||||
temp[targetTab] = "true";
|
||||
mui.extend(aniShow, temp);
|
||||
plus.webview.show(targetTab, "fade-in", 300);
|
||||
|
||||
}
|
||||
//隐藏当前;
|
||||
plus.webview.hide(activeTab);
|
||||
//更改当前活跃的选项卡
|
||||
activeTab = targetTab;
|
||||
|
||||
// var html = $(this).html();
|
||||
// html = html.substring(0, html.indexOf('.png')) + '_on.png">';
|
||||
// $(this).html(html);
|
||||
$(this).addClass('on').siblings().removeClass('on');
|
||||
// $(this).siblings().each(function() {
|
||||
// if($(this).html().indexOf('_on') == -1) {
|
||||
// return
|
||||
// }
|
||||
// html = $(this).html().substring(0, $(this).html().indexOf('_on'))
|
||||
// html = html + '.png">';
|
||||
// $(this).html(html)
|
||||
// })
|
||||
});
|
||||
|
||||
//首次启动切滑效果
|
||||
|
||||
mui.plusReady(function() {
|
||||
// launchScreen();
|
||||
// plus.navigator.setStatusBarStyle('dark');
|
||||
// //console.log(plus.navigator.getStatusBarStyle())
|
||||
var self = plus.webview.currentWebview();
|
||||
shopId = self.shopId;
|
||||
// console.log(shopId);
|
||||
localStorage.setItem('shopId', shopId);
|
||||
|
||||
for (var i = 0; i < subpages.length; i++) {
|
||||
var temp = {};
|
||||
//http://www.html5plus.org/doc/zh_cn/webview.html#plus.webview.create
|
||||
var sub = plus.webview.create(subpages[i], subpages[i], subpage_style);
|
||||
if (i > 0) {
|
||||
sub.hide();
|
||||
} else {
|
||||
temp[subpages[i]] = "true";
|
||||
mui.extend(aniShow, temp); //合并对象
|
||||
}
|
||||
self.append(sub);
|
||||
}
|
||||
});
|
||||
}
|
||||
jumpPage();
|
||||
|
Reference in New Issue
Block a user