You've already forked qlg.tsgz.moe
Init Repo
This commit is contained in:
42
hyhproject/wechat2/view/default/js/brands.js
Executable file
42
hyhproject/wechat2/view/default/js/brands.js
Executable file
@ -0,0 +1,42 @@
|
||||
//商品列表页
|
||||
function getGoodsList(brandId){
|
||||
location.href = WST.U('wechat/goods/lists','brandId='+brandId);
|
||||
}
|
||||
//获取品牌列表
|
||||
function brandsList(){
|
||||
$('#Load').show();
|
||||
loading = true;
|
||||
var param = {};
|
||||
param.pagesize = 16;
|
||||
param.page = Number( $('#currPage').val() ) + 1;
|
||||
$.post(WST.U('wechat/brands/pageQuery'), param,function(data){
|
||||
var json = WST.toJson(data);
|
||||
if(json && json.Rows && json.Rows.length>0){
|
||||
$('#currPage').val(json.CurrentPage);
|
||||
$('#totalPage').val(json.TotalPage);
|
||||
var gettpl = document.getElementById('list').innerHTML;
|
||||
laytpl(gettpl).render(json.Rows, function(html){
|
||||
$('#info-list').append(html);
|
||||
});
|
||||
echo.init();//图片懒加载
|
||||
}
|
||||
loading = false;
|
||||
$('#Load').hide();
|
||||
});
|
||||
}
|
||||
var currPage = totalPage = 0;
|
||||
var loading = false;
|
||||
$(document).ready(function(){
|
||||
WST.initFooter('home');
|
||||
brandsList();
|
||||
$(window).scroll(function(){
|
||||
if (loading) return;
|
||||
if ((5 + $(window).scrollTop()) >= ($(document).height() - screen.height)) {
|
||||
currPage = Number( $('#currPage').val() );
|
||||
totalPage = Number( $('#totalPage').val() );
|
||||
if( totalPage > 0 && currPage < totalPage ){
|
||||
brandsList();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
189
hyhproject/wechat2/view/default/js/carts.js
Executable file
189
hyhproject/wechat2/view/default/js/carts.js
Executable file
@ -0,0 +1,189 @@
|
||||
var promotionMethod = {};
|
||||
$(document).ready(function(){
|
||||
WST.initFooter('cart');
|
||||
WST.imgAdapt('j-imgAdapt');
|
||||
|
||||
statCartMoney();
|
||||
//选中店铺
|
||||
$('.ui-icon-chooses').click(function(){
|
||||
WST.changeIconStatus($(this), 1);
|
||||
var childrenId = $(this).attr('childrenId');
|
||||
var goodsCount = $('.'+childrenId).length;//商品个数
|
||||
var ids = [];
|
||||
if( $(this).attr('class').indexOf('wst-active') == -1 ){
|
||||
WST.changeIconStatus($('.'+childrenId), 2);//选中
|
||||
for(var i=0; i<goodsCount; i++){
|
||||
var cid = $('.'+childrenId).eq(i).attr('cartId');
|
||||
ids.push(cid);
|
||||
}
|
||||
WST.batchChangeCartGoods(ids.join(','),0);
|
||||
}else{
|
||||
WST.changeIconStatus($('.'+childrenId), 2, 'wst-active');//取消选中
|
||||
for(var i=0; i<goodsCount; i++){
|
||||
var cid = $('.'+childrenId).eq(i).attr('cartId');
|
||||
ids.push(cid);
|
||||
}
|
||||
WST.batchChangeCartGoods(ids.join(','),1);
|
||||
}
|
||||
statCartMoney();
|
||||
});
|
||||
//选中商品
|
||||
$('.ui-icon-chooseg').click(function(){
|
||||
if( $(this).attr('class').indexOf('wst-active') == -1 ){
|
||||
var checked = 1;
|
||||
WST.changeIconStatus($(this), 1);//选中
|
||||
}else{
|
||||
var checked = 0;
|
||||
WST.changeIconStatus($(this), 2);//取消选中
|
||||
}
|
||||
var cid = $(this).attr('cartId');
|
||||
if(cid!=''){
|
||||
WST.changeCartGoods(cid,$('#buyNum_'+cid).val(),checked);
|
||||
statCartMoney();
|
||||
}
|
||||
});
|
||||
//选中合计
|
||||
$('.ui-icon-choose').click(function(){
|
||||
WST.changeIconStatus($(this), 1);
|
||||
var shopIconCount = $('.ui-icon-chooses').length;//店铺个数
|
||||
var goodsCount = $('.ui-icon-chooseg').length;//商品个数
|
||||
var ids = [];
|
||||
if( $(this).attr('class').indexOf('wst-active') == -1 ){
|
||||
//选中所有
|
||||
for(var i=0; i<shopIconCount; i++){
|
||||
WST.changeIconStatus($('.ui-icon-chooses').eq(i), 2);
|
||||
}
|
||||
for(var i=0; i<goodsCount; i++){
|
||||
WST.changeIconStatus($('.ui-icon-chooseg').eq(i), 2);
|
||||
var cid = $('.ui-icon-chooseg').eq(i).attr('cartId');
|
||||
ids.push(cid);
|
||||
}
|
||||
WST.batchChangeCartGoods(ids.join(','),0);
|
||||
}else{
|
||||
//取消选中所有
|
||||
for(var i=0; i<shopIconCount; i++){
|
||||
WST.changeIconStatus($('.ui-icon-chooses').eq(i), 2, 'wst-active');
|
||||
}
|
||||
for(var i=0; i<goodsCount; i++){
|
||||
WST.changeIconStatus($('.ui-icon-chooseg').eq(i), 2, 'wst-active');
|
||||
var cid = $('.ui-icon-chooseg').eq(i).attr('cartId');
|
||||
ids.push(cid);
|
||||
}
|
||||
WST.batchChangeCartGoods(ids.join(','),1);
|
||||
}
|
||||
statCartMoney();
|
||||
});
|
||||
});
|
||||
//合计
|
||||
function statCartMoney(){
|
||||
var cartMoney = 0,goodsTotalPrice,id;
|
||||
$('.wst-active').each(function(){
|
||||
id = $(this).attr('cartId');
|
||||
goodsTotalPrice = parseFloat($(this).attr('mval'))*parseInt($('#buyNum_'+id).val());
|
||||
cartMoney = cartMoney + goodsTotalPrice;
|
||||
});
|
||||
for(var i=1; i<$('#totalshop').val(); i++){
|
||||
var shopMoney = 0,goodsTotalPrice2;
|
||||
$('.clist'+i).each(function(){
|
||||
id = $(this).attr('cartId');
|
||||
goodsTotalPrice2 = parseFloat($(this).attr('mval'))*parseInt($('#buyNum_'+id).val());
|
||||
shopMoney = shopMoney + goodsTotalPrice2;
|
||||
});
|
||||
$('#tprice_'+i).html('<span>¥ </span>'+shopMoney.toFixed(2));
|
||||
}
|
||||
/* 满就送 */
|
||||
var minusMoney = 0;
|
||||
for(var key in promotionMethod){
|
||||
minusMoney = window[key](cartMoney);
|
||||
cartMoney = cartMoney - minusMoney;
|
||||
}
|
||||
$('#totalMoney').html('<span>¥ </span>'+cartMoney.toFixed(2));
|
||||
checkGoodsBuyStatus();
|
||||
}
|
||||
function checkGoodsBuyStatus(){
|
||||
var cartNum = 0,stockNum = 0,cartId = 0;
|
||||
$('.wst-active').each(function(){
|
||||
cartId = $(this).attr('cartId');
|
||||
cartNum = parseInt($('#buyNum_'+cartId).val(),10);
|
||||
stockNum = parseInt($('#buyNum_'+cartId).attr('data-max'),10);
|
||||
if(stockNum < 0 || stockNum < cartNum){
|
||||
if(stockNum < 0){
|
||||
msg = '库存不足';
|
||||
}else{
|
||||
msg = '购买量超过库存';
|
||||
}
|
||||
$('#noprompt'+cartId).show().html(msg);
|
||||
$(this).parent().parent().addClass('nogoods');
|
||||
WST.changeIconStatus($(this), 2);//取消选中
|
||||
WST.changeCartGoods(cartId,$('#buyNum_'+cartId).val(),0);
|
||||
statCartMoney();
|
||||
}else{
|
||||
$('#noprompt'+cartId).hide().html('');
|
||||
$(this).parent().parent().removeClass('nogoods');
|
||||
}
|
||||
});
|
||||
}
|
||||
//编辑
|
||||
function edit(type){
|
||||
if(type==0){
|
||||
WST.showHide('','#edit,#settlement,#total');
|
||||
WST.showHide(1,'#complete,#delete');
|
||||
}else{
|
||||
WST.showHide('','#complete,#delete');
|
||||
WST.showHide(1,'#edit,#settlement,#total');
|
||||
}
|
||||
}
|
||||
//删除
|
||||
function deletes(){
|
||||
var goodsIds = '';
|
||||
var goodsIconCount = $('.ui-icon-chooseg').length;//商品个数
|
||||
for(var i=0; i<goodsIconCount; i++){
|
||||
if( $('.ui-icon-chooseg').eq(i).attr('class').indexOf('wst-active') != -1 ){
|
||||
goodsIds += $('.ui-icon-chooseg').eq(i).attr('cartId') + ',';
|
||||
}
|
||||
}
|
||||
if(goodsIds!=''){
|
||||
WST.dialog('确定删除选中的商品吗?','del("'+goodsIds+'")');
|
||||
}else{
|
||||
WST.msg('请选择要删除的商品','info');
|
||||
}
|
||||
}
|
||||
function del(goodsIds){
|
||||
$.post(WST.U('wechat/carts/delCart'),{id:goodsIds},function(data,textStatus){
|
||||
var json = WST.toJson(data);
|
||||
if(json.status==1){
|
||||
WST.msg(json.msg,'success');
|
||||
WST.dialogHide('prompt');
|
||||
setTimeout(function(){
|
||||
location.href = WST.U('wechat/carts/index');
|
||||
},2000);
|
||||
}else{
|
||||
WST.msg(json.msg,'warn');
|
||||
}
|
||||
});
|
||||
}
|
||||
//结算
|
||||
function toSettlement(){
|
||||
var goodsIconCount = $('.ui-icon-chooseg').length;//商品个数
|
||||
var noGoodsSelected = true;
|
||||
for(var i=0; i<goodsIconCount; i++){
|
||||
if( $('.ui-icon-chooseg').eq(i).attr('class').indexOf('wst-active') != -1 ){
|
||||
noGoodsSelected = false;
|
||||
}
|
||||
}
|
||||
if(noGoodsSelected){
|
||||
WST.msg('请勾选要结算的商品','info');
|
||||
return false;
|
||||
}
|
||||
location.href = WST.U('wechat/carts/settlement');
|
||||
}
|
||||
//导航
|
||||
function inMore(){
|
||||
if($("#arrow").css("display")=='none'){
|
||||
$("#arrow").show();
|
||||
$("#layer").show();
|
||||
}else{
|
||||
$("#arrow").hide();
|
||||
$("#layer").hide();
|
||||
}
|
||||
}
|
445
hyhproject/wechat2/view/default/js/common.js
Executable file
445
hyhproject/wechat2/view/default/js/common.js
Executable file
@ -0,0 +1,445 @@
|
||||
var WST = WST?WST:{};
|
||||
WST.wxv = '1.0_0825';
|
||||
WST.toJson = function(str,notLimit){
|
||||
var json = {};
|
||||
if(str){
|
||||
try{
|
||||
if(typeof(str )=="object"){
|
||||
json = str;
|
||||
}else{
|
||||
json = eval("("+str+")");
|
||||
}
|
||||
if(!notLimit){
|
||||
if(json.status && json.status=='-999'){
|
||||
WST.inLogin();
|
||||
}
|
||||
}
|
||||
}catch(e){
|
||||
alert("系统发生错误:"+e.getMessage);
|
||||
json = {};
|
||||
}
|
||||
return json;
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
}
|
||||
//登录
|
||||
WST.inLogin = function(){
|
||||
var urla = window.location.href;
|
||||
$.post(WST.U('wechat/index/sessionAddress'),{url:urla},function(data,textStatus){});
|
||||
var urls = escape(document.location.protocol+'//'+window.location.host+WST.U('wechat/users/login','type=1'));
|
||||
var url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+WST.conf.wxAppId+'&redirect_uri='+urls+'&response_type=code&scope=snsapi_userinfo&state='+window.conf.wxAppCode+'#wechat_redirect';
|
||||
window.location.href = url;
|
||||
}
|
||||
//底部的tab
|
||||
WST.initFooter = function(tab){
|
||||
var homeImage = (tab=='home') ? 'home-active' : 'home';
|
||||
var categoryImage = (tab=='category') ? 'category-active' : 'category';
|
||||
var cartImage = (tab=='cart') ? 'cart-active' : 'cart';
|
||||
var followImage = (tab=='brand') ? 'follow-active' : 'follow';
|
||||
var usersImage = (tab=='user') ? 'user-active' : 'user';
|
||||
$('#home').append('<span class="icon '+homeImage+'"></span><span class="'+homeImage+'-word">首页</span>');
|
||||
$('#category').append('<span class="icon '+categoryImage+'"></span><span class="'+categoryImage+'-word">分类</span>');
|
||||
$('#cart').prepend('<span class="icon '+cartImage+'"></span><span class="'+cartImage+'-word">购物车</span>');
|
||||
$('#follow').append('<span class="icon '+followImage+'"></span><span class="'+followImage+'-word">关注</span>');
|
||||
$('#user').append('<span class="icon '+usersImage+'"></span><span class="'+usersImage+'-word">我的</span>');
|
||||
}
|
||||
//变换选中框的状态
|
||||
WST.changeIconStatus = function (obj, toggle, status){
|
||||
if(toggle==1){
|
||||
if( obj.attr('class').indexOf('ui-icon-unchecked-s') > -1 ){
|
||||
obj.removeClass('ui-icon-unchecked-s').addClass('ui-icon-success-block wst-active');
|
||||
}else{
|
||||
obj.removeClass('ui-icon-success-block wst-active').addClass('ui-icon-unchecked-s');
|
||||
}
|
||||
}else if(toggle==2){
|
||||
if(status == 'wst-active'){
|
||||
obj.removeClass('ui-icon-unchecked-s').addClass('ui-icon-success-block wst-active');
|
||||
}else{
|
||||
obj.removeClass('ui-icon-success-block wst-active').addClass('ui-icon-unchecked-s');
|
||||
}
|
||||
}
|
||||
}
|
||||
WST.changeIptNum = function(diffNum,iptId,id,func){
|
||||
var suffix = (id)?"_"+id:"";
|
||||
var iptElem = $(iptId+suffix);
|
||||
var minVal = parseInt(iptElem.attr('data-min'),10);
|
||||
var maxVal = parseInt(iptElem.attr('data-max'),10);
|
||||
var num = parseInt(iptElem.val(),10);
|
||||
num = num?num:1;
|
||||
num = num + diffNum;
|
||||
if(maxVal<=num)num=maxVal;
|
||||
if(num<=minVal)num=minVal;
|
||||
if(num==0)num=1;
|
||||
iptElem.val(num);
|
||||
if(suffix!='')WST.changeCartGoods(id,num,-1);
|
||||
if(func){
|
||||
var fn = window[func];
|
||||
fn();
|
||||
}
|
||||
}
|
||||
WST.changeCartGoods = function(id,buyNum,isCheck){
|
||||
$.post(WST.U('wechat/carts/changeCartGoods'),{id:id,isCheck:isCheck,buyNum:buyNum,rnd:Math.random()},function(data,textStatus){
|
||||
var json = WST.toJson(data);
|
||||
if(json.status!=1){
|
||||
WST.msg(json.msg,'info');
|
||||
}
|
||||
});
|
||||
}
|
||||
// 批量修改购物车状态
|
||||
WST.batchChangeCartGoods = function(ids,isCheck){
|
||||
$.post(WST.U('wechat/carts/batchChangeCartGoods'),{ids:ids,isCheck:isCheck},function(data,textStatus){
|
||||
var json = WST.toJson(data);
|
||||
if(json.status!=1){
|
||||
WST.msg(json.msg,'info');
|
||||
}
|
||||
});
|
||||
}
|
||||
//商品主页
|
||||
WST.intoGoods = function(id){
|
||||
location.href = WST.U('wechat/goods/detail','goodsId='+id);
|
||||
};
|
||||
//店铺主页
|
||||
WST.intoShops = function(id){
|
||||
location.href = WST.U('wechat/shops/home','shopId='+id);
|
||||
};
|
||||
//首页
|
||||
WST.intoIndex = function(){
|
||||
location.href = WST.U('wechat/index/index');
|
||||
};
|
||||
//搜索
|
||||
WST.searchPage = function(type,state){
|
||||
if(state==1){
|
||||
$("#wst-"+type+"-search").show();
|
||||
}else{
|
||||
$("#wst-"+type+"-search").hide();
|
||||
}
|
||||
};
|
||||
WST.search = function(type){
|
||||
var data = $('#wst-search').val();
|
||||
if(type==1){
|
||||
location.href = WST.U('wechat/shops/shopStreet','keyword='+data);//店铺
|
||||
}else if(type==0){
|
||||
location.href = WST.U('wechat/goods/lists','keyword='+data);//商品
|
||||
}else if(type==2){
|
||||
var shopId = $('#shopId').val();
|
||||
location.href = WST.U('wechat/shops/shopGoodsList','goodsName='+data+'&shopId='+shopId);//店铺商品
|
||||
}
|
||||
};
|
||||
//关注
|
||||
WST.favorites = function(sId,type){
|
||||
$.post(WST.U('wechat/favorites/add'),{id:sId,type:type},function(data){
|
||||
var json = WST.toJson(data);
|
||||
if(json.status==1){
|
||||
WST.msg(json.msg,'success');
|
||||
if(type==1){
|
||||
$('#fStatus').html('已关注');
|
||||
$('#fBtn').attr('onclick','WST.cancelFavorite('+json.data.fId+',1)');
|
||||
$('.j-shopfollow').addClass('follow');
|
||||
$('#followNum').html(parseInt($('#followNum').html())+1);
|
||||
}else{
|
||||
$('.imgfollow').removeClass('nofollow').addClass('follow');
|
||||
$('.imgfollow').attr('onclick','WST.cancelFavorite('+json.data.fId+',0)');
|
||||
}
|
||||
}else{
|
||||
WST.msg(json.msg,'info');
|
||||
}
|
||||
})
|
||||
}
|
||||
// 取消关注
|
||||
WST.cancelFavorite = function(fId,type){
|
||||
$.post(WST.U('wechat/favorites/cancel'),{id:fId,type:type},function(data){
|
||||
var json = WST.toJson(data);
|
||||
if(json.status==1){
|
||||
WST.msg(json.msg,'success');
|
||||
if(type==1){
|
||||
$('#fStatus').html('关注店铺');
|
||||
$('#fBtn').attr('onclick','WST.favorites('+$('#shopId').val()+',1)');
|
||||
$('.j-shopfollow').removeClass('follow');
|
||||
$('#followNum').html(parseInt($('#followNum').html())-1);
|
||||
}else{
|
||||
$('.imgfollow').removeClass('follow').addClass('nofollow');
|
||||
$('.imgfollow').attr('onclick','WST.favorites('+$('#goodsId').val()+',0)');
|
||||
}
|
||||
}else{
|
||||
WST.msg(json.msg,'info');
|
||||
}
|
||||
});
|
||||
}
|
||||
WST.userPhoto = function(userPhoto){
|
||||
if(userPhoto.substring(0,4)!='http' && userPhoto!=""){
|
||||
userPhoto = window.conf.ROOT+"/"+userPhoto;
|
||||
}else if(!userPhoto){
|
||||
userPhoto = window.conf.ROOT+"/"+window.conf.USER_LOGO;
|
||||
}
|
||||
return userPhoto;
|
||||
}
|
||||
//刷新验证码
|
||||
WST.getVerify = function(id){
|
||||
$(id).attr('src',WST.U('wechat/index/getVerify','rnd='+Math.random()));
|
||||
}
|
||||
//返回当前页面高度
|
||||
WST.pageHeight = function(){
|
||||
if(WST.checkBrowser().msie){
|
||||
return document.compatMode == "CSS1Compat"? document.documentElement.clientHeight :
|
||||
document.body.clientHeight;
|
||||
}else{
|
||||
return self.innerHeight;
|
||||
}
|
||||
};
|
||||
//返回当前页面宽度
|
||||
WST.pageWidth = function(){
|
||||
if(WST.checkBrowser().msie){
|
||||
return document.compatMode == "CSS1Compat"? document.documentElement.clientWidth :
|
||||
document.body.clientWidth;
|
||||
}else{
|
||||
return self.innerWidth;
|
||||
}
|
||||
};
|
||||
WST.checkBrowser = function(){
|
||||
return {
|
||||
mozilla : /firefox/.test(navigator.userAgent.toLowerCase()),
|
||||
webkit : /webkit/.test(navigator.userAgent.toLowerCase()),
|
||||
opera : /opera/.test(navigator.userAgent.toLowerCase()),
|
||||
msie : /msie/.test(navigator.userAgent.toLowerCase())
|
||||
}
|
||||
}
|
||||
//只能輸入數字
|
||||
WST.isNumberKey = function(evt){
|
||||
var charCode = (evt.which) ? evt.which : event.keyCode;
|
||||
if (charCode > 31 && (charCode < 48 || charCode > 57)){
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
WST.isChinese = function(obj,isReplace){
|
||||
var pattern = /[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/i
|
||||
if(pattern.test(obj.value)){
|
||||
if(isReplace)obj.value=obj.value.replace(/[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/ig,"");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//适应图片大小正方形
|
||||
WST.imgAdapt = function(name){
|
||||
var w = $('.'+name).width();
|
||||
$('.'+name).css({"width": w+"px","height": w+"px"});
|
||||
$('.'+name+' a').css({"width": w+"px","height": w+"px"});
|
||||
$('.'+name+' a img').css({"max-width": w+"px","max-height": w+"px"});
|
||||
}
|
||||
//显示隐藏
|
||||
WST.showHide = function(t,str){
|
||||
var s = str.split(',');
|
||||
if(t){
|
||||
for(var i=0;i<s.length;i++){
|
||||
$(s[i]).show();
|
||||
}
|
||||
}else{
|
||||
for(var i=0;i<s.length;i++){
|
||||
$(s[i]).hide();
|
||||
}
|
||||
}
|
||||
s = null;
|
||||
}
|
||||
/**
|
||||
* 提示信息
|
||||
* @param content 内容
|
||||
* @param type info/普通,success/成功,warn/错误
|
||||
* @param stayTime 显示时间
|
||||
*/
|
||||
WST.msg = function(content,type,stayTime){
|
||||
if(!stayTime){
|
||||
stayTime = '1200';
|
||||
}
|
||||
var el = $.tips({content:content,type:type,stayTime:stayTime});
|
||||
return el;
|
||||
}
|
||||
//提示对话框
|
||||
WST.dialog = function(content,event){
|
||||
$("#wst-dialog").html(content);
|
||||
$("#wst-event2").attr("onclick","javascript:"+event);
|
||||
$("#wst-di-prompt").dialog("show");
|
||||
}
|
||||
//提示分享对话框
|
||||
WST.share = function(){
|
||||
$("#wst-di-share").dialog("show");
|
||||
}
|
||||
/**
|
||||
* 隐藏对话框
|
||||
* @param event prompt/提示对话框
|
||||
* @param event share/提示对话框
|
||||
*/
|
||||
WST.dialogHide = function(event){
|
||||
$("#wst-di-"+event).dialog("hide");
|
||||
}
|
||||
//加载中
|
||||
WST.load = function(content){
|
||||
$('#Loadl').css('display','-webkit-box');
|
||||
$('#j-Loadl').html(content);
|
||||
}
|
||||
WST.noload = function(){
|
||||
$('#Loadl').css('display','none');
|
||||
}
|
||||
//滚动到顶部
|
||||
WSTrunToTop = function (){
|
||||
currentPosition=document.documentElement.scrollTop || document.body.scrollTop;
|
||||
currentPosition-=20;
|
||||
if(currentPosition>0){
|
||||
window.scrollTo(0,currentPosition);
|
||||
}
|
||||
else{
|
||||
window.scrollTo(0,0);
|
||||
clearInterval(timer);
|
||||
}
|
||||
}
|
||||
|
||||
WST.blank = function(str,defaultVal){
|
||||
if(str=='0000-00-00')str = '';
|
||||
if(str=='0000-00-00 00:00:00')str = '';
|
||||
if(!str)str = '';
|
||||
if(typeof(str)=='null')str = '';
|
||||
if(typeof(str)=='undefined')str = '';
|
||||
if(str=='' && defaultVal)str = defaultVal;
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
*/
|
||||
WST.upload = function(opts){
|
||||
var _opts = {};
|
||||
_opts = $.extend(_opts,{auto: true,swf: WST.conf.ROOT +'/plugins/webuploader/Uploader.swf',server:WST.U('wechat/orders/uploadPic')},opts);
|
||||
var uploader = WebUploader.create(_opts);
|
||||
uploader.on('uploadSuccess', function( file,response ) {
|
||||
var json = WST.toJson(response._raw);
|
||||
if(_opts.callback)_opts.callback(json,file);
|
||||
});
|
||||
uploader.on('uploadError', function( file ) {
|
||||
if(_opts.uploadError)_opts.uploadError();
|
||||
});
|
||||
uploader.on( 'uploadProgress', function( file, percentage ) {
|
||||
percentage = percentage.toFixed(2)*100;
|
||||
if(_opts.progress)_opts.progress(percentage);
|
||||
});
|
||||
return uploader;
|
||||
}
|
||||
|
||||
//返回键
|
||||
function backPrevPage(url){
|
||||
window.location.hash = "ready";
|
||||
window.location.hash = "ok";
|
||||
setTimeout(function(){
|
||||
$(window).on('hashchange', function(e) {
|
||||
var hashName = window.location.hash.replace('#', '');
|
||||
hashName = hashName.split('&');
|
||||
if( hashName[0] == 'ready' ){
|
||||
location.href = url;
|
||||
}
|
||||
});
|
||||
},50);
|
||||
}
|
||||
|
||||
//图片切换
|
||||
WST.replaceImg = function(v,str){
|
||||
var vs = v.split('.');
|
||||
return v.replace("."+vs[1],str+"."+vs[1]);
|
||||
}
|
||||
|
||||
$(function(){
|
||||
echo.init();//图片懒加载
|
||||
// 滚动到顶部
|
||||
$(window).scroll(function(){
|
||||
if( $(window).scrollTop() > 200 ){
|
||||
$('#toTop').show();
|
||||
}else{
|
||||
$('#toTop').hide();
|
||||
}
|
||||
});
|
||||
$('#toTop').on('click', function() {
|
||||
timer=setInterval("WSTrunToTop()",1);
|
||||
});
|
||||
/**
|
||||
* 获取WSTMart基础配置
|
||||
* @type {object}
|
||||
*/
|
||||
WST.conf = window.conf;
|
||||
/* 基础对象检测 */
|
||||
WST.conf || $.error("WSTMart基础配置没有正确加载!");
|
||||
/**
|
||||
* 解析URL
|
||||
* @param {string} url 被解析的URL
|
||||
* @return {object} 解析后的数据
|
||||
*/
|
||||
WST.parse_url = function(url){
|
||||
var parse = url.match(/^(?:([a-z]+):\/\/)?([\w-]+(?:\.[\w-]+)+)?(?::(\d+))?([\w-\/]+)?(?:\?((?:\w+=[^#&=\/]*)?(?:&\w+=[^#&=\/]*)*))?(?:#([\w-]+))?$/i);
|
||||
parse || $.error("url格式不正确!");
|
||||
return {
|
||||
"scheme" : parse[1],
|
||||
"host" : parse[2],
|
||||
"port" : parse[3],
|
||||
"path" : parse[4],
|
||||
"query" : parse[5],
|
||||
"fragment" : parse[6]
|
||||
};
|
||||
}
|
||||
|
||||
WST.parse_str = function(str){
|
||||
var value = str.split("&"), vars = {}, param;
|
||||
for(var i=0;i<value.length;i++){
|
||||
param = value[i].split("=");
|
||||
vars[param[0]] = param[1];
|
||||
}
|
||||
return vars;
|
||||
}
|
||||
WST.U = function(url, vars){
|
||||
if(!url || url=='')return '';
|
||||
var info = this.parse_url(url), path = [], reg;
|
||||
/* 验证info */
|
||||
info.path || $.error("url格式错误!");
|
||||
url = info.path;
|
||||
/* 解析URL */
|
||||
path = url.split("/");
|
||||
path = [path.pop(), path.pop(), path.pop()].reverse();
|
||||
path[1] || $.error("WST.U(" + url + ")没有指定控制器");
|
||||
|
||||
/* 解析参数 */
|
||||
if(typeof vars === "string"){
|
||||
vars = this.parse_str(vars);
|
||||
}
|
||||
/* 解析URL自带的参数 */
|
||||
info.query && $.extend(vars, this.parse_str(info.query));
|
||||
if(false !== WST.conf.SUFFIX){
|
||||
url += "." + WST.conf.SUFFIX;
|
||||
}
|
||||
if($.isPlainObject(vars)){
|
||||
url += "?" + $.param(vars);
|
||||
}
|
||||
//url = url.replace(new RegExp("%2F","gm"),"+");
|
||||
url = WST.conf.APP + "/"+url;
|
||||
return url;
|
||||
}
|
||||
WST.AU = function(url, vars){
|
||||
if(!url || url=='')return '';
|
||||
var info = this.parse_url(url);
|
||||
url = info.path;
|
||||
path = url.split("/");
|
||||
url = "addon/";
|
||||
path = [path.pop(), path.pop()].reverse();
|
||||
path[0] || $.error("WST.AU(" + url + ")没有指定控制器");
|
||||
path[1] || $.error("WST.AU(" + url + ")没有指定接口");
|
||||
url = url + info.scheme + "-" + path.join('-');
|
||||
/* 解析参数 */
|
||||
if(typeof vars === "string"){
|
||||
vars = this.parse_str(vars);
|
||||
}
|
||||
info.query && $.extend(vars, this.parse_str(info.query));
|
||||
if(false !== WST.conf.SUFFIX){
|
||||
url += "." + WST.conf.SUFFIX;
|
||||
}
|
||||
if($.isPlainObject(vars)){
|
||||
url += "?" + $.param(vars);
|
||||
}
|
||||
return WST.conf.APP + "/"+url;
|
||||
}
|
||||
});
|
2
hyhproject/wechat2/view/default/js/echo.min.js
vendored
Executable file
2
hyhproject/wechat2/view/default/js/echo.min.js
vendored
Executable file
@ -0,0 +1,2 @@
|
||||
/*! echo.js v1.7.0 | (c) 2015 @toddmotto | https://github.com/toddmotto/echo */
|
||||
!function(t,e){"function"==typeof define&&define.amd?define(function(){return e(t)}):"object"==typeof exports?module.exports=e:t.echo=e(t)}(this,function(t){"use strict";var e,n,o,r,c,a={},d=function(){},u=function(t,e){var n=t.getBoundingClientRect();return n.right>=e.l&&n.bottom>=e.t&&n.left<=e.r&&n.top<=e.b},l=function(){(r||!n)&&(clearTimeout(n),n=setTimeout(function(){a.render(),n=null},o))};return a.init=function(n){n=n||{};var u=n.offset||0,i=n.offsetVertical||u,f=n.offsetHorizontal||u,s=function(t,e){return parseInt(t||e,10)};e={t:s(n.offsetTop,i),b:s(n.offsetBottom,i),l:s(n.offsetLeft,f),r:s(n.offsetRight,f)},o=s(n.throttle,250),r=n.debounce!==!1,c=!!n.unload,d=n.callback||d,a.render(),document.addEventListener?(t.addEventListener("scroll",l,!1),t.addEventListener("load",l,!1)):(t.attachEvent("onscroll",l),t.attachEvent("onload",l))},a.render=function(){for(var n,o,r=document.querySelectorAll("img[data-echo], [data-echo-background]"),l=r.length,i={l:0-e.l,t:0-e.t,b:(t.innerHeight||document.documentElement.clientHeight)+e.b,r:(t.innerWidth||document.documentElement.clientWidth)+e.r},f=0;l>f;f++)o=r[f],u(o,i)?(c&&o.setAttribute("data-echo-placeholder",o.src),null!==o.getAttribute("data-echo-background")?o.style.backgroundImage="url("+o.getAttribute("data-echo-background")+")":o.src=o.getAttribute("data-echo"),c||o.removeAttribute("data-echo"),d(o,"load")):c&&(n=o.getAttribute("data-echo-placeholder"))&&(null!==o.getAttribute("data-echo-background")?o.style.backgroundImage="url("+n+")":o.src=n,o.removeAttribute("data-echo-placeholder"),d(o,"unload"));l||a.detach()},a.detach=function(){document.removeEventListener?t.removeEventListener("scroll",l):t.detachEvent("onscroll",l),clearTimeout(n)},a});
|
41
hyhproject/wechat2/view/default/js/goods_category.js
Executable file
41
hyhproject/wechat2/view/default/js/goods_category.js
Executable file
@ -0,0 +1,41 @@
|
||||
jQuery.noConflict();
|
||||
function showRight(obj, index){
|
||||
$(obj).addClass('wst-goodscate_selected').siblings('#goodscate').removeClass('wst-goodscate_selected');
|
||||
jQuery('.goodscate1').eq(index).fadeIn(200).siblings('.goodscate1').hide();
|
||||
}
|
||||
//商品列表页
|
||||
function getGoodsList(goodsCatId){
|
||||
location.href = WST.U('wechat/goods/lists','catId='+goodsCatId);
|
||||
}
|
||||
//品牌-商品列表页
|
||||
function getBrandGoodsList(brandId){
|
||||
location.href = WST.U('wechat/goods/lists','brandId='+brandId);
|
||||
}
|
||||
//适应高度
|
||||
function selfAdapt(h){
|
||||
var o = document.getElementById('ui-scrollerl');
|
||||
var a = h-86;
|
||||
o.style.height=a+'px';
|
||||
}
|
||||
var height = WST.pageHeight();
|
||||
$(document).ready(function(){
|
||||
WST.initFooter('category');
|
||||
$('.wst-se-search').on('submit', '.input-form', function(event){
|
||||
event.preventDefault();
|
||||
})
|
||||
selfAdapt(height);
|
||||
$(window).scroll(function(event){
|
||||
var h = WST.pageHeight();
|
||||
selfAdapt(h);
|
||||
});
|
||||
var scroll = new fz.Scroll('.ui-scrollerl', {
|
||||
scrollY: true,
|
||||
slidingY: 'y'
|
||||
});
|
||||
var w = WST.pageWidth();
|
||||
var wImg=(w*0.76-30)/3;
|
||||
var hImg = wImg*9/14;
|
||||
$('.wst-gc-br img').css('height',hImg);
|
||||
var w = $('.goods-cat-img').width();
|
||||
$('.goods-cat-img').css('height',w);
|
||||
});
|
232
hyhproject/wechat2/view/default/js/goods_detail.js
Executable file
232
hyhproject/wechat2/view/default/js/goods_detail.js
Executable file
@ -0,0 +1,232 @@
|
||||
jQuery.noConflict();
|
||||
//切换
|
||||
function pageSwitch(obj,type){
|
||||
$(obj).addClass('active').siblings('.ui-tab-nav li.switch').removeClass('active');
|
||||
$('#goods'+type).show().siblings('section.ui-container').hide();
|
||||
if(type==1){
|
||||
var offsetTop = $("#goods1").offset().top;
|
||||
var scrollTop = $(window).scrollTop()-100;
|
||||
if (scrollTop > offsetTop){
|
||||
$("#goods-header").show();
|
||||
}else{
|
||||
$("#goods-header").hide();
|
||||
}
|
||||
}
|
||||
if(type==3){
|
||||
$("#goods-header").show();
|
||||
}
|
||||
}
|
||||
//商品评价列表
|
||||
function evaluateList(){
|
||||
loading = true;
|
||||
var param = {};
|
||||
param.goodsId = $('#goodsId').val();
|
||||
param.type = $('#evaluateType').val();
|
||||
param.pagesize = 10;
|
||||
param.page = Number( $('#currPage').val() ) + 1;
|
||||
$.post(WST.U('wechat/goodsappraises/getById'), param,function(data){
|
||||
var json = WST.toJson(data);
|
||||
$('#currPage').val(json.data.CurrentPage);
|
||||
$('#totalPage').val(json.data.TotalPage);
|
||||
var gettpl = document.getElementById('list').innerHTML;
|
||||
laytpl(gettpl).render(json.data.Rows, function(html){
|
||||
$('#evaluate-list').append(html);
|
||||
});
|
||||
loading = false;
|
||||
echo.init();//图片懒加载
|
||||
});
|
||||
}
|
||||
function evaluateSwitch(obj,type){
|
||||
$('#evaluateType').val(type);
|
||||
$(obj).addClass('active').siblings('.wst-ev-term .ui-col').removeClass('active');
|
||||
$('#currPage').val('0');
|
||||
$('#totalPage').val('0');
|
||||
$('#evaluate-list').html('');
|
||||
evaluateList();
|
||||
}
|
||||
var currPage = totalPage = 0;
|
||||
var loading = false;
|
||||
$(document).ready(function(){
|
||||
//商品图片
|
||||
new Swiper('.swiper-container', {
|
||||
slidesPerView: 1,
|
||||
spaceBetween: 0,
|
||||
grabCursor : true,
|
||||
autoplayDisableOnInteraction : true,
|
||||
pagination : '.swiper-pagination',
|
||||
paginationClickable :true
|
||||
});
|
||||
evaluateList();
|
||||
fixedHeader();
|
||||
WST.imgAdapt('j-imgAdapt');
|
||||
$(window).scroll(function(){
|
||||
if (loading) return;
|
||||
if ((5 + $(window).scrollTop()) >= ($(document).height() - screen.height)) {
|
||||
currPage = Number( $('#currPage').val() );
|
||||
totalPage = Number( $('#totalPage').val() );
|
||||
if( totalPage > 0 && currPage < totalPage ){
|
||||
evaluateList();
|
||||
}
|
||||
}
|
||||
});
|
||||
if(goodsInfo.sku){
|
||||
var specs,dv;
|
||||
for(var key in goodsInfo.sku){
|
||||
if(goodsInfo.sku[key].isDefault==1){
|
||||
specs = key.split(':');
|
||||
$('.j-option').each(function(){
|
||||
dv = $(this).attr('data-val')
|
||||
if($.inArray(dv,specs)>-1){
|
||||
$(this).addClass('active');
|
||||
}
|
||||
})
|
||||
$('#buyNum').attr('data-max',goodsInfo.sku[key].specStock);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$('#buyNum').attr('data-max',goodsInfo.goodsStock);
|
||||
}
|
||||
checkGoodsStock();
|
||||
//选择规格
|
||||
$('.spec .j-option').click(function(){
|
||||
$(this).addClass('active').siblings().removeClass('active');
|
||||
checkGoodsStock();
|
||||
});
|
||||
//弹框的高度
|
||||
var dataHeight = $("#frame").css('height');
|
||||
var cartHeight = parseInt($("#frame-cart").css('height'))+52+'px';
|
||||
if(parseInt(dataHeight)>230){
|
||||
$('#content').css('overflow-y','scroll').css('height','200');
|
||||
}
|
||||
if(parseInt(cartHeight)>420){
|
||||
$('#standard').css('overflow-y','scroll').css('height','260');
|
||||
}
|
||||
var dataHeight = $("#frame").css('height');
|
||||
var cartHeight = parseInt($("#frame-cart").css('height'))+52+'px';
|
||||
$("#frame").css('bottom','-'+dataHeight);
|
||||
$("#frame-cart").css('bottom','-'+cartHeight);
|
||||
});
|
||||
function checkGoodsStock(){
|
||||
var specIds = [],stock = 0,goodsPrice=0,marketPrice=0;
|
||||
if(goodsInfo.isSpec==1){
|
||||
$('.spec .active').each(function(){
|
||||
specIds.push(parseInt($(this).attr('data-val'),10));
|
||||
});
|
||||
specIds.sort(function(a,b){return a-b;});
|
||||
if(goodsInfo.sku[specIds.join(':')]){
|
||||
stock = goodsInfo.sku[specIds.join(':')].specStock;
|
||||
marketPrice = goodsInfo.sku[specIds.join(':')].marketPrice;
|
||||
goodsPrice = goodsInfo.sku[specIds.join(':')].specPrice;
|
||||
}
|
||||
}else{
|
||||
stock = goodsInfo.goodsStock;
|
||||
marketPrice = goodsInfo.marketPrice;
|
||||
goodsPrice = goodsInfo.goodsPrice;
|
||||
}
|
||||
$('#goods-stock').html(stock);
|
||||
$('#buyNum').attr('data-max',stock);
|
||||
$('#j-market-price').html('¥'+marketPrice);
|
||||
$('#j-shop-price').html('¥'+goodsPrice);
|
||||
if(stock<=0){
|
||||
$('#addBtn').addClass('disabled');
|
||||
$('#buyBtn').addClass('disabled');
|
||||
}else{
|
||||
$('#addBtn').removeClass('disabled');
|
||||
$('#buyBtn').removeClass('disabled');
|
||||
}
|
||||
}
|
||||
//导航
|
||||
function fixedHeader(){
|
||||
var offsetTop = $("#goods1").offset().top;
|
||||
$(window).scroll(function() {
|
||||
if($("#goods1").css("display")!='none'){
|
||||
var scrollTop = $(window).scrollTop()-100;
|
||||
if (scrollTop > offsetTop){
|
||||
$("#goods-header").show();
|
||||
}else{
|
||||
$("#goods-header").hide();
|
||||
}
|
||||
}else{
|
||||
$("#goods-header").show();
|
||||
}
|
||||
});
|
||||
}
|
||||
function inMore(){
|
||||
if($("#arrow").css("display")=='none'){
|
||||
jQuery('#arrow').show(200);
|
||||
$("#layer").show();
|
||||
}else{
|
||||
jQuery('#arrow').hide(100);
|
||||
$("#layer").hide();
|
||||
}
|
||||
}
|
||||
//弹框
|
||||
function dataShow(){
|
||||
jQuery('#cover').attr("onclick","javascript:dataHide();").show();
|
||||
jQuery('#frame').animate({"bottom": 0}, 500);
|
||||
}
|
||||
function dataHide(){
|
||||
var dataHeight = $("#frame").css('height');
|
||||
jQuery('#frame').animate({'bottom': '-'+dataHeight}, 500);
|
||||
jQuery('#cover').hide();
|
||||
}
|
||||
//弹框
|
||||
var type;
|
||||
function cartShow(t){
|
||||
type = t;
|
||||
jQuery('#cover').attr("onclick","javascript:cartHide();").show();
|
||||
jQuery('#frame-cart').animate({"bottom": 0}, 500);
|
||||
}
|
||||
function cartHide(){
|
||||
var cartHeight = parseInt($("#frame-cart").css('height'))+52+'px';
|
||||
jQuery('#frame-cart').animate({'bottom': '-'+cartHeight}, 500);
|
||||
jQuery('#cover').hide();
|
||||
}
|
||||
//加入购物车
|
||||
function addCart(){
|
||||
var goodsSpecId = 0;
|
||||
if(goodsInfo.isSpec==1){
|
||||
var specIds = [];
|
||||
$('.spec .active').each(function(){
|
||||
specIds.push($(this).attr('data-val'));
|
||||
});
|
||||
if(specIds.length==0){
|
||||
WST.msg('请选择你要购买的商品信息','info');
|
||||
}
|
||||
specIds.sort(function(a,b){return a-b;});
|
||||
if(goodsInfo.sku[specIds.join(':')]){
|
||||
goodsSpecId = goodsInfo.sku[specIds.join(':')].id;
|
||||
}
|
||||
}
|
||||
var goodsType = $("#goodsType").val();
|
||||
var buyNum = $("#buyNum").val()?$("#buyNum").val():1;
|
||||
$.post(WST.U('wechat/carts/addCart'),{goodsId:goodsInfo.id,goodsSpecId:goodsSpecId,buyNum:buyNum,type:type,rnd:Math.random()},function(data,textStatus){
|
||||
var json = WST.toJson(data);
|
||||
if(json.status==1){
|
||||
WST.msg(json.msg,'success');
|
||||
cartHide();
|
||||
if(type==1){
|
||||
setTimeout(function(){
|
||||
if(goodsType==1){
|
||||
location.href=WST.U('wechat/carts/'+json.data.forward);
|
||||
}else{
|
||||
location.href=WST.U('wechat/carts/settlement');
|
||||
}
|
||||
},1000);
|
||||
}else{
|
||||
if(json.cartNum>0)$("#cartNum").html('<span>'+json.cartNum+'</span>');
|
||||
}
|
||||
}else{
|
||||
WST.msg(json.msg,'info');
|
||||
}
|
||||
});
|
||||
}
|
||||
document.addEventListener('touchmove', function(event) {
|
||||
//阻止背景页面滚动,
|
||||
if(!jQuery("#cover").is(":hidden")){
|
||||
event.preventDefault();
|
||||
}
|
||||
if(!jQuery("#layer").is(":hidden")){
|
||||
event.preventDefault();
|
||||
}
|
||||
})
|
92
hyhproject/wechat2/view/default/js/goods_list.js
Executable file
92
hyhproject/wechat2/view/default/js/goods_list.js
Executable file
@ -0,0 +1,92 @@
|
||||
//排序条件
|
||||
function orderCondition(obj,condition){
|
||||
var classContent = $(obj).attr('class');
|
||||
var status = $(obj).attr('status');
|
||||
var theSiblings = $(obj).siblings('.sorts');
|
||||
theSiblings.removeClass('active').attr('status','down');
|
||||
$(obj).addClass('active');
|
||||
if(classContent.indexOf('active')==-1){
|
||||
$(obj).children('i').addClass('down2').removeClass('down');
|
||||
theSiblings.children('i').addClass('down').removeClass('down2');
|
||||
}
|
||||
if(status.indexOf('down')>-1){
|
||||
if(classContent.indexOf('active')==-1){
|
||||
$(obj).children('i').addClass('down2').removeClass('up2');
|
||||
$('#desc').val('0');
|
||||
}else{
|
||||
$(obj).children('i').addClass('up2').removeClass('down2');
|
||||
$(obj).attr('status','up');
|
||||
$('#desc').val('1');
|
||||
}
|
||||
}else{
|
||||
$(obj).children('i').addClass('down2').removeClass('up2');
|
||||
$(obj).attr('status','down');
|
||||
$('#desc').val('0');
|
||||
}
|
||||
$('#condition').val(condition);//排序条件
|
||||
$('#currPage').val('0');//当前页归零
|
||||
$('#goods-list').html('');
|
||||
goodsList();
|
||||
}
|
||||
//获取商品列表
|
||||
function goodsList(){
|
||||
$('#Load').show();
|
||||
loading = true;
|
||||
var param = {};
|
||||
param.catId = $('#catId').val();
|
||||
param.brandId = $('#brandId').val();
|
||||
param.condition = $('#condition').val();
|
||||
param.desc = $('#desc').val();
|
||||
param.keyword = $('#keyword').val();
|
||||
param.pagesize = 10;
|
||||
param.page = Number( $('#currPage').val() ) + 1;
|
||||
$.post(WST.U('wechat/goods/pageQuery'), param,function(data){
|
||||
var json = WST.toJson(data);
|
||||
$('#currPage').val(json.CurrentPage);
|
||||
$('#totalPage').val(json.TotalPage);
|
||||
var gettpl = document.getElementById('list').innerHTML;
|
||||
laytpl(gettpl).render(json.Rows, function(html){
|
||||
$('#goods-list').append(html);
|
||||
});
|
||||
WST.imgAdapt('j-imgAdapt');
|
||||
loading = false;
|
||||
$('#Load').hide();
|
||||
echo.init();//图片懒加载
|
||||
});
|
||||
}
|
||||
//切换
|
||||
function switchList(obj){
|
||||
if($('#goods-list').hasClass('wst-go-switch')){
|
||||
$(obj).removeClass('wst-se-icon2');
|
||||
$('#goods-list').removeClass('wst-go-switch');
|
||||
}else{
|
||||
$(obj).addClass('wst-se-icon2');
|
||||
$('#goods-list').addClass('wst-go-switch');
|
||||
}
|
||||
$('.j-imgAdapt').removeAttr('style');
|
||||
$('.j-imgAdapt a').removeAttr('style');
|
||||
$('.j-imgAdapt a img').removeAttr('style');
|
||||
$('#currPage').val('0');
|
||||
$('#goods-list').html('');
|
||||
goodsList();
|
||||
}
|
||||
var currPage = totalPage = 0;
|
||||
var loading = false;
|
||||
$(document).ready(function(){
|
||||
WST.initFooter('home');
|
||||
$('.wst-se-search').on('submit', '.input-form', function(event){
|
||||
event.preventDefault();
|
||||
})
|
||||
goodsList();
|
||||
$('.wst-gol-adsb').css('height',$('.j-imgRec').width()+20);
|
||||
$(window).scroll(function(){
|
||||
if (loading) return;
|
||||
if ((5 + $(window).scrollTop()) >= ($(document).height() - screen.height)) {
|
||||
currPage = Number( $('#currPage').val() );
|
||||
totalPage = Number( $('#totalPage').val() );
|
||||
if( totalPage > 0 && currPage < totalPage ){
|
||||
goodsList();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
124
hyhproject/wechat2/view/default/js/index.js
Executable file
124
hyhproject/wechat2/view/default/js/index.js
Executable file
@ -0,0 +1,124 @@
|
||||
//列表
|
||||
function indexList(){
|
||||
$('#Load').show();
|
||||
loading = true;
|
||||
var param = {};
|
||||
param.currPage = Number( $('#currPage').val() ) + 1;
|
||||
$.post(WST.U('wechat/index/pageQuery'), param,function(data){
|
||||
var json = WST.toJson(data);
|
||||
if(json && json.catId){
|
||||
$('#currPage').val(json.currPage);
|
||||
var gettpl = document.getElementById('list').innerHTML;
|
||||
laytpl(gettpl).render(json, function(html){
|
||||
$('#goods-list').append(html);
|
||||
});
|
||||
WST.imgAdapt('j-imgAdapt');
|
||||
}
|
||||
loading = false;
|
||||
$('#Load').hide();
|
||||
});
|
||||
}
|
||||
//商品列表页
|
||||
function getGoodsList(goodsCatId){
|
||||
location.href = WST.U('wechat/goods/lists','catId='+goodsCatId);
|
||||
}
|
||||
//关注
|
||||
function forFollow(){
|
||||
$("#wst-di-weixincode").dialog("show");
|
||||
}
|
||||
function closeFollow(){
|
||||
$.post(WST.U('wechat/index/closeFollow'), {},function(data){
|
||||
var json = WST.toJson(data);
|
||||
if(json.status==1){
|
||||
$('.wst-in-public').hide();
|
||||
$('.wst-in-header').removeClass('wst-in-change');
|
||||
$('.wst-in-search').removeClass('wst-in-change');
|
||||
}
|
||||
});
|
||||
}
|
||||
var currPage = 0;
|
||||
var loading = false;
|
||||
$(document).ready(function(){
|
||||
WST.initFooter('home');
|
||||
//搜索
|
||||
$(window).scroll(function(){
|
||||
if( $(window).scrollTop() > 42 ){
|
||||
$('#j-header').addClass('active');
|
||||
$('#j-searchs').addClass('active');
|
||||
}else{
|
||||
$('#j-header').removeClass('active');
|
||||
$('#j-searchs').removeClass('active');
|
||||
}
|
||||
});
|
||||
$('.wst-in-search').on('submit', '.input-form', function(event){
|
||||
event.preventDefault();
|
||||
})
|
||||
if($('.ui-slider li').hasClass("advert1")){
|
||||
//广告
|
||||
var slider = new fz.Scroll('.ui-slider', {
|
||||
role: 'slider',
|
||||
indicator: true,
|
||||
autoplay: true,
|
||||
interval: 3000
|
||||
});
|
||||
}else{
|
||||
$('.ui-slider').hide();
|
||||
}
|
||||
|
||||
//文章
|
||||
if($('.wst-in-news a').hasClass("words")){
|
||||
new Swiper('.swiper-container1', {
|
||||
slidesPerView: 1,
|
||||
freeMode : true,
|
||||
spaceBetween: 0,
|
||||
autoplay : 3800,
|
||||
speed:500,
|
||||
direction : 'vertical',
|
||||
loop : true,
|
||||
autoplayDisableOnInteraction : false,
|
||||
onlyExternal : true
|
||||
});
|
||||
}
|
||||
|
||||
var w = WST.pageWidth();
|
||||
//咨询上广告
|
||||
if($('.wst-in-activity a').hasClass("advert4")){
|
||||
}else{
|
||||
$('.wst-in-activity .advert4').hide();
|
||||
}
|
||||
//中间大广告
|
||||
if($('.wst-in-adst a').hasClass("advert2")){
|
||||
}else{
|
||||
$('.wst-in-adst').hide();
|
||||
}
|
||||
|
||||
//中间小广告
|
||||
if($('.wst-in-adsb a').hasClass("advert3")){
|
||||
new Swiper('.swiper-container2', {
|
||||
slidesPerView: 3,
|
||||
freeMode : true,
|
||||
spaceBetween: 0,
|
||||
autoplay : 2000,
|
||||
speed:1200,
|
||||
loop : true,
|
||||
autoplayDisableOnInteraction : false,
|
||||
onSlideChangeEnd: function(swiper){
|
||||
echo.init();//图片懒加载
|
||||
}
|
||||
});
|
||||
}else{
|
||||
$('.wst-in-adsb').hide();
|
||||
}
|
||||
|
||||
//刷新
|
||||
indexList();
|
||||
$(window).scroll(function(){
|
||||
if (loading) return;
|
||||
if (5 + ($(window).scrollTop()) >= ($(document).height() - screen.height)) {
|
||||
currPage = Number( $('#currPage').val() );
|
||||
if(currPage < 10 ){
|
||||
indexList();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
521
hyhproject/wechat2/view/default/js/izimodal/iziModal.js
Executable file
521
hyhproject/wechat2/view/default/js/izimodal/iziModal.js
Executable file
@ -0,0 +1,521 @@
|
||||
/*
|
||||
* iziModal | v1.0
|
||||
* http://izimodal.dolce.ninja
|
||||
* by Marcelo Dolce.
|
||||
* js修改过
|
||||
*/
|
||||
(function(jQuery){
|
||||
|
||||
"use strict";
|
||||
|
||||
var PLUGIN_NAME = 'iziModal';
|
||||
|
||||
var STATES = {
|
||||
CLOSING: 'closing',
|
||||
CLOSED: 'closed',
|
||||
OPENING: 'opening',
|
||||
OPENED: 'opened',
|
||||
DESTROYED: 'destroyed'
|
||||
};
|
||||
|
||||
function whichAnimationEvent(){
|
||||
var t,
|
||||
el = document.createElement("fakeelement");
|
||||
|
||||
var animations = {
|
||||
"animation" : "animationend",
|
||||
"OAnimation" : "oAnimationEnd",
|
||||
"MozAnimation" : "animationend",
|
||||
"WebkitAnimation": "webkitAnimationEnd"
|
||||
};
|
||||
for (t in animations){
|
||||
if (el.style[t] !== undefined){
|
||||
return animations[t];
|
||||
}
|
||||
}
|
||||
}
|
||||
var animationEvent = whichAnimationEvent();
|
||||
|
||||
var isMobile = false;
|
||||
if (/Mobi/.test(navigator.userAgent)) {
|
||||
isMobile = true;
|
||||
}
|
||||
|
||||
var iziModal = function (element, options) {
|
||||
this.init(element, options);
|
||||
};
|
||||
|
||||
iziModal.prototype = {
|
||||
|
||||
constructor: iziModal,
|
||||
|
||||
init: function (element, options) {
|
||||
|
||||
var that = this;
|
||||
|
||||
this.jQueryelement = jQuery(element);
|
||||
this.id = this.jQueryelement.attr('id');
|
||||
this.state = STATES.CLOSED;
|
||||
this.options = options;
|
||||
this.timer = null;
|
||||
this.headerHeight = 0;
|
||||
this.jQueryheader = jQuery('<div class="'+PLUGIN_NAME+'-header"><h1 class="'+PLUGIN_NAME+'-header-title">' + options.title + '</h1><p class="'+PLUGIN_NAME+'-header-subtitle">' + options.subtitle + '</p><a href="javascript:void(0)" class="'+PLUGIN_NAME+'-button-close" data-'+PLUGIN_NAME+'-close><i class="ui-icon-return"></i></a><div id="wst-switch"><div></div>');
|
||||
this.jQueryoverlay = jQuery('<div class="'+PLUGIN_NAME+'-overlay" style="background-color:'+options.overlayColor+'"></div>');
|
||||
|
||||
if (options.subtitle === '') {
|
||||
this.jQueryheader.addClass(PLUGIN_NAME+'-noSubtitle');
|
||||
}
|
||||
|
||||
if (options.iframe === true) {
|
||||
this.jQueryelement.html('<div class="'+PLUGIN_NAME+'-wrap"><div class="'+PLUGIN_NAME+'-content '+PLUGIN_NAME+'-content-loader"><iframe class="'+PLUGIN_NAME+'-iframe"></iframe>' + this.jQueryelement.html() + "</div></div>");
|
||||
|
||||
if (options.iframeHeight !== null) {
|
||||
this.jQueryelement.find('.'+PLUGIN_NAME+'-iframe').css('height', options.iframeHeight);
|
||||
}
|
||||
|
||||
} else {
|
||||
this.jQueryelement.html('<div class="'+PLUGIN_NAME+'-wrap"><div class="'+PLUGIN_NAME+'-content">' + this.jQueryelement.html() + '</div></div>');
|
||||
}
|
||||
|
||||
jQuery(document.body).find('style[rel='+this.id+']').remove();
|
||||
|
||||
if(typeof options.padding !== 'undefined' || options.padding !== 0)
|
||||
this.jQueryelement.find('.'+PLUGIN_NAME+'-content').css('padding', options.padding);
|
||||
|
||||
|
||||
if (options.title !== "" || options.subtitle !== "") {
|
||||
|
||||
if (options.headerColor !== null) {
|
||||
this.jQueryelement.css('border-bottom', '3px solid ' + options.headerColor + '');
|
||||
this.jQueryheader.css('background', this.options.headerColor);
|
||||
}
|
||||
if (options.iconClass !== null) {
|
||||
this.jQueryheader.prepend('<i class="'+PLUGIN_NAME+'-header-icon ' + options.iconClass + '"></i>');
|
||||
this.jQueryheader.find("."+PLUGIN_NAME+'-header-icon').css('color', options.iconColor);
|
||||
}
|
||||
this.jQueryelement.prepend(this.jQueryheader);
|
||||
}
|
||||
|
||||
var separators = /%|px|em|cm/,
|
||||
wClear = String(options.width).split(separators),
|
||||
w = String(options.width),
|
||||
medida = "px";
|
||||
wClear = String(wClear).split(",")[0];
|
||||
|
||||
if(isNaN(options.width)){
|
||||
if( String(options.width).indexOf("%") != -1){
|
||||
medida = "%";
|
||||
} else {
|
||||
medida = w.slice("-2");
|
||||
}
|
||||
}
|
||||
|
||||
this.jQueryelement.css({
|
||||
'margin-left': -(wClear / 2) + medida,
|
||||
'max-width': parseInt(wClear) + medida
|
||||
});
|
||||
|
||||
this.mediaQueries = '<style rel="' + this.id + '">@media handheld, only screen and (max-width: ' + wClear + 'px) { #' + this.jQueryelement[0].id + '{ width: 100% !important; max-width: 100% !important; margin-left: 0 !important; left: 0 !important; } }</style>';
|
||||
jQuery(document.body).append(this.mediaQueries);
|
||||
|
||||
// Adjusting horizontal positioning
|
||||
this.jQueryelement.addClass(PLUGIN_NAME + " " + options.theme);
|
||||
|
||||
// Adjusting vertical positioning
|
||||
this.jQueryelement.css('margin-top', parseInt(-(this.jQueryelement.innerHeight() / 2)) + 'px');
|
||||
|
||||
|
||||
if(this.jQueryelement.find('.'+PLUGIN_NAME+'-header').length){
|
||||
this.jQueryelement.css('overflow', 'hidden');
|
||||
}
|
||||
|
||||
// Close on overlay click
|
||||
this.jQueryoverlay.click(function () {
|
||||
if (that.options.overlayClose && !that.jQueryelement.hasClass(that.options.transitionOutModal)) {
|
||||
that.close();
|
||||
}
|
||||
});
|
||||
|
||||
// Close when button pressed
|
||||
this.jQueryelement.on('click', '[data-'+PLUGIN_NAME+'-close]', function (e) {
|
||||
e.preventDefault();
|
||||
that.close();
|
||||
});
|
||||
},
|
||||
|
||||
toggle: function () {
|
||||
|
||||
if(this.state == STATES.OPENED){
|
||||
this.close();
|
||||
}
|
||||
if(this.state == STATES.CLOSED){
|
||||
this.open();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
open: function (param) {
|
||||
|
||||
var that = this;
|
||||
|
||||
if (param && typeof(param) === "function") {
|
||||
param(that);
|
||||
}
|
||||
|
||||
if(this.options.iframe === true){
|
||||
|
||||
var href = null;
|
||||
if(this.options.iframeURL !== null){
|
||||
href = this.options.iframeURL;
|
||||
} else {
|
||||
try {
|
||||
href = param.target.href;
|
||||
if(href !== undefined){
|
||||
href = param.target.href;
|
||||
}
|
||||
} catch(e) {
|
||||
console.warn(e);
|
||||
}
|
||||
}
|
||||
this.jQueryelement.find('.'+PLUGIN_NAME+'-iframe').attr('src', href);
|
||||
}
|
||||
|
||||
this.jQueryelement.trigger(STATES.OPENING);
|
||||
this.state = STATES.OPENING;
|
||||
|
||||
console.info('[ '+PLUGIN_NAME+' | '+this.id+' ] Opening...');
|
||||
|
||||
if (this.options.bodyOverflow || isMobile){
|
||||
jQuery(document.body).css('overflow', 'hidden');
|
||||
}
|
||||
|
||||
that.options.onOpening.call(this);
|
||||
|
||||
function opened(){
|
||||
that.jQueryelement.trigger(STATES.OPENED);
|
||||
that.state = STATES.OPENED;
|
||||
|
||||
console.info('[ '+PLUGIN_NAME+' | '+that.id+' ] Opened.');
|
||||
|
||||
that.options.onOpened.call(this);
|
||||
}
|
||||
|
||||
this.jQueryoverlay.appendTo('body');
|
||||
|
||||
if (this.options.transitionInOverlay) {
|
||||
this.jQueryoverlay.addClass(this.options.transitionInOverlay);
|
||||
}
|
||||
|
||||
if (this.options.transitionInModal !== '') {
|
||||
|
||||
this.jQueryelement.addClass(this.options.transitionInModal).show();
|
||||
|
||||
this.jQueryelement.find('.'+PLUGIN_NAME+'-wrap').one(animationEvent, function () {
|
||||
|
||||
that.jQueryelement.removeClass(that.options.transitionInModal);
|
||||
that.jQueryoverlay.removeClass(that.options.transitionInOverlay);
|
||||
|
||||
opened();
|
||||
});
|
||||
|
||||
} else {
|
||||
this.jQueryelement.show();
|
||||
opened();
|
||||
}
|
||||
|
||||
if (that.options.focusInput){
|
||||
that.jQueryelement.find(':input:not(button):enabled:visible:first').focus(); // Focus on the first field
|
||||
}
|
||||
|
||||
(function updateTimer(){
|
||||
that.recalculateLayout();
|
||||
that.timer = setTimeout(updateTimer, 500);
|
||||
})();
|
||||
|
||||
// Close when the Escape key is pressed
|
||||
jQuery(document).keydown(function (e) {
|
||||
if (that.options.closeOnEscape && e.keyCode === 27) {
|
||||
that.close();
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
close: function (param) {
|
||||
|
||||
var that = this;
|
||||
|
||||
if (param && typeof(param) === "function") {
|
||||
param(that);
|
||||
}
|
||||
|
||||
jQuery(document).off("keydown");
|
||||
|
||||
this.state = STATES.CLOSING;
|
||||
this.jQueryelement.trigger(STATES.CLOSING);
|
||||
console.info('[ '+PLUGIN_NAME+' | '+this.id+' ] Closing...');
|
||||
|
||||
clearTimeout(that.timer);
|
||||
|
||||
that.options.onClosing.call(this);
|
||||
|
||||
function closed(){
|
||||
|
||||
if (that.options.iframe === true) {
|
||||
that.jQueryelement.find('.'+PLUGIN_NAME+'-iframe').attr('src', "");
|
||||
}
|
||||
|
||||
if (that.options.bodyOverflow || isMobile){
|
||||
jQuery(document.body).css('overflow', 'initial');
|
||||
}
|
||||
|
||||
jQuery(document.body).removeClass(PLUGIN_NAME+'-attached');
|
||||
|
||||
that.jQueryelement.trigger(STATES.CLOSED);
|
||||
that.state = STATES.CLOSED;
|
||||
|
||||
console.info('[ '+PLUGIN_NAME+' | '+that.id+' ] Closed.');
|
||||
|
||||
that.options.onClosed.call(this);
|
||||
}
|
||||
|
||||
if (this.options.transitionOutModal !== '') {
|
||||
|
||||
//this.jQueryelement.removeClass(this.options.transitionInModal).addClass(this.options.transitionOutModal);
|
||||
//this.jQueryoverlay.removeClass(this.options.transitionInOverlay).addClass(this.options.transitionOutOverlay);
|
||||
|
||||
this.jQueryelement.attr('class', PLUGIN_NAME + " " + this.options.theme + " " + this.options.transitionOutModal);
|
||||
this.jQueryoverlay.attr('class', PLUGIN_NAME + "-overlay " + this.options.transitionOutOverlay);
|
||||
|
||||
this.jQueryelement.one(animationEvent, function () {
|
||||
|
||||
if( that.jQueryelement.hasClass(that.options.transitionOutModal) ){
|
||||
|
||||
that.jQueryelement.removeClass(that.options.transitionOutModal).hide();
|
||||
that.jQueryoverlay.removeClass(that.options.transitionOutOverlay).remove();
|
||||
|
||||
closed();
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.jQueryelement.hide();
|
||||
this.jQueryoverlay.remove();
|
||||
|
||||
closed();
|
||||
}
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
var e = jQuery.Event('destroy');
|
||||
|
||||
this.jQueryelement.trigger(e);
|
||||
|
||||
jQuery(document).off("keydown");
|
||||
|
||||
clearTimeout(this.timer);
|
||||
|
||||
if (this.options.iframe === true) {
|
||||
this.jQueryelement.find('.'+PLUGIN_NAME+'-iframe').remove();
|
||||
}
|
||||
this.jQueryelement.html(this.jQueryelement.find('.'+PLUGIN_NAME+'-content').html());
|
||||
|
||||
jQuery(document.body).find('style[rel='+this.id+']').remove();
|
||||
|
||||
this.jQueryelement.off('click', '[data-'+PLUGIN_NAME+'-close]');
|
||||
|
||||
this.jQueryelement
|
||||
.off('.'+PLUGIN_NAME)
|
||||
.removeData(PLUGIN_NAME)
|
||||
.attr('style', '');
|
||||
|
||||
this.jQueryoverlay.remove();
|
||||
this.jQueryelement.trigger(STATES.DESTROYED);
|
||||
this.jQueryelement = null;
|
||||
},
|
||||
|
||||
getState: function(){
|
||||
|
||||
console.info(this.state);
|
||||
|
||||
return this.state;
|
||||
},
|
||||
|
||||
setTitle: function(title){
|
||||
|
||||
if (this.options.title !== null) {
|
||||
|
||||
this.jQueryheader.find('.'+PLUGIN_NAME+'-header-title').html(title);
|
||||
|
||||
this.options.title = title;
|
||||
}
|
||||
},
|
||||
|
||||
setSubtitle: function(subtitle){
|
||||
|
||||
if (this.options.subtitle !== null) {
|
||||
|
||||
this.jQueryheader.find('.'+PLUGIN_NAME+'-header-subtitle').html(subtitle);
|
||||
|
||||
this.options.subtitle = subtitle;
|
||||
}
|
||||
},
|
||||
|
||||
setIconClass: function(iconClass){
|
||||
|
||||
if (this.options.iconClass !== null) {
|
||||
|
||||
this.jQueryheader.find('.'+PLUGIN_NAME+'-header-icon').attr('class', PLUGIN_NAME+'-header-icon ' + iconClass);
|
||||
|
||||
this.options.iconClass = iconClass;
|
||||
}
|
||||
},
|
||||
|
||||
setHeaderColor: function(headerColor){
|
||||
|
||||
if (this.options.headerColor !== null) {
|
||||
this.jQueryelement.css('border-bottom', '3px solid ' + headerColor + '');
|
||||
this.jQueryheader.css('background', headerColor);
|
||||
|
||||
this.options.headerColor = headerColor;
|
||||
}
|
||||
},
|
||||
|
||||
startLoading: function(){
|
||||
if( !this.jQueryelement.find('.'+PLUGIN_NAME+'-loader').length ){
|
||||
this.jQueryelement.append('<div class="'+PLUGIN_NAME+'-loader '+this.options.transitionInOverlay+'"></div>');
|
||||
}
|
||||
},
|
||||
|
||||
stopLoading: function(){
|
||||
var that = this;
|
||||
this.jQueryelement.find('.'+PLUGIN_NAME+'-loader').removeClass(this.options.transitionInOverlay).addClass(this.options.transitionOutOverlay);
|
||||
this.jQueryelement.find('.'+PLUGIN_NAME+'-loader').one(animationEvent, function () {
|
||||
that.jQueryelement.find('.'+PLUGIN_NAME+'-loader').removeClass(that.options.transitionOutOverlay).remove();
|
||||
});
|
||||
},
|
||||
|
||||
recalculateLayout: function(){
|
||||
|
||||
if(this.jQueryelement.find('.'+PLUGIN_NAME+'-header').length){
|
||||
this.headerHeight = parseInt(this.jQueryelement.find('.'+PLUGIN_NAME+'-header').innerHeight()) + 2/*border bottom of modal*/;
|
||||
this.jQueryelement.css('overflow', 'hidden');
|
||||
}
|
||||
|
||||
var windowHeight = jQuery(window).height(),
|
||||
contentHeight = this.jQueryelement.find('.'+PLUGIN_NAME+'-content')[0].scrollHeight,
|
||||
modalMargin = parseInt(-((this.jQueryelement.innerHeight() + 1) / 2)) + 'px';
|
||||
|
||||
if(this.state == STATES.OPENED || this.state == STATES.OPENING){
|
||||
|
||||
if (this.options.iframe === true) {
|
||||
|
||||
// Se a altura da janela é menor que o modal com iframe
|
||||
if(windowHeight < (this.options.iframeHeight + this.headerHeight)){
|
||||
|
||||
jQuery(document.body).addClass(PLUGIN_NAME+'-attached');
|
||||
|
||||
this.jQueryelement.find('.'+PLUGIN_NAME+'-iframe').css({
|
||||
'height': parseInt(windowHeight - this.headerHeight) + 'px',
|
||||
});
|
||||
|
||||
} else {
|
||||
jQuery(document.body).removeClass(PLUGIN_NAME+'-attached');
|
||||
|
||||
this.jQueryelement.find('.'+PLUGIN_NAME+'-iframe').css({
|
||||
'height': parseInt(this.options.iframeHeight) + 'px',
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (windowHeight > (contentHeight + this.headerHeight)) {
|
||||
jQuery(document.body).removeClass(PLUGIN_NAME+'-attached');
|
||||
//内部窗口高;
|
||||
var screenHeight=window.innerHeight-45
|
||||
|| document.documentElement.clientHeight
|
||||
|| document.body.clientHeight;
|
||||
this.jQueryelement.find('.'+PLUGIN_NAME+'-wrap').css({'height': screenHeight+'px'});
|
||||
}
|
||||
|
||||
if (this.jQueryelement.innerHeight() > windowHeight || this.jQueryelement.innerHeight() < contentHeight) {
|
||||
jQuery(document.body).addClass(PLUGIN_NAME+'-attached');
|
||||
|
||||
this.jQueryelement.find('.'+PLUGIN_NAME+'-wrap').css({
|
||||
'height': parseInt(windowHeight - this.headerHeight) + 'px',
|
||||
});
|
||||
}
|
||||
|
||||
var scrollTop = this.jQueryelement.find('.'+PLUGIN_NAME+'-wrap').scrollTop(),
|
||||
internoHeight = this.jQueryelement.find('.'+PLUGIN_NAME+'-content').innerHeight(),
|
||||
externoHeight = this.jQueryelement.find('.'+PLUGIN_NAME+'-wrap').innerHeight();
|
||||
/*
|
||||
if ((externoHeight + scrollTop) < (internoHeight - 50)) {
|
||||
this.jQueryelement.addClass('hasScroll');
|
||||
} else {
|
||||
this.jQueryelement.removeClass('hasScroll');
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
// Corrige margin-top caso o modal sofra alterações na altura de seu conteúdo
|
||||
if (this.jQueryelement.css('margin-top') != modalMargin && this.jQueryelement.css('margin-top') != "0px") {
|
||||
// this.jQueryelement.css('margin-top', modalMargin);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
jQuery.fn[PLUGIN_NAME] = function (option, args) {
|
||||
return this.each(function () {
|
||||
var jQuerythis = jQuery(this),
|
||||
data = jQuerythis.data(PLUGIN_NAME),
|
||||
options = jQuery.extend({}, jQuery.fn.iziModal.defaults, jQuerythis.data(), typeof option == 'object' && option);
|
||||
|
||||
if (!data && (!option || typeof option == 'object')){
|
||||
jQuerythis.data(PLUGIN_NAME, (data = new iziModal(this, options)));
|
||||
}
|
||||
if (typeof option == 'string' && typeof data != 'undefined'){
|
||||
data[option].apply(data, [].concat(args));
|
||||
}
|
||||
else if (options.autoOpen){ // Automatically open the modal if autoOpen setted true
|
||||
data.open();
|
||||
}
|
||||
});
|
||||
};
|
||||
//内部窗口宽
|
||||
var screenWidth=window.innerWidth
|
||||
|| document.documentElement.clientWidth
|
||||
|| document.body.clientWidth;
|
||||
jQuery.fn[PLUGIN_NAME].defaults = {
|
||||
title: "",
|
||||
subtitle: "",
|
||||
theme: "",
|
||||
headerColor: "#88A0B9",
|
||||
overlayColor: "rgba(0, 0, 0, 0.4)",
|
||||
iconColor: "",
|
||||
iconClass: null,
|
||||
width: screenWidth,
|
||||
padding: 0,
|
||||
iframe: false,
|
||||
iframeHeight: 400,
|
||||
iframeURL: null,
|
||||
overlayClose: true,
|
||||
closeOnEscape: true,
|
||||
bodyOverflow: false,
|
||||
focusInput: true,
|
||||
autoOpen: false,
|
||||
transitionInModal: 'transitionIn',
|
||||
transitionOutModal: 'transitionOut',
|
||||
transitionInOverlay: 'fadeIn',
|
||||
transitionOutOverlay: 'fadeOut',
|
||||
onOpening: function() {},
|
||||
onOpened: function() {},
|
||||
onClosing: function() {},
|
||||
onClosed: function() {}
|
||||
};
|
||||
|
||||
jQuery.fn[PLUGIN_NAME].Constructor = iziModal;
|
||||
|
||||
}).call(this, window.jQuery);
|
2
hyhproject/wechat2/view/default/js/jquery.min.js
vendored
Executable file
2
hyhproject/wechat2/view/default/js/jquery.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
9
hyhproject/wechat2/view/default/js/laytpl/laytpl.js
Executable file
9
hyhproject/wechat2/view/default/js/laytpl/laytpl.js
Executable file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
|
||||
@Name:laytpl-v1.1 精妙的js模板引擎
|
||||
@Author:贤心 - 2014-08-16
|
||||
@Site:http://sentsin.com/layui/laytpl
|
||||
@License:MIT license
|
||||
*/
|
||||
|
||||
;!function(){"use strict";var f,b={open:"{{",close:"}}"},c={exp:function(a){return new RegExp(a,"g")},query:function(a,c,e){var f=["#([\\s\\S])+?","([^{#}])*?"][a||0];return d((c||"")+b.open+f+b.close+(e||""))},escape:function(a){return String(a||"").replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""")},error:function(a,b){var c="Laytpl Error:";return"object"==typeof console&&console.error(c+a+"\n"+(b||"")),c+a}},d=c.exp,e=function(a){this.tpl=a};e.pt=e.prototype,e.pt.parse=function(a,e){var f=this,g=a,h=d("^"+b.open+"#",""),i=d(b.close+"$","");a=a.replace(/[\r\t\n]/g," ").replace(d(b.open+"#"),b.open+"# ").replace(d(b.close+"}"),"} "+b.close).replace(/\\/g,"\\\\").replace(/(?="|')/g,"\\").replace(c.query(),function(a){return a=a.replace(h,"").replace(i,""),'";'+a.replace(/\\/g,"")+'; view+="'}).replace(c.query(1),function(a){var c='"+(';return a.replace(/\s/g,"")===b.open+b.close?"":(a=a.replace(d(b.open+"|"+b.close),""),/^=/.test(a)&&(a=a.replace(/^=/,""),c='"+_escape_('),c+a.replace(/\\/g,"")+')+"')}),a='"use strict";var view = "'+a+'";return view;';try{return f.cache=a=new Function("d, _escape_",a),a(e,c.escape)}catch(j){return delete f.cache,c.error(j,g)}},e.pt.render=function(a,b){var e,d=this;return a?(e=d.cache?d.cache(a,c.escape):d.parse(d.tpl,a),b?(b(e),void 0):e):c.error("no data")},f=function(a){return"string"!=typeof a?c.error("Template not found"):new e(a)},f.config=function(a){a=a||{};for(var c in a)b[c]=a[c]},f.v="1.1","function"==typeof define?define(function(){return f}):"undefined"!=typeof exports?module.exports=f:window.laytpl=f}();
|
230
hyhproject/wechat2/view/default/js/login.js
Executable file
230
hyhproject/wechat2/view/default/js/login.js
Executable file
@ -0,0 +1,230 @@
|
||||
jQuery.noConflict();
|
||||
function inChoice(n){
|
||||
if(n==1){
|
||||
$('#login-w').html('登录');
|
||||
}else{
|
||||
$('#login-w').html('注册新账号');
|
||||
}
|
||||
WST.showHide('','#choice');
|
||||
WST.showHide(1,'#login'+n+',#return');
|
||||
}
|
||||
function inReturn(){
|
||||
$('#login-w').html('登录账号');
|
||||
WST.showHide('','#login0,#login1,#return');
|
||||
WST.showHide(1,'#choice');
|
||||
}
|
||||
function login(){
|
||||
var loginName = $('#loginName').val();
|
||||
var loginPwd = $('#loginPwd').val();
|
||||
var loginVerfy = $('#loginVerfy').val();
|
||||
if(loginName==''){
|
||||
WST.msg('请输入账号','info');
|
||||
return false;
|
||||
}
|
||||
if(loginPwd==''){
|
||||
WST.msg('请输入密码','info');
|
||||
return false;
|
||||
}
|
||||
if(loginVerfy==''){
|
||||
WST.msg('请输入验证码','info');
|
||||
return false;
|
||||
}
|
||||
if(window.conf.IS_CRYPTPWD==1){
|
||||
var public_key=$('#key').val();
|
||||
var exponent="10001";
|
||||
var rsa = new RSAKey();
|
||||
rsa.setPublic(public_key, exponent);
|
||||
var loginPwd = rsa.encrypt(loginPwd);
|
||||
}
|
||||
WST.load('登录中···');
|
||||
var param = {};
|
||||
param.loginName = loginName;
|
||||
param.loginPwd = loginPwd;
|
||||
param.verifyCode = loginVerfy;
|
||||
$('#loginButton').addClass("active").attr('disabled', 'disabled');
|
||||
$.post(WST.U('wechat/users/checkLogin'), param, function(data){
|
||||
var json = WST.toJson(data);
|
||||
if( json.status == 1 ){
|
||||
WST.msg(json.msg,'success');
|
||||
var url = json.url;
|
||||
setTimeout(function(){
|
||||
if(WST.blank(url)){
|
||||
location.href = url;
|
||||
}else{
|
||||
location.href = WST.U('wechat/users/index');
|
||||
}
|
||||
},2000);
|
||||
}else{
|
||||
WST.msg(json.msg,'warn');
|
||||
WST.getVerify("#verifyImg1");
|
||||
$('#loginButton').removeAttr('disabled').removeClass("active");
|
||||
}
|
||||
WST.noload();
|
||||
data = json = null;
|
||||
});
|
||||
}
|
||||
var nameType = 3;
|
||||
function onTesting(obj){
|
||||
//不能输入中文
|
||||
WST.isChinese(obj,1);
|
||||
var data = $(obj).val();
|
||||
var regMobile = /^0?1[3|4|5|8][0-9]\d{8}$/;
|
||||
if(regMobile.test(data)){//手机
|
||||
$.post(WST.U('wechat/users/checkUserPhone'), {userPhone:data}, function(data){
|
||||
var json = WST.toJson(data);
|
||||
if( json.status == 1 ){
|
||||
}else{
|
||||
var dia=$.dialog({
|
||||
title:'',
|
||||
content:'<p style="text-align: center;">手机号已注册</p>',
|
||||
button:["确认"]
|
||||
});
|
||||
}
|
||||
data = json = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
function register(){
|
||||
var regName = $('#regName').val();
|
||||
var regPwd = $('#regPwd').val();
|
||||
var regcoPwd = $('#regcoPwd').val();
|
||||
var regVerfy = $('#regVerfy').val();
|
||||
var phoneCode = $('#phoneCode').val();
|
||||
var param = {};
|
||||
if($('#defaults').hasClass('ui-icon-unchecked-s')){
|
||||
WST.msg('请阅读用户注册协议','info');
|
||||
return false;
|
||||
}
|
||||
if(regName==''){
|
||||
WST.msg('请输入账号','info');
|
||||
return false;
|
||||
}
|
||||
if(regName.length < 6){
|
||||
WST.msg('账号为6位以上数字或字母','info');
|
||||
return false;
|
||||
}
|
||||
if(regPwd==''){
|
||||
WST.msg('请输入密码','info');
|
||||
return false;
|
||||
}
|
||||
if(regPwd.length < 6 || regPwd.length > 16){
|
||||
WST.msg('请输入密码为6-16位字符','info');
|
||||
return false;
|
||||
}
|
||||
if(regcoPwd==''){
|
||||
WST.msg('确认密码不能为空','info');
|
||||
return false;
|
||||
}
|
||||
if(regPwd!=regcoPwd){
|
||||
WST.msg('确认密码不一致','info');
|
||||
return false;
|
||||
}
|
||||
if(phoneCode==''){
|
||||
WST.msg('请输入短信验证码','info');
|
||||
return false;
|
||||
}
|
||||
param.mobileCode = phoneCode;
|
||||
if(window.conf.IS_CRYPTPWD==1){
|
||||
var public_key=$('#key').val();
|
||||
var exponent="10001";
|
||||
var rsa = new RSAKey();
|
||||
rsa.setPublic(public_key, exponent);
|
||||
var regcoPwd = rsa.encrypt(regcoPwd);
|
||||
var regPwd = rsa.encrypt(regPwd);
|
||||
}
|
||||
WST.load('注册中···');
|
||||
param.nameType = nameType;
|
||||
param.loginName = regName;
|
||||
param.loginPwd = regcoPwd;
|
||||
param.reUserPwd = regPwd;
|
||||
$('#regButton').addClass("active").attr('disabled', 'disabled');
|
||||
$.post(WST.U('wechat/users/register'), param, function(data){
|
||||
var json = WST.toJson(data);
|
||||
if( json.status == 1 ){
|
||||
WST.msg(json.msg,'success');
|
||||
var url = json.url;
|
||||
setTimeout(function(){
|
||||
if(WST.blank(url)){
|
||||
location.href = url;
|
||||
}else{
|
||||
location.href = WST.U('wechat/users/index');
|
||||
}
|
||||
},2000);
|
||||
}else{
|
||||
WST.msg(json.msg,'warn');
|
||||
WST.getVerify("#verifyImg0");
|
||||
$('#regButton').removeAttr('disabled').removeClass("active");
|
||||
}
|
||||
WST.noload();
|
||||
data = json = null;
|
||||
});
|
||||
}
|
||||
var time = 0;
|
||||
var isSend = false;
|
||||
function obtainCode(){
|
||||
var userPhone = $('#regName').val();
|
||||
if(userPhone ==''){
|
||||
WST.msg('请输入帐号为手机号码','info');
|
||||
$('#userPhone').focus();
|
||||
return false;
|
||||
}
|
||||
if(WST.conf.SMS_VERFY==1){
|
||||
var smsVerfy = $('#smsVerfy').val();
|
||||
if(smsVerfy ==''){
|
||||
WST.msg('请输入验证码','info');
|
||||
$('#smsVerfy').focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var param = {};
|
||||
param.userPhone = userPhone;
|
||||
param.smsVerfy = smsVerfy;
|
||||
if(isSend)return;
|
||||
isSend = true;
|
||||
$.post(WST.U('wechat/users/getPhoneVerifyCode'), param, function(data){
|
||||
var json = WST.toJson(data);
|
||||
if( json.status == 1 ){
|
||||
WST.msg(json.msg,'success');
|
||||
time = 120;
|
||||
$('#obtain').attr('disabled', 'disabled').html('120秒获取');
|
||||
var task = setInterval(function(){
|
||||
time--;
|
||||
$('#obtain').html(''+time+"秒获取");
|
||||
if(time==0){
|
||||
isSend = false;
|
||||
clearInterval(task);
|
||||
$('#obtain').removeAttr('disabled').html("重新发送");
|
||||
}
|
||||
},1000);
|
||||
}else{
|
||||
WST.msg(json.msg,'warn');
|
||||
WST.getVerify("#verifyImg3");
|
||||
isSend = false;
|
||||
}
|
||||
data = json = null;
|
||||
});
|
||||
}
|
||||
//弹框
|
||||
function wholeShow(type){
|
||||
jQuery('#'+type).animate({"right": 0}, 500);
|
||||
}
|
||||
function wholeHide(type){
|
||||
var dataWidth = $('#'+type).css('width');
|
||||
jQuery('#'+type).animate({'right': '-'+dataWidth}, 500);
|
||||
}
|
||||
//协议
|
||||
function inAgree(obj){
|
||||
if($('#defaults').hasClass('wst-active')){
|
||||
$(obj).addClass('ui-icon-unchecked-s');
|
||||
$(obj).removeClass('ui-icon-success-block wst-active');
|
||||
}else{
|
||||
$(obj).removeClass('ui-icon-unchecked-s');
|
||||
$(obj).addClass('ui-icon-success-block wst-active');
|
||||
}
|
||||
}
|
||||
$(document).ready(function(){
|
||||
var w = WST.pageWidth();
|
||||
var h = WST.pageHeight();
|
||||
$('#protocol .content').css('overflow-y','scroll').css('height',h-61);
|
||||
$("#protocol").css('right',-w);
|
||||
});
|
2463
hyhproject/wechat2/view/default/js/photoclip/hammer.js
Executable file
2463
hyhproject/wechat2/view/default/js/photoclip/hammer.js
Executable file
File diff suppressed because it is too large
Load Diff
2197
hyhproject/wechat2/view/default/js/photoclip/iscroll-zoom.js
Executable file
2197
hyhproject/wechat2/view/default/js/photoclip/iscroll-zoom.js
Executable file
File diff suppressed because it is too large
Load Diff
3
hyhproject/wechat2/view/default/js/photoclip/jquery.photoClip.min.js
vendored
Executable file
3
hyhproject/wechat2/view/default/js/photoclip/jquery.photoClip.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
104
hyhproject/wechat2/view/default/js/photoclip/upload.hpictures.js
Executable file
104
hyhproject/wechat2/view/default/js/photoclip/upload.hpictures.js
Executable file
@ -0,0 +1,104 @@
|
||||
jQuery.noConflict();
|
||||
//关闭图片上传区
|
||||
function closeUploadArea(){
|
||||
var data='#upload_close,#upload_button,#upload_modal';
|
||||
var data2='.return_users,.useri_info,#useri_info,#footer';
|
||||
WST.showHide('',data);
|
||||
WST.showHide(1,data2);
|
||||
//清空图片上传区的内容
|
||||
$('#clipArea').find('img').remove();
|
||||
$('#file').val('');
|
||||
$('#view').css('background-image','');
|
||||
$('#imgData').val('');
|
||||
}
|
||||
jQuery('#uploadImg').on('change', function() {
|
||||
var data='.return_users,.useri_info,#useri_info,#footer';
|
||||
var data2='#upload_close,#upload_button,#upload_modal';
|
||||
WST.showHide('',data);
|
||||
WST.showHide(1,data2);
|
||||
});
|
||||
//头像上传
|
||||
jQuery("#clipArea").photoClip({
|
||||
width: 350,
|
||||
height: 350,
|
||||
file: "#uploadImg",
|
||||
view: "#view",
|
||||
ok: "#upload_button",
|
||||
loadStart: function() {
|
||||
$('#Load').show();
|
||||
},
|
||||
loadComplete: function() {
|
||||
$('#Load').hide();
|
||||
},
|
||||
clipFinish: function(dataURL) {
|
||||
jQuery('#imgData').val(dataURL);
|
||||
var imgData = $('#imgData').val();
|
||||
if(!imgData || imgData==''){
|
||||
WST.msg('请先选择图片','info');
|
||||
return false;
|
||||
}
|
||||
// 上传裁剪好的图片
|
||||
funUploadFile(dataURL);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @param base64Codes
|
||||
* 图片的base64编码
|
||||
*/
|
||||
funUploadFile=function(base64Codes){
|
||||
var self = this;
|
||||
var formData = new FormData();
|
||||
//convertBase64UrlToBlob函数是将base64编码转换为Blob
|
||||
//append函数的第一个参数是后台获取数据的参数名,在php中用$FILES['imageName']接收,
|
||||
var imgSuffix = base64Codes.split(";")[0].split('/')[1];
|
||||
formData.append("imageName",self.convertBase64UrlToBlob(base64Codes),"image."+imgSuffix);
|
||||
//ajax 提交form
|
||||
$.ajax({
|
||||
// 你后台的接收地址
|
||||
url : WST.U('wechat/users/uploadPic',{'dir':'users','isTumb':1}),
|
||||
type : "POST",
|
||||
data : formData,
|
||||
dataType:"json",
|
||||
processData : false, // 告诉jQuery不要去处理发送的数据
|
||||
contentType : false, // 告诉jQuery不要去设置Content-Type请求头
|
||||
success:function(data){
|
||||
var json = WST.toJson(data);
|
||||
if(json.status==1){
|
||||
$.post(WST.U('wechat/users/editUserInfo'), {userPhoto:json.savePath+json.name}, function(data){
|
||||
if(json.status==1){
|
||||
WST.msg('修改头像成功','success');
|
||||
jQuery('#imgurl').attr('src', WST.conf.ROOT +'/'+json.savePath+'/'+json.name);
|
||||
}else{
|
||||
WST.msg('修改头像失败,请重试','warn');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}else{
|
||||
WST.msg(json.msg,'warn');
|
||||
}
|
||||
closeUploadArea();
|
||||
$('#Load').hide();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 将以base64的图片url数据转换为Blob
|
||||
* @param urlData
|
||||
* 用url方式表示的base64图片数据
|
||||
*/
|
||||
convertBase64UrlToBlob=function(urlData){
|
||||
//去掉url的头,并转换为byte
|
||||
var bytes=window.atob(urlData.split(',')[1]);
|
||||
//处理异常,将ascii码小于0的转换为大于0
|
||||
var ab = new ArrayBuffer(bytes.length);
|
||||
var ia = new Uint8Array(ab);
|
||||
for (var i = 0; i < bytes.length; i++) {
|
||||
ia[i] = bytes.charCodeAt(i);
|
||||
}
|
||||
// 此处type注意与photoClip初始化中的outputType类型保持一致
|
||||
return new Blob( [ab] , {type : 'image/jpeg'});
|
||||
}
|
88
hyhproject/wechat2/view/default/js/qrcode.js
Executable file
88
hyhproject/wechat2/view/default/js/qrcode.js
Executable file
@ -0,0 +1,88 @@
|
||||
|
||||
var qrcode=function(){var qrcode=function(typeNumber,errorCorrectLevel){var PAD0=0xEC;var PAD1=0x11;var _typeNumber=typeNumber;var _errorCorrectLevel=QRErrorCorrectLevel[errorCorrectLevel];var _modules=null;var _moduleCount=0;var _dataCache=null;var _dataList=new Array();var _this={};var makeImpl=function(test,maskPattern){_moduleCount=_typeNumber*4+17;_modules=function(moduleCount){var modules=new Array(moduleCount);for(var row=0;row<moduleCount;row+=1){modules[row]=new Array(moduleCount);for(var col=0;col<moduleCount;col+=1){modules[row][col]=null;}}
|
||||
return modules;}(_moduleCount);setupPositionProbePattern(0,0);setupPositionProbePattern(_moduleCount-7,0);setupPositionProbePattern(0,_moduleCount-7);setupPositionAdjustPattern();setupTimingPattern();setupTypeInfo(test,maskPattern);if(_typeNumber>=7){setupTypeNumber(test);}
|
||||
if(_dataCache==null){_dataCache=createData(_typeNumber,_errorCorrectLevel,_dataList);}
|
||||
mapData(_dataCache,maskPattern);};var setupPositionProbePattern=function(row,col){for(var r=-1;r<=7;r+=1){if(row+r<=-1||_moduleCount<=row+r)continue;for(var c=-1;c<=7;c+=1){if(col+c<=-1||_moduleCount<=col+c)continue;if((0<=r&&r<=6&&(c==0||c==6))||(0<=c&&c<=6&&(r==0||r==6))||(2<=r&&r<=4&&2<=c&&c<=4)){_modules[row+r][col+c]=true;}else{_modules[row+r][col+c]=false;}}}};var getBestMaskPattern=function(){var minLostPoint=0;var pattern=0;for(var i=0;i<8;i+=1){makeImpl(true,i);var lostPoint=QRUtil.getLostPoint(_this);if(i==0||minLostPoint>lostPoint){minLostPoint=lostPoint;pattern=i;}}
|
||||
return pattern;};var setupTimingPattern=function(){for(var r=8;r<_moduleCount-8;r+=1){if(_modules[r][6]!=null){continue;}
|
||||
_modules[r][6]=(r%2==0);}
|
||||
for(var c=8;c<_moduleCount-8;c+=1){if(_modules[6][c]!=null){continue;}
|
||||
_modules[6][c]=(c%2==0);}};var setupPositionAdjustPattern=function(){var pos=QRUtil.getPatternPosition(_typeNumber);for(var i=0;i<pos.length;i+=1){for(var j=0;j<pos.length;j+=1){var row=pos[i];var col=pos[j];if(_modules[row][col]!=null){continue;}
|
||||
for(var r=-2;r<=2;r+=1){for(var c=-2;c<=2;c+=1){if(r==-2||r==2||c==-2||c==2||(r==0&&c==0)){_modules[row+r][col+c]=true;}else{_modules[row+r][col+c]=false;}}}}}};var setupTypeNumber=function(test){var bits=QRUtil.getBCHTypeNumber(_typeNumber);for(var i=0;i<18;i+=1){var mod=(!test&&((bits>>i)&1)==1);_modules[Math.floor(i/3)][i%3+_moduleCount-8-3]=mod;}
|
||||
for(var i=0;i<18;i+=1){var mod=(!test&&((bits>>i)&1)==1);_modules[i%3+_moduleCount-8-3][Math.floor(i/3)]=mod;}};var setupTypeInfo=function(test,maskPattern){var data=(_errorCorrectLevel<<3)|maskPattern;var bits=QRUtil.getBCHTypeInfo(data);for(var i=0;i<15;i+=1){var mod=(!test&&((bits>>i)&1)==1);if(i<6){_modules[i][8]=mod;}else if(i<8){_modules[i+1][8]=mod;}else{_modules[_moduleCount-15+i][8]=mod;}}
|
||||
for(var i=0;i<15;i+=1){var mod=(!test&&((bits>>i)&1)==1);if(i<8){_modules[8][_moduleCount-i-1]=mod;}else if(i<9){_modules[8][15-i-1+1]=mod;}else{_modules[8][15-i-1]=mod;}}
|
||||
_modules[_moduleCount-8][8]=(!test);};var mapData=function(data,maskPattern){var inc=-1;var row=_moduleCount-1;var bitIndex=7;var byteIndex=0;var maskFunc=QRUtil.getMaskFunction(maskPattern);for(var col=_moduleCount-1;col>0;col-=2){if(col==6)col-=1;while(true){for(var c=0;c<2;c+=1){if(_modules[row][col-c]==null){var dark=false;if(byteIndex<data.length){dark=(((data[byteIndex]>>>bitIndex)&1)==1);}
|
||||
var mask=maskFunc(row,col-c);if(mask){dark=!dark;}
|
||||
_modules[row][col-c]=dark;bitIndex-=1;if(bitIndex==-1){byteIndex+=1;bitIndex=7;}}}
|
||||
row+=inc;if(row<0||_moduleCount<=row){row-=inc;inc=-inc;break;}}}};var createBytes=function(buffer,rsBlocks){var offset=0;var maxDcCount=0;var maxEcCount=0;var dcdata=new Array(rsBlocks.length);var ecdata=new Array(rsBlocks.length);for(var r=0;r<rsBlocks.length;r+=1){var dcCount=rsBlocks[r].dataCount;var ecCount=rsBlocks[r].totalCount-dcCount;maxDcCount=Math.max(maxDcCount,dcCount);maxEcCount=Math.max(maxEcCount,ecCount);dcdata[r]=new Array(dcCount);for(var i=0;i<dcdata[r].length;i+=1){dcdata[r][i]=0xff&buffer.getBuffer()[i+offset];}
|
||||
offset+=dcCount;var rsPoly=QRUtil.getErrorCorrectPolynomial(ecCount);var rawPoly=qrPolynomial(dcdata[r],rsPoly.getLength()-1);var modPoly=rawPoly.mod(rsPoly);ecdata[r]=new Array(rsPoly.getLength()-1);for(var i=0;i<ecdata[r].length;i+=1){var modIndex=i+modPoly.getLength()-ecdata[r].length;ecdata[r][i]=(modIndex>=0)?modPoly.getAt(modIndex):0;}}
|
||||
var totalCodeCount=0;for(var i=0;i<rsBlocks.length;i+=1){totalCodeCount+=rsBlocks[i].totalCount;}
|
||||
var data=new Array(totalCodeCount);var index=0;for(var i=0;i<maxDcCount;i+=1){for(var r=0;r<rsBlocks.length;r+=1){if(i<dcdata[r].length){data[index]=dcdata[r][i];index+=1;}}}
|
||||
for(var i=0;i<maxEcCount;i+=1){for(var r=0;r<rsBlocks.length;r+=1){if(i<ecdata[r].length){data[index]=ecdata[r][i];index+=1;}}}
|
||||
return data;};var createData=function(typeNumber,errorCorrectLevel,dataList){var rsBlocks=QRRSBlock.getRSBlocks(typeNumber,errorCorrectLevel);var buffer=qrBitBuffer();for(var i=0;i<dataList.length;i+=1){var data=dataList[i];buffer.put(data.getMode(),4);buffer.put(data.getLength(),QRUtil.getLengthInBits(data.getMode(),typeNumber));data.write(buffer);}
|
||||
var totalDataCount=0;for(var i=0;i<rsBlocks.length;i+=1){totalDataCount+=rsBlocks[i].dataCount;}
|
||||
if(buffer.getLengthInBits()>totalDataCount*8){throw new Error('code length overflow. ('
|
||||
+buffer.getLengthInBits()
|
||||
+'>'
|
||||
+totalDataCount*8
|
||||
+')');}
|
||||
if(buffer.getLengthInBits()+4<=totalDataCount*8){buffer.put(0,4);}
|
||||
while(buffer.getLengthInBits()%8!=0){buffer.putBit(false);}
|
||||
while(true){if(buffer.getLengthInBits()>=totalDataCount*8){break;}
|
||||
buffer.put(PAD0,8);if(buffer.getLengthInBits()>=totalDataCount*8){break;}
|
||||
buffer.put(PAD1,8);}
|
||||
return createBytes(buffer,rsBlocks);};_this.addData=function(data){var newData=qr8BitByte(data);_dataList.push(newData);_dataCache=null;};_this.isDark=function(row,col){if(row<0||_moduleCount<=row||col<0||_moduleCount<=col){throw new Error(row+','+col);}
|
||||
return _modules[row][col];};_this.getModuleCount=function(){return _moduleCount;};_this.make=function(){makeImpl(false,getBestMaskPattern());};_this.createTableTag=function(cellSize,margin){cellSize=cellSize||2;margin=(typeof margin=='undefined')?cellSize*4:margin;var qrHtml='';qrHtml+='<table style="';qrHtml+=' border-width: 0px; border-style: none;';qrHtml+=' border-collapse: collapse;';qrHtml+=' padding: 0px; margin: '+margin+'px;';qrHtml+='">';qrHtml+='<tbody>';for(var r=0;r<_this.getModuleCount();r+=1){qrHtml+='<tr>';for(var c=0;c<_this.getModuleCount();c+=1){qrHtml+='<td style="';qrHtml+=' border-width: 0px; border-style: none;';qrHtml+=' border-collapse: collapse;';qrHtml+=' padding: 0px; margin: 0px;';qrHtml+=' width: '+cellSize+'px;';qrHtml+=' height: '+cellSize+'px;';qrHtml+=' background-color: ';qrHtml+=_this.isDark(r,c)?'#000000':'#ffffff';qrHtml+=';';qrHtml+='"/>';}
|
||||
qrHtml+='</tr>';}
|
||||
qrHtml+='</tbody>';qrHtml+='</table>';return qrHtml;};_this.createImgTag=function(cellSize,margin){cellSize=cellSize||2;margin=(typeof margin=='undefined')?cellSize*4:margin;var size=_this.getModuleCount()*cellSize+margin*2;var min=margin;var max=size-margin;return createImgTag(size,size,function(x,y){if(min<=x&&x<max&&min<=y&&y<max){var c=Math.floor((x-min)/cellSize);var r=Math.floor((y-min)/cellSize);return _this.isDark(r,c)?0:1;}else{return 1;}});};return _this;};qrcode.stringToBytes=function(s){var bytes=new Array();for(var i=0;i<s.length;i+=1){var c=s.charCodeAt(i);bytes.push(c&0xff);}
|
||||
return bytes;};qrcode.createStringToBytes=function(unicodeData,numChars){var unicodeMap=function(){var bin=base64DecodeInputStream(unicodeData);var read=function(){var b=bin.read();if(b==-1)throw new Error();return b;};var count=0;var unicodeMap={};while(true){var b0=bin.read();if(b0==-1)break;var b1=read();var b2=read();var b3=read();var k=String.fromCharCode((b0<<8)|b1);var v=(b2<<8)|b3;unicodeMap[k]=v;count+=1;}
|
||||
if(count!=numChars){throw new Error(count+' != '+numChars);}
|
||||
return unicodeMap;}();var unknownChar='?'.charCodeAt(0);return function(s){var bytes=new Array();for(var i=0;i<s.length;i+=1){var c=s.charCodeAt(i);if(c<128){bytes.push(c);}else{var b=unicodeMap[s.charAt(i)];if(typeof b=='number'){if((b&0xff)==b){bytes.push(b);}else{bytes.push(b>>>8);bytes.push(b&0xff);}}else{bytes.push(unknownChar);}}}
|
||||
return bytes;};};var QRMode={MODE_NUMBER:1<<0,MODE_ALPHA_NUM:1<<1,MODE_8BIT_BYTE:1<<2,MODE_KANJI:1<<3};var QRErrorCorrectLevel={L:1,M:0,Q:3,H:2};var QRMaskPattern={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var QRUtil=function(){var PATTERN_POSITION_TABLE=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]];var G15=(1<<10)|(1<<8)|(1<<5)|(1<<4)|(1<<2)|(1<<1)|(1<<0);var G18=(1<<12)|(1<<11)|(1<<10)|(1<<9)|(1<<8)|(1<<5)|(1<<2)|(1<<0);var G15_MASK=(1<<14)|(1<<12)|(1<<10)|(1<<4)|(1<<1);var _this={};var getBCHDigit=function(data){var digit=0;while(data!=0){digit+=1;data>>>=1;}
|
||||
return digit;};_this.getBCHTypeInfo=function(data){var d=data<<10;while(getBCHDigit(d)-getBCHDigit(G15)>=0){d^=(G15<<(getBCHDigit(d)-getBCHDigit(G15)));}
|
||||
return((data<<10)|d)^G15_MASK;};_this.getBCHTypeNumber=function(data){var d=data<<12;while(getBCHDigit(d)-getBCHDigit(G18)>=0){d^=(G18<<(getBCHDigit(d)-getBCHDigit(G18)));}
|
||||
return(data<<12)|d;};_this.getPatternPosition=function(typeNumber){return PATTERN_POSITION_TABLE[typeNumber-1];};_this.getMaskFunction=function(maskPattern){switch(maskPattern){case QRMaskPattern.PATTERN000:return function(i,j){return(i+j)%2==0;};case QRMaskPattern.PATTERN001:return function(i,j){return i%2==0;};case QRMaskPattern.PATTERN010:return function(i,j){return j%3==0;};case QRMaskPattern.PATTERN011:return function(i,j){return(i+j)%3==0;};case QRMaskPattern.PATTERN100:return function(i,j){return(Math.floor(i/2)+Math.floor(j/3))%2==0;};case QRMaskPattern.PATTERN101:return function(i,j){return(i*j)%2+(i*j)%3==0;};case QRMaskPattern.PATTERN110:return function(i,j){return((i*j)%2+(i*j)%3)%2==0;};case QRMaskPattern.PATTERN111:return function(i,j){return((i*j)%3+(i+j)%2)%2==0;};default:throw new Error('bad maskPattern:'+maskPattern);}};_this.getErrorCorrectPolynomial=function(errorCorrectLength){var a=qrPolynomial([1],0);for(var i=0;i<errorCorrectLength;i+=1){a=a.multiply(qrPolynomial([1,QRMath.gexp(i)],0));}
|
||||
return a;};_this.getLengthInBits=function(mode,type){if(1<=type&&type<10){switch(mode){case QRMode.MODE_NUMBER:return 10;case QRMode.MODE_ALPHA_NUM:return 9;case QRMode.MODE_8BIT_BYTE:return 8;case QRMode.MODE_KANJI:return 8;default:throw new Error('mode:'+mode);}}else if(type<27){switch(mode){case QRMode.MODE_NUMBER:return 12;case QRMode.MODE_ALPHA_NUM:return 11;case QRMode.MODE_8BIT_BYTE:return 16;case QRMode.MODE_KANJI:return 10;default:throw new Error('mode:'+mode);}}else if(type<41){switch(mode){case QRMode.MODE_NUMBER:return 14;case QRMode.MODE_ALPHA_NUM:return 13;case QRMode.MODE_8BIT_BYTE:return 16;case QRMode.MODE_KANJI:return 12;default:throw new Error('mode:'+mode);}}else{throw new Error('type:'+type);}};_this.getLostPoint=function(qrcode){var moduleCount=qrcode.getModuleCount();var lostPoint=0;for(var row=0;row<moduleCount;row+=1){for(var col=0;col<moduleCount;col+=1){var sameCount=0;var dark=qrcode.isDark(row,col);for(var r=-1;r<=1;r+=1){if(row+r<0||moduleCount<=row+r){continue;}
|
||||
for(var c=-1;c<=1;c+=1){if(col+c<0||moduleCount<=col+c){continue;}
|
||||
if(r==0&&c==0){continue;}
|
||||
if(dark==qrcode.isDark(row+r,col+c)){sameCount+=1;}}}
|
||||
if(sameCount>5){lostPoint+=(3+sameCount-5);}}};for(var row=0;row<moduleCount-1;row+=1){for(var col=0;col<moduleCount-1;col+=1){var count=0;if(qrcode.isDark(row,col))count+=1;if(qrcode.isDark(row+1,col))count+=1;if(qrcode.isDark(row,col+1))count+=1;if(qrcode.isDark(row+1,col+1))count+=1;if(count==0||count==4){lostPoint+=3;}}}
|
||||
for(var row=0;row<moduleCount;row+=1){for(var col=0;col<moduleCount-6;col+=1){if(qrcode.isDark(row,col)&&!qrcode.isDark(row,col+1)&&qrcode.isDark(row,col+2)&&qrcode.isDark(row,col+3)&&qrcode.isDark(row,col+4)&&!qrcode.isDark(row,col+5)&&qrcode.isDark(row,col+6)){lostPoint+=40;}}}
|
||||
for(var col=0;col<moduleCount;col+=1){for(var row=0;row<moduleCount-6;row+=1){if(qrcode.isDark(row,col)&&!qrcode.isDark(row+1,col)&&qrcode.isDark(row+2,col)&&qrcode.isDark(row+3,col)&&qrcode.isDark(row+4,col)&&!qrcode.isDark(row+5,col)&&qrcode.isDark(row+6,col)){lostPoint+=40;}}}
|
||||
var darkCount=0;for(var col=0;col<moduleCount;col+=1){for(var row=0;row<moduleCount;row+=1){if(qrcode.isDark(row,col)){darkCount+=1;}}}
|
||||
var ratio=Math.abs(100*darkCount/moduleCount/moduleCount-50)/5;lostPoint+=ratio*10;return lostPoint;};return _this;}();var QRMath=function(){var EXP_TABLE=new Array(256);var LOG_TABLE=new Array(256);for(var i=0;i<8;i+=1){EXP_TABLE[i]=1<<i;}
|
||||
for(var i=8;i<256;i+=1){EXP_TABLE[i]=EXP_TABLE[i-4]^EXP_TABLE[i-5]^EXP_TABLE[i-6]^EXP_TABLE[i-8];}
|
||||
for(var i=0;i<255;i+=1){LOG_TABLE[EXP_TABLE[i]]=i;}
|
||||
var _this={};_this.glog=function(n){if(n<1){throw new Error('glog('+n+')');}
|
||||
return LOG_TABLE[n];};_this.gexp=function(n){while(n<0){n+=255;}
|
||||
while(n>=256){n-=255;}
|
||||
return EXP_TABLE[n];};return _this;}();function qrPolynomial(num,shift){if(typeof num.length=='undefined'){throw new Error(num.length+'/'+shift);}
|
||||
var _num=function(){var offset=0;while(offset<num.length&&num[offset]==0){offset+=1;}
|
||||
var _num=new Array(num.length-offset+shift);for(var i=0;i<num.length-offset;i+=1){_num[i]=num[i+offset];}
|
||||
return _num;}();var _this={};_this.getAt=function(index){return _num[index];};_this.getLength=function(){return _num.length;};_this.multiply=function(e){var num=new Array(_this.getLength()+e.getLength()-1);for(var i=0;i<_this.getLength();i+=1){for(var j=0;j<e.getLength();j+=1){num[i+j]^=QRMath.gexp(QRMath.glog(_this.getAt(i))+QRMath.glog(e.getAt(j)));}}
|
||||
return qrPolynomial(num,0);};_this.mod=function(e){if(_this.getLength()-e.getLength()<0){return _this;}
|
||||
var ratio=QRMath.glog(_this.getAt(0))-QRMath.glog(e.getAt(0));var num=new Array(_this.getLength());for(var i=0;i<_this.getLength();i+=1){num[i]=_this.getAt(i);}
|
||||
for(var i=0;i<e.getLength();i+=1){num[i]^=QRMath.gexp(QRMath.glog(e.getAt(i))+ratio);}
|
||||
return qrPolynomial(num,0).mod(e);};return _this;};var QRRSBlock=function(){var RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16]];var qrRSBlock=function(totalCount,dataCount){var _this={};_this.totalCount=totalCount;_this.dataCount=dataCount;return _this;};var _this={};var getRsBlockTable=function(typeNumber,errorCorrectLevel){switch(errorCorrectLevel){case QRErrorCorrectLevel.L:return RS_BLOCK_TABLE[(typeNumber-1)*4+0];case QRErrorCorrectLevel.M:return RS_BLOCK_TABLE[(typeNumber-1)*4+1];case QRErrorCorrectLevel.Q:return RS_BLOCK_TABLE[(typeNumber-1)*4+2];case QRErrorCorrectLevel.H:return RS_BLOCK_TABLE[(typeNumber-1)*4+3];default:return undefined;}};_this.getRSBlocks=function(typeNumber,errorCorrectLevel){var rsBlock=getRsBlockTable(typeNumber,errorCorrectLevel);if(typeof rsBlock=='undefined'){throw new Error('bad rs block @ typeNumber:'+typeNumber+'/errorCorrectLevel:'+errorCorrectLevel);}
|
||||
var length=rsBlock.length/3;var list=new Array();for(var i=0;i<length;i+=1){var count=rsBlock[i*3+0];var totalCount=rsBlock[i*3+1];var dataCount=rsBlock[i*3+2];for(var j=0;j<count;j+=1){list.push(qrRSBlock(totalCount,dataCount));}}
|
||||
return list;};return _this;}();var qrBitBuffer=function(){var _buffer=new Array();var _length=0;var _this={};_this.getBuffer=function(){return _buffer;};_this.getAt=function(index){var bufIndex=Math.floor(index/8);return((_buffer[bufIndex]>>>(7-index%8))&1)==1;};_this.put=function(num,length){for(var i=0;i<length;i+=1){_this.putBit(((num>>>(length-i-1))&1)==1);}};_this.getLengthInBits=function(){return _length;};_this.putBit=function(bit){var bufIndex=Math.floor(_length/8);if(_buffer.length<=bufIndex){_buffer.push(0);}
|
||||
if(bit){_buffer[bufIndex]|=(0x80>>>(_length%8));}
|
||||
_length+=1;};return _this;};var qr8BitByte=function(data){var _mode=QRMode.MODE_8BIT_BYTE;var _data=data;var _bytes=qrcode.stringToBytes(data);var _this={};_this.getMode=function(){return _mode;};_this.getLength=function(buffer){return _bytes.length;};_this.write=function(buffer){for(var i=0;i<_bytes.length;i+=1){buffer.put(_bytes[i],8);}};return _this;};var byteArrayOutputStream=function(){var _bytes=new Array();var _this={};_this.writeByte=function(b){_bytes.push(b&0xff);};_this.writeShort=function(i){_this.writeByte(i);_this.writeByte(i>>>8);};_this.writeBytes=function(b,off,len){off=off||0;len=len||b.length;for(var i=0;i<len;i+=1){_this.writeByte(b[i+off]);}};_this.writeString=function(s){for(var i=0;i<s.length;i+=1){_this.writeByte(s.charCodeAt(i));}};_this.toByteArray=function(){return _bytes;};_this.toString=function(){var s='';s+='[';for(var i=0;i<_bytes.length;i+=1){if(i>0){s+=',';}
|
||||
s+=_bytes[i];}
|
||||
s+=']';return s;};return _this;};var base64EncodeOutputStream=function(){var _buffer=0;var _buflen=0;var _length=0;var _base64='';var _this={};var writeEncoded=function(b){_base64+=String.fromCharCode(encode(b&0x3f));};var encode=function(n){if(n<0){}else if(n<26){return 0x41+n;}else if(n<52){return 0x61+(n-26);}else if(n<62){return 0x30+(n-52);}else if(n==62){return 0x2b;}else if(n==63){return 0x2f;}
|
||||
throw new Error('n:'+n);};_this.writeByte=function(n){_buffer=(_buffer<<8)|(n&0xff);_buflen+=8;_length+=1;while(_buflen>=6){writeEncoded(_buffer>>>(_buflen-6));_buflen-=6;}};_this.flush=function(){if(_buflen>0){writeEncoded(_buffer<<(6-_buflen));_buffer=0;_buflen=0;}
|
||||
if(_length%3!=0){var padlen=3-_length%3;for(var i=0;i<padlen;i+=1){_base64+='=';}}};_this.toString=function(){return _base64;};return _this;};var base64DecodeInputStream=function(str){var _str=str;var _pos=0;var _buffer=0;var _buflen=0;var _this={};_this.read=function(){while(_buflen<8){if(_pos>=_str.length){if(_buflen==0){return-1;}
|
||||
throw new Error('unexpected end of file./'+_buflen);}
|
||||
var c=_str.charAt(_pos);_pos+=1;if(c=='='){_buflen=0;return-1;}else if(c.match(/^\s$/)){continue;}
|
||||
_buffer=(_buffer<<6)|decode(c.charCodeAt(0));_buflen+=6;}
|
||||
var n=(_buffer>>>(_buflen-8))&0xff;_buflen-=8;return n;};var decode=function(c){if(0x41<=c&&c<=0x5a){return c-0x41;}else if(0x61<=c&&c<=0x7a){return c-0x61+26;}else if(0x30<=c&&c<=0x39){return c-0x30+52;}else if(c==0x2b){return 62;}else if(c==0x2f){return 63;}else{throw new Error('c:'+c);}};return _this;};var gifImage=function(width,height){var _width=width;var _height=height;var _data=new Array(width*height);var _this={};_this.setPixel=function(x,y,pixel){_data[y*_width+x]=pixel;};_this.write=function(out){out.writeString('GIF87a');out.writeShort(_width);out.writeShort(_height);out.writeByte(0x80);out.writeByte(0);out.writeByte(0);out.writeByte(0x00);out.writeByte(0x00);out.writeByte(0x00);out.writeByte(0xff);out.writeByte(0xff);out.writeByte(0xff);out.writeString(',');out.writeShort(0);out.writeShort(0);out.writeShort(_width);out.writeShort(_height);out.writeByte(0);var lzwMinCodeSize=2;var raster=getLZWRaster(lzwMinCodeSize);out.writeByte(lzwMinCodeSize);var offset=0;while(raster.length-offset>255){out.writeByte(255);out.writeBytes(raster,offset,255);offset+=255;}
|
||||
out.writeByte(raster.length-offset);out.writeBytes(raster,offset,raster.length-offset);out.writeByte(0x00);out.writeString(';');};var bitOutputStream=function(out){var _out=out;var _bitLength=0;var _bitBuffer=0;var _this={};_this.write=function(data,length){if((data>>>length)!=0){throw new Error('length over');}
|
||||
while(_bitLength+length>=8){_out.writeByte(0xff&((data<<_bitLength)|_bitBuffer));length-=(8-_bitLength);data>>>=(8-_bitLength);_bitBuffer=0;_bitLength=0;}
|
||||
_bitBuffer=(data<<_bitLength)|_bitBuffer;_bitLength=_bitLength+length;};_this.flush=function(){if(_bitLength>0){_out.writeByte(_bitBuffer);}};return _this;};var getLZWRaster=function(lzwMinCodeSize){var clearCode=1<<lzwMinCodeSize;var endCode=(1<<lzwMinCodeSize)+1;var bitLength=lzwMinCodeSize+1;var table=lzwTable();for(var i=0;i<clearCode;i+=1){table.add(String.fromCharCode(i));}
|
||||
table.add(String.fromCharCode(clearCode));table.add(String.fromCharCode(endCode));var byteOut=byteArrayOutputStream();var bitOut=bitOutputStream(byteOut);bitOut.write(clearCode,bitLength);var dataIndex=0;var s=String.fromCharCode(_data[dataIndex]);dataIndex+=1;while(dataIndex<_data.length){var c=String.fromCharCode(_data[dataIndex]);dataIndex+=1;if(table.contains(s+c)){s=s+c;}else{bitOut.write(table.indexOf(s),bitLength);if(table.size()<0xfff){if(table.size()==(1<<bitLength)){bitLength+=1;}
|
||||
table.add(s+c);}
|
||||
s=c;}}
|
||||
bitOut.write(table.indexOf(s),bitLength);bitOut.write(endCode,bitLength);bitOut.flush();return byteOut.toByteArray();};var lzwTable=function(){var _map={};var _size=0;var _this={};_this.add=function(key){if(_this.contains(key)){throw new Error('dup key:'+key);}
|
||||
_map[key]=_size;_size+=1;};_this.size=function(){return _size;};_this.indexOf=function(key){return _map[key];};_this.contains=function(key){return typeof _map[key]!='undefined';};return _this;};return _this;};var createImgTag=function(width,height,getPixel,alt){var gif=gifImage(width,height);for(var y=0;y<height;y+=1){for(var x=0;x<width;x+=1){gif.setPixel(x,y,getPixel(x,y));}}
|
||||
var b=byteArrayOutputStream();gif.write(b);var base64=base64EncodeOutputStream();var bytes=b.toByteArray();for(var i=0;i<bytes.length;i+=1){base64.writeByte(bytes[i]);}
|
||||
base64.flush();var img='';img+='<img';img+='\u0020src="';img+='data:image/gif;base64,';img+=base64;img+='"';img+='\u0020width="';img+=width;img+='"';img+='\u0020height="';img+=height;img+='"';if(alt){img+='\u0020alt="';img+=alt;img+='"';}
|
||||
img+='/>';return img;};return qrcode;}();/* |xGv00|ca8fc6bde81a353e7cede123b304bdb9 */
|
108
hyhproject/wechat2/view/default/js/self_shop.js
Executable file
108
hyhproject/wechat2/view/default/js/self_shop.js
Executable file
@ -0,0 +1,108 @@
|
||||
jQuery.noConflict();
|
||||
var loading = false;
|
||||
$(function(){
|
||||
$('.wst-se-search').on('submit', '.input-form', function(event){
|
||||
event.preventDefault();
|
||||
})
|
||||
// 加载商品列表
|
||||
shopsList();
|
||||
// 商家推荐
|
||||
new Swiper('.swiper-container', {
|
||||
slidesPerView: 4,
|
||||
freeMode : true,
|
||||
spaceBetween: 0,
|
||||
autoplay : 2000,
|
||||
speed:1200,
|
||||
loop : false,
|
||||
autoplayDisableOnInteraction : false,
|
||||
onSlideChangeEnd: function(swiper){
|
||||
echo.init();//图片懒加载
|
||||
}
|
||||
});
|
||||
// 推荐
|
||||
WST.imgAdapt('j-imgRec');
|
||||
// 热卖
|
||||
WST.imgAdapt('j-imgRec1');
|
||||
$('.wst-gol-adsb').css('height',$('.j-imgRec').width()+20);
|
||||
// 商品分类
|
||||
var h = WST.pageHeight();
|
||||
var dataHeight = $("#frame").css('height');
|
||||
if(parseInt(dataHeight)>h-42){
|
||||
$('#content').css('overflow-y','scroll').css('height',h-42);
|
||||
}
|
||||
$(window).scroll(function(){
|
||||
if (loading) return;
|
||||
if (($(window).scrollTop()) >= ($(document).height() - screen.height)) {
|
||||
shopsList();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//弹框
|
||||
function dataShow(){
|
||||
jQuery('#cover').attr("onclick","javascript:dataHide();").show();
|
||||
jQuery('#frame').animate({"right": 0}, 500);
|
||||
}
|
||||
function dataHide(){
|
||||
var dataHeight = $("#frame").css('height');
|
||||
var dataWidth = $("#frame").css('width');
|
||||
jQuery('#frame').animate({'right': '-'+dataWidth}, 500);
|
||||
jQuery('#cover').hide();
|
||||
}
|
||||
|
||||
function showRight(obj, index){
|
||||
$(obj).addClass('wst-goodscate_selected').siblings('#goodscate').removeClass('wst-goodscate_selected');
|
||||
$('.goodscate1').eq(index).show().siblings('.goodscate1').hide();
|
||||
}
|
||||
function searchGoods(){
|
||||
location.href=WST.U('wechat/shops/home','goodsName='+$('#searchKey').val(),true);
|
||||
}
|
||||
/*分类*/
|
||||
function goGoodsList(ct1,ct2){
|
||||
var param = 'shopId=1&ct1='+ct1;
|
||||
if(ct2)
|
||||
param += '&ct2='+ct2;
|
||||
param.shopId = 1;
|
||||
location.href=WST.U('wechat/shops/shopgoodslist',param,true);
|
||||
}
|
||||
|
||||
function shopAds(){
|
||||
//广告
|
||||
var slider = new fz.Scroll('.ui-slider', {
|
||||
role: 'slider',
|
||||
indicator: true,
|
||||
autoplay: true,
|
||||
interval: 3000
|
||||
});
|
||||
var w = WST.pageWidth();
|
||||
var h = w*2/5;
|
||||
var o = $('.ui-slider').css("padding-top",h);
|
||||
var scroll = new fz.Scroll('.ui-slider', {
|
||||
scrollY: true
|
||||
});
|
||||
}
|
||||
|
||||
//获取商品列表
|
||||
function shopsList(){
|
||||
$('#Load').show();
|
||||
loading = true;
|
||||
var param = {};
|
||||
param.currPage = Number( $('#currPage').val() ) + 1;
|
||||
$.post(WST.U('wechat/shops/getFloorData'), param, function(data){
|
||||
var json = WST.toJson(data);
|
||||
if(json && json.catId){
|
||||
var gettpl = document.getElementById('gList').innerHTML;
|
||||
laytpl(gettpl).render(json, function(html){
|
||||
$('#goods-list').append(html);
|
||||
});
|
||||
$('#currPage').val(json.currPage);
|
||||
WST.imgAdapt('j-imgAdapt');
|
||||
}
|
||||
loading = false;
|
||||
$('#Load').hide();
|
||||
});
|
||||
}
|
||||
|
||||
function toShopInfo(sid){
|
||||
location.href=WST.U('wechat/shops/index',{'shopId':sid},true)
|
||||
}
|
316
hyhproject/wechat2/view/default/js/settlement.js
Executable file
316
hyhproject/wechat2/view/default/js/settlement.js
Executable file
@ -0,0 +1,316 @@
|
||||
jQuery.noConflict();
|
||||
function onSwitch(obj,n){
|
||||
$(obj).children('.ui-icon-push').removeClass('ui-icon-unchecked-s').addClass('ui-icon-checked-s wst-active');
|
||||
$(obj).siblings().children('.ui-icon-push').removeClass('ui-icon-checked-s wst-active').addClass('ui-icon-unchecked-s');
|
||||
}
|
||||
/* 选择是否需要发票 */
|
||||
function isInvoice(obj,n){
|
||||
$(obj).children('.ui-icon-push').removeClass('ui-icon-unchecked-s').addClass('ui-icon-checked-s wst-active');
|
||||
$(obj).siblings().children('.ui-icon-push').removeClass('ui-icon-checked-s wst-active').addClass('ui-icon-unchecked-s');
|
||||
$('#isInvoice').val(n);// 记录用户是否需要开发票
|
||||
$('#invoicesh').val(n);
|
||||
}
|
||||
/* 发票对象【个人or单位】 */
|
||||
function invOnSwitch(obj,n){
|
||||
$(obj).children('.ui-icon-push').removeClass('ui-icon-unchecked-s').addClass('ui-icon-checked-s wst-active');
|
||||
$(obj).siblings().children('.ui-icon-push').removeClass('ui-icon-checked-s wst-active').addClass('ui-icon-unchecked-s');
|
||||
if(n==1){
|
||||
$('.inv_hidebox').show();
|
||||
}else{
|
||||
$('.inv_hidebox').hide();
|
||||
}
|
||||
$('#invoice_obj').val(n);// 记录用户所开发票对象
|
||||
}
|
||||
/* 发票抬头列表绑定事件 */
|
||||
$(function(){
|
||||
$('#invoice_head').focus(function(){
|
||||
$('#inv_headlist').show();
|
||||
})
|
||||
$('#invoice_head').blur(function(){
|
||||
setTimeout(function(){
|
||||
$('#inv_headlist').hide();
|
||||
},100)
|
||||
})
|
||||
// 只要用户编辑了,就视为新增
|
||||
$('#invoice_head').bind('input propertychange', function() {
|
||||
$('#invoiceId').val(0);
|
||||
});
|
||||
})
|
||||
/* 完成发票信息填写 */
|
||||
function saveInvoice(){
|
||||
var param={};
|
||||
var invoiceId = $('#invoiceId').val();// 发票id
|
||||
param.invoiceCode = $('#invoice_code').val();// 纳税人识别码
|
||||
param.invoiceHead = $('#invoice_head').val();// 发票抬头
|
||||
var url = 'wechat/invoices/add';
|
||||
if(invoiceId>0){
|
||||
url = 'wechat/invoices/edit';
|
||||
param.id = invoiceId;
|
||||
}
|
||||
|
||||
if($('#invoice_obj').val()!=0){
|
||||
$.post(WST.U(url),param,function(data){
|
||||
var json = WST.toJson(data);
|
||||
if(json.status==1){
|
||||
setInvoiceText();
|
||||
if(invoiceId==0)$('#invoiceId').val(json.data.id)
|
||||
}else{
|
||||
WST.msg(json.msg,'info');
|
||||
}
|
||||
})
|
||||
}else{
|
||||
setInvoiceText();
|
||||
}
|
||||
}
|
||||
// 设置页面显示值
|
||||
function setInvoiceText(){
|
||||
var isInvoice = $('#isInvoice').val();
|
||||
var invoiceObj = $('#invoice_obj').val();// 发票对象
|
||||
var invoiceHead = $('#invoice_head').val();// 发票抬头
|
||||
var text = '不开发票';
|
||||
if(isInvoice==1){
|
||||
text = (invoiceObj==0)?'普通发票(纸质) 个人 明细':'普通发票(纸质)<br />'+invoiceHead+'<br />明细';
|
||||
}
|
||||
$('#invoicest').html(text);
|
||||
invoiceHide();
|
||||
}
|
||||
function inDetermine(n){
|
||||
$('#'+n+' .wst-active').each(function(){
|
||||
type = $(this).attr('mode');
|
||||
word = $(this).attr('word');
|
||||
if(n=='payments')payCode = $(this).attr('payCode');
|
||||
});
|
||||
$('#'+n+'h').val(type);
|
||||
$('#'+n+'t').html(word);
|
||||
if(n=='payments'){
|
||||
$('#'+n+'w').val(payCode);
|
||||
}
|
||||
getCartMoney();
|
||||
dataHide(n);
|
||||
}
|
||||
|
||||
|
||||
//计算价格
|
||||
function getCartMoney(){
|
||||
var params = {};
|
||||
params.isUseScore = $('#scoreh').val();
|
||||
params.useScore = $('#userOrderScore').html();
|
||||
params.areaId2 = $('#areaId').val();
|
||||
params.deliverType = $('#givesh').val();
|
||||
params.sign = $('#sign').val();
|
||||
|
||||
params.couponIds = [];
|
||||
$('input[id^="couponId_"]').each(function(){
|
||||
var shopId = $(this).attr('id').split('_')[1];
|
||||
params.couponIds.push(shopId+':'+$(this).val());
|
||||
})
|
||||
params.couponIds = params.couponIds.join(',');
|
||||
WST.load('正在计算价格...');
|
||||
if(params.sign==1){
|
||||
$.post(WST.U('wechat/carts/getCartMoney'),params,function(data,textStatus){
|
||||
WST.noload();
|
||||
var json = WST.toJson(data);
|
||||
if(json.status==1){
|
||||
json = json.data;
|
||||
for(var key in json.shops){
|
||||
// 设置每间店铺的运费及总价格
|
||||
$('#shopF_'+key).html('¥'+json.shops[key]['freight'].toFixed(2));
|
||||
$('#shopC_'+key).html('¥'+json.shops[key]['goodsMoney'].toFixed(2));
|
||||
}
|
||||
$('#totalMoney').html('¥'+json.realTotalMoney.toFixed(2));
|
||||
$('#totalPrice').val(json.realTotalMoney);
|
||||
// 设置可用积分及积分可抵金额
|
||||
$('#userOrderScore').html(json.maxScore);
|
||||
$('#userOrderMoney').html(json.maxScoreMoney);
|
||||
}
|
||||
});
|
||||
}else if(params.sign==2){//虚拟商品
|
||||
params.deliverType = 1;
|
||||
$.post(WST.U('wechat/carts/getQuickCartMoney'),params,function(data,textStatus){
|
||||
WST.noload();
|
||||
var json = WST.toJson(data);
|
||||
if(json.status==1){
|
||||
json = json.data;
|
||||
$('#totalMoney').html('¥'+json.realTotalMoney.toFixed(2));
|
||||
$('#totalPrice').val(json.realTotalMoney);
|
||||
// 设置可用积分及积分可抵金额
|
||||
$('#userOrderScore').html(json.maxScore);
|
||||
$('#userOrderMoney').html(json.maxScoreMoney);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
//提交订单
|
||||
function submitOrder(){
|
||||
var addressId = $('#addressId').val();
|
||||
if(addressId==''){
|
||||
WST.msg('请选择收货地址','info');
|
||||
return false;
|
||||
}
|
||||
WST.load('提交中···');
|
||||
var param = {};
|
||||
param.s_addressId = addressId;
|
||||
param.s_areaId = $('#areaId').val();
|
||||
param.payType = $('#paymentsh').val();
|
||||
param.payCode = $('#paymentsw').val();
|
||||
param.isUseScore = $('#scoreh').val();
|
||||
param.useScore = $('#userOrderScore').html();
|
||||
$('.wst-se-sh .shopn').each(function(){
|
||||
shopId = $(this).attr('shopId');
|
||||
param['remark_'+shopId] = $('#remark_'+shopId).val();
|
||||
param['couponId_'+shopId] = $('#couponId_'+shopId).val();
|
||||
});
|
||||
param.deliverType = $('#givesh').val();
|
||||
param.isInvoice = $('#isInvoice').val();
|
||||
param.invoiceId = $('#invoiceId').val();
|
||||
param.invoiceClient = $('#invoice_obj').val()==1?$('#invoice_head').val():'个人';
|
||||
$('.wst-se-confirm .button').attr('disabled', 'disabled');
|
||||
$.post(WST.U('wechat/orders/submit'),param,function(data,textStatus){
|
||||
var json = WST.toJson(data);
|
||||
WST.noload();
|
||||
if(json.status==1){
|
||||
WST.msg(json.msg,'success');
|
||||
setTimeout(function(){
|
||||
if(param.payType==1 && $('#totalPrice').val()>0){
|
||||
if(param.payCode=='weixinpays' || param.payCode==''){
|
||||
location.href = WST.U('wechat/weixinpays/toPay',{"orderNo":json.data,'isBatch':1});
|
||||
}else if(param.payCode=='wallets'){
|
||||
location.href = WST.U('wechat/wallets/payment',{"orderNo":json.data,'isBatch':1});
|
||||
}
|
||||
}else{
|
||||
location.href = WST.U('wechat/orders/index');
|
||||
}
|
||||
},1000);
|
||||
}else{
|
||||
WST.msg(json.msg,'info');
|
||||
$('.wst-se-confirm .button').removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
}
|
||||
//提交虚拟商品订单
|
||||
function quickSubmitOrder(){
|
||||
WST.load('提交中···');
|
||||
var param = {};
|
||||
param.payType = $('#paymentsh').val();
|
||||
param.payCode = $('#paymentsw').val();
|
||||
param.isUseScore = $('#scoreh').val();
|
||||
param.useScore = $('#userOrderScore').html();
|
||||
$('.wst-se-sh .shopn').each(function(){
|
||||
shopId = $(this).attr('shopId');
|
||||
param['remark_'+shopId] = $('#remark_'+shopId).val();
|
||||
param['couponId_'+shopId] = $('#couponId_'+shopId).val();
|
||||
});
|
||||
param.isInvoice = $('#isInvoice').val();
|
||||
param.invoiceId = $('#invoiceId').val();
|
||||
param.invoiceClient = $('#invoice_obj').val()==1?$('#invoice_head').val():'个人';
|
||||
$('.wst-se-confirm .button').attr('disabled', 'disabled');
|
||||
$.post(WST.U('wechat/orders/quickSubmit'),param,function(data,textStatus){
|
||||
var json = WST.toJson(data);
|
||||
WST.noload();
|
||||
if(json.status==1){
|
||||
WST.msg(json.msg,'success');
|
||||
setTimeout(function(){
|
||||
if(param.payType==1 && $('#totalPrice').val()>0){
|
||||
if(param.payCode=='weixinpays' || param.payCode==''){
|
||||
location.href = WST.U('wechat/weixinpays/toPay',{"orderNo":json.data,'isBatch':1});
|
||||
}else if(param.payCode=='wallets'){
|
||||
location.href = WST.U('wechat/wallets/payment',{"orderNo":json.data,'isBatch':1});
|
||||
}
|
||||
}else{
|
||||
location.href = WST.U('wechat/orders/index');
|
||||
}
|
||||
|
||||
},1000);
|
||||
}else{
|
||||
WST.msg(json.msg,'info');
|
||||
$('.wst-se-confirm .button').removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
}
|
||||
function addAddress(type,id){
|
||||
location.href = WST.U('wechat/useraddress/index','type='+type+'&addressId='+id);
|
||||
}
|
||||
var dataHeight = $(".frame").css('height');
|
||||
dataHeight = parseInt(dataHeight)+50+'px';
|
||||
$(document).ready(function(){
|
||||
WST.imgAdapt('j-imgAdapt');
|
||||
$(".frame").css('bottom','-'+dataHeight);
|
||||
|
||||
backPrevPage(WST.U('wechat/carts/index'));
|
||||
});
|
||||
//弹框
|
||||
function dataShow(n){
|
||||
jQuery('#cover').attr("onclick","javascript:dataHide('"+n+"');").show();
|
||||
jQuery('#'+n).animate({"bottom": 0}, 500);
|
||||
//显示已保存的数据
|
||||
var type = $('#'+n+'h').val();
|
||||
if(type==0){
|
||||
jQuery('i[class*="'+n+'"]').removeClass('ui-icon-checked-s wst-active').addClass('ui-icon-unchecked-s');
|
||||
jQuery('.'+n+'0').removeClass('ui-icon-unchecked-s').addClass('ui-icon-checked-s wst-active');
|
||||
}else{
|
||||
jQuery('i[class*="'+n+'"]').removeClass('ui-icon-checked-s wst-active').addClass('ui-icon-unchecked-s');
|
||||
jQuery('.'+n+'1').removeClass('ui-icon-unchecked-s').addClass('ui-icon-checked-s wst-active');
|
||||
}
|
||||
if(n=='payments'){
|
||||
var payCode = $('#'+n+'w').val();
|
||||
jQuery('i[class*="'+n+'"]').removeClass('ui-icon-checked-s wst-active').addClass('ui-icon-unchecked-s');
|
||||
jQuery('.'+n+'_'+payCode).removeClass('ui-icon-unchecked-s').addClass('ui-icon-checked-s wst-active');
|
||||
}
|
||||
if(n=='invoices'){
|
||||
if(type==0){
|
||||
jQuery('#j-invoice').hide();
|
||||
}else{
|
||||
jQuery('#j-invoice').show();
|
||||
}
|
||||
}
|
||||
}
|
||||
function dataHide(n){
|
||||
jQuery('#'+n).animate({'bottom': '-'+dataHeight}, 500);
|
||||
jQuery('#cover').hide();
|
||||
}
|
||||
document.addEventListener('touchmove', function(event) {
|
||||
//阻止背景页面滚动,
|
||||
if(!jQuery("#cover").is(":hidden")){
|
||||
event.preventDefault();
|
||||
}
|
||||
})
|
||||
|
||||
/*********************** 发票信息层 ****************************/
|
||||
//弹框
|
||||
function invoiceShow(){
|
||||
jQuery('#cover').attr("onclick","javascript:invoiceHide();").show();
|
||||
jQuery('#frame').animate({"right": 0}, 500);
|
||||
setTimeout(function(){$('#shopBox').hide();},600)// 隐藏背部页面
|
||||
|
||||
}
|
||||
function invoiceHide(){
|
||||
$('#shopBox').show();// 隐藏背部页面
|
||||
var dataHeight = $("#frame").css('height');
|
||||
var dataWidth = $("#frame").css('width');
|
||||
jQuery('#frame').animate({'right': '-'+dataWidth}, 500);
|
||||
jQuery('#cover').hide();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getInvoiceList(){
|
||||
$.post(WST.U('wechat/invoices/pageQuery'),{},function(data){
|
||||
var json = WST.toJson(data);
|
||||
if(json.status!=-1){
|
||||
var gettpl1 = document.getElementById('invoiceBox').innerHTML;
|
||||
laytpl(gettpl1).render(json, function(html){
|
||||
$('.inv_list_item').html(html);
|
||||
invoiceShow();
|
||||
// 点击抬头item
|
||||
$('.inv_list_item li').click(function(){
|
||||
// 设置值
|
||||
$('#invoice_head').val($(this).html());
|
||||
$('#invoiceId').val($(this).attr('invId'));
|
||||
$('#invoice_code').val($(this).attr('invCode'));
|
||||
})
|
||||
});
|
||||
}else{
|
||||
WST.msg(json.msg,'info');
|
||||
}
|
||||
});
|
||||
}
|
128
hyhproject/wechat2/view/default/js/shop_goods_list.js
Executable file
128
hyhproject/wechat2/view/default/js/shop_goods_list.js
Executable file
@ -0,0 +1,128 @@
|
||||
jQuery.noConflict();
|
||||
var loading = false;
|
||||
$(function(){
|
||||
$('.wst-se-search').on('submit', '.input-form', function(event){
|
||||
event.preventDefault();
|
||||
})
|
||||
// 加载商品列表
|
||||
shopsList();
|
||||
// 楼层商品
|
||||
WST.imgAdapt('j-imgAdapt');
|
||||
// 商品分类
|
||||
var h = WST.pageHeight();
|
||||
var dataHeight = $("#frame").css('height');
|
||||
if(parseInt(dataHeight)>h-42){
|
||||
$('#content').css('overflow-y','scroll').css('height',h-42);
|
||||
}
|
||||
$(window).scroll(function(event){
|
||||
var wScrollY = window.scrollY; // 当前滚动条位置
|
||||
var wInnerH = window.innerHeight; // 设备窗口的高度(不会变)
|
||||
var bScrollH = document.body.scrollHeight; // 滚动条总高度
|
||||
if (wScrollY + wInnerH >= bScrollH) {
|
||||
var currPage = Number( $('#currPage').val() );
|
||||
var totalPage = Number( $('#totalPage').val() );
|
||||
if(currPage < totalPage ){
|
||||
shopsList();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//弹框
|
||||
function dataShow(){
|
||||
jQuery('#cover').attr("onclick","javascript:dataHide();").show();
|
||||
jQuery('#frame').animate({"right": 0}, 500);
|
||||
}
|
||||
function dataHide(){
|
||||
var dataHeight = $("#frame").css('height');
|
||||
var dataWidth = $("#frame").css('width');
|
||||
jQuery('#frame').animate({'right': '-'+dataWidth}, 500);
|
||||
jQuery('#cover').hide();
|
||||
}
|
||||
|
||||
function showRight(obj, index){
|
||||
$(obj).addClass('wst-goodscate_selected').siblings('#goodscate').removeClass('wst-goodscate_selected');
|
||||
$('.goodscate1').eq(index).show().siblings('.goodscate1').hide();
|
||||
}
|
||||
//排序条件
|
||||
function orderCondition(obj,condition){
|
||||
var classContent = $(obj).attr('class');
|
||||
var status = $(obj).attr('status');
|
||||
var theSiblings = $(obj).siblings('.sorts');
|
||||
theSiblings.removeClass('active').attr('status','down');
|
||||
$(obj).addClass('active');
|
||||
if(classContent.indexOf('active')==-1){
|
||||
$(obj).children('i').addClass('down2').removeClass('down');
|
||||
theSiblings.children('i').addClass('down').removeClass('down2');
|
||||
}
|
||||
if(status.indexOf('down')>-1){
|
||||
if(classContent.indexOf('active')==-1){
|
||||
$(obj).children('i').addClass('down2').removeClass('up2');
|
||||
$('#desc').val('0');
|
||||
}else{
|
||||
$(obj).children('i').addClass('up2').removeClass('down2');
|
||||
$(obj).attr('status','up');
|
||||
$('#desc').val('1');
|
||||
}
|
||||
}else{
|
||||
$(obj).children('i').addClass('down2').removeClass('up2');
|
||||
$(obj).attr('status','down');
|
||||
$('#desc').val('0');
|
||||
}
|
||||
$('#condition').val(condition);//排序条件
|
||||
$('#currPage').val('0');//当前页归零
|
||||
$('#shops-list').html('');
|
||||
shopsList();
|
||||
}
|
||||
|
||||
|
||||
//获取商品列表
|
||||
function shopsList(){
|
||||
$('#Load').show();
|
||||
loading = true;
|
||||
var param = {};
|
||||
param.shopId = $('#shopId').val();
|
||||
param.msort = $('#condition').val();
|
||||
param.mdesc = $('#desc').val();
|
||||
param.goodsName = $('#keyword').val();
|
||||
param.ct1 = $('#ct1').val();
|
||||
param.ct2 = $('#ct2').val();
|
||||
|
||||
param.pagesize = 10;
|
||||
param.page = Number( $('#currPage').val() ) + 1;
|
||||
$.post(WST.U('wechat/shops/getShopGoods'), param, function(data){
|
||||
var json = WST.toJson(data);
|
||||
var html = '';
|
||||
if(json && json.Rows && json.Rows.length>0){
|
||||
var gettpl = document.getElementById('shopList').innerHTML;
|
||||
laytpl(gettpl).render(json.Rows, function(html){
|
||||
$('#shops-list').append(html);
|
||||
});
|
||||
|
||||
$('#currPage').val(json.CurrentPage);
|
||||
$('#totalPage').val(json.TotalPage);
|
||||
}else{
|
||||
html += '<div class="wst-prompt-icon"><img src="'+ window.conf.WECHAT +'/img/nothing-goods.png"></div>';
|
||||
html += '<div class="wst-prompt-info">';
|
||||
html += '<p>对不起,没有相关商品。</p>';
|
||||
html += '</div>';
|
||||
$('#shops-list').html(html);
|
||||
}
|
||||
WST.imgAdapt('j-imgAdapt');
|
||||
loading = false;
|
||||
$('#Load').hide();
|
||||
echo.init();//图片懒加载
|
||||
});
|
||||
}
|
||||
|
||||
/*分类*/
|
||||
function getGoodsList(ct1,ct2){
|
||||
$('#ct2').val('');
|
||||
$('#ct1').val(ct1);
|
||||
if(ct2)$('#ct2').val(ct2);
|
||||
$('#currPage').val('0');
|
||||
$('#shops-list').html('');
|
||||
shopsList();
|
||||
$("#wst-shops-search").hide();
|
||||
dataHide();
|
||||
}
|
190
hyhproject/wechat2/view/default/js/shop_home.js
Executable file
190
hyhproject/wechat2/view/default/js/shop_home.js
Executable file
@ -0,0 +1,190 @@
|
||||
jQuery.noConflict();
|
||||
var loading = false;
|
||||
$(function(){
|
||||
$('.wst-se-search').on('submit', '.input-form', function(event){
|
||||
event.preventDefault();
|
||||
})
|
||||
fixedTerm();
|
||||
shopBest();
|
||||
WST.imgAdapt('j-imgIndex');
|
||||
// 商品分类
|
||||
var h = WST.pageHeight();
|
||||
var dataHeight = $("#frame").css('height');
|
||||
if(parseInt(dataHeight)>h-42){
|
||||
$('#content').css('overflow-y','scroll').css('height',h-42);
|
||||
}
|
||||
$(window).scroll(function(){
|
||||
if (loading) return;
|
||||
if((($(window).scrollTop()+$(window).height())+50)>=$(document).height()){
|
||||
if($('#currPage').val()<$('#totalPage').val())shopsList();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//弹框
|
||||
function dataShow(){
|
||||
jQuery('#cover').attr("onclick","javascript:dataHide();").show();
|
||||
jQuery('#frame').animate({"right": 0}, 500);
|
||||
}
|
||||
function dataHide(){
|
||||
var dataHeight = $("#frame").css('height');
|
||||
var dataWidth = $("#frame").css('width');
|
||||
jQuery('#frame').animate({'right': '-'+dataWidth}, 500);
|
||||
jQuery('#cover').hide();
|
||||
}
|
||||
|
||||
function showRight(obj, index){
|
||||
$(obj).addClass('wst-goodscate_selected').siblings('#goodscate').removeClass('wst-goodscate_selected');
|
||||
$('.goodscate1').eq(index).show().siblings('.goodscate1').hide();
|
||||
}
|
||||
|
||||
function shopAds(){
|
||||
//广告
|
||||
var slider = new fz.Scroll('.ui-slider', {
|
||||
role: 'slider',
|
||||
indicator: true,
|
||||
autoplay: true,
|
||||
interval: 3000
|
||||
});
|
||||
}
|
||||
//排序条件
|
||||
function orderCondition(obj,condition){
|
||||
jQuery('html,body').scrollTop($('#j-top').offset().top);
|
||||
var classContent = $(obj).attr('class');
|
||||
var status = $(obj).attr('status');
|
||||
var theSiblings = $(obj).siblings('.sorts');
|
||||
theSiblings.removeClass('active').attr('status','down');
|
||||
$(obj).addClass('active');
|
||||
if(classContent.indexOf('active')==-1){
|
||||
$(obj).children('i').addClass('down2').removeClass('down');
|
||||
theSiblings.children('i').addClass('down').removeClass('down2');
|
||||
}
|
||||
if(status.indexOf('down')>-1){
|
||||
if(classContent.indexOf('active')==-1){
|
||||
$(obj).children('i').addClass('down2').removeClass('up2');
|
||||
$('#desc').val('0');
|
||||
}else{
|
||||
$(obj).children('i').addClass('up2').removeClass('down2');
|
||||
$(obj).attr('status','up');
|
||||
$('#desc').val('1');
|
||||
}
|
||||
}else{
|
||||
$(obj).children('i').addClass('down2').removeClass('up2');
|
||||
$(obj).attr('status','down');
|
||||
$('#desc').val('0');
|
||||
}
|
||||
$('#condition').val(condition);//排序条件
|
||||
$('#currPage').val('0');//当前页归零
|
||||
$('#shops-list').html('');
|
||||
shopsList();
|
||||
}
|
||||
|
||||
//查看
|
||||
function switchTerm(n){
|
||||
if(parseInt($('#j-top').offset().top)>$(window).scrollTop()){
|
||||
jQuery('html,body').animate({scrollTop:$('#j-top').offset().top}, 800);
|
||||
}
|
||||
$('#j-top'+n).addClass('active').siblings('.wst-sh-term li').removeClass('active');
|
||||
if(n==1){
|
||||
$('#j-index1').show();
|
||||
$('#j-index0').hide();
|
||||
}else{
|
||||
$('#j-index0').show();
|
||||
$('#j-index1').hide();
|
||||
$('#currPage').val('0');
|
||||
$('#shops-list').html('');
|
||||
shopsList();
|
||||
}
|
||||
}
|
||||
function fixedTerm(){
|
||||
var offsetTop = $("#j-top").offset().top;
|
||||
$(window).scroll(function() {
|
||||
var scrollTop = $(window).scrollTop();
|
||||
if (scrollTop > offsetTop){
|
||||
$("#j-top").addClass('active');
|
||||
$('#j-index0').css('padding-top',45);
|
||||
$('#j-index1').css('padding-top',45);
|
||||
}else{
|
||||
$("#j-top").removeClass('active');
|
||||
$('#j-index0').css('padding-top',0);
|
||||
$('#j-index1').css('padding-top',0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//获取商品列表销量
|
||||
function shopBest(){
|
||||
loading = true;
|
||||
var param = {};
|
||||
param.shopId = $('#shopId').val();
|
||||
param.msort = 2;
|
||||
param.mdesc = 1;
|
||||
param.pagesize = 6;
|
||||
$.post(WST.U('wechat/shops/getShopGoods'), param, function(data){
|
||||
var json = WST.toJson(data);
|
||||
var html = '';
|
||||
if(json && json.Rows && json.Rows.length>0){
|
||||
var gettpl = document.getElementById('shopBest').innerHTML;
|
||||
laytpl(gettpl).render(json.Rows, function(html){
|
||||
$('#best-list').append(html);
|
||||
});
|
||||
}
|
||||
WST.imgAdapt('j-imgBest');
|
||||
loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
//获取商品列表
|
||||
function shopsList(){
|
||||
$('#Load').show();
|
||||
loading = true;
|
||||
var param = {};
|
||||
param.shopId = $('#shopId').val();
|
||||
param.msort = $('#condition').val();
|
||||
param.mdesc = $('#desc').val();
|
||||
param.goodsName = $('#keyword').val();
|
||||
param.ct1 = $('#ct1').val();
|
||||
param.ct2 = $('#ct2').val();
|
||||
param.pagesize = 10;
|
||||
param.page = Number( $('#currPage').val() ) + 1;
|
||||
$.post(WST.U('wechat/shops/getShopGoods'), param, function(data){
|
||||
var json = WST.toJson(data);
|
||||
var html = '';
|
||||
if(json && json.Rows && json.Rows.length>0){
|
||||
var gettpl = document.getElementById('shopList').innerHTML;
|
||||
laytpl(gettpl).render(json.Rows, function(html){
|
||||
$('#shops-list').append(html);
|
||||
});
|
||||
|
||||
$('#currPage').val(json.CurrentPage);
|
||||
$('#totalPage').val(json.TotalPage);
|
||||
}else{
|
||||
html += '<div class="wst-prompt-icon"><img src="'+ window.conf.WECHAT +'/img/nothing-goods.png"></div>';
|
||||
html += '<div class="wst-prompt-info">';
|
||||
html += '<p>对不起,没有相关商品。</p>';
|
||||
html += '</div>';
|
||||
$('#shops-list').html(html);
|
||||
}
|
||||
WST.imgAdapt('j-imgAdapt');
|
||||
loading = false;
|
||||
$('#Load').hide();
|
||||
echo.init();//图片懒加载
|
||||
});
|
||||
}
|
||||
|
||||
/*分类*/
|
||||
function getGoodsList(ct1,ct2){
|
||||
$('#ct2').val('');
|
||||
$('#ct1').val(ct1);
|
||||
if(ct2)$('#ct2').val(ct2);
|
||||
$('#currPage').val('0');
|
||||
$('#shops-list').html('');
|
||||
shopsList();
|
||||
$("#wst-shops-search").hide();
|
||||
dataHide();
|
||||
switchTerm(0);
|
||||
}
|
||||
|
||||
function toShopInfo(sid){
|
||||
location.href=WST.U('wechat/shops/index',{'shopId':sid},true)
|
||||
}
|
124
hyhproject/wechat2/view/default/js/shops_list.js
Executable file
124
hyhproject/wechat2/view/default/js/shops_list.js
Executable file
@ -0,0 +1,124 @@
|
||||
//排序条件
|
||||
function orderCondition(obj,condition){
|
||||
var classContent = $(obj).attr('class');
|
||||
var status = $(obj).attr('status');
|
||||
var theSiblings = $(obj).siblings('.sorts');
|
||||
theSiblings.removeClass('active').attr('status','down');
|
||||
$(obj).addClass('active');
|
||||
$('.wst-shl-select').removeClass('active');
|
||||
if(classContent.indexOf('active')==-1){
|
||||
$('.wst-shl-head .evaluate i').addClass('down2').removeClass('down');
|
||||
}
|
||||
if(status.indexOf('down')>-1){
|
||||
if(classContent.indexOf('active')==-1){
|
||||
$('.wst-shl-head .evaluate i').addClass('down2').removeClass('up2');
|
||||
$('#desc').val('0');
|
||||
}else{
|
||||
$('.wst-shl-head .evaluate i').addClass('up2').removeClass('down2');
|
||||
$(obj).attr('status','up');
|
||||
$('#desc').val('1');
|
||||
}
|
||||
}else{
|
||||
$('.wst-shl-head .evaluate i').addClass('down2').removeClass('up2');
|
||||
$(obj).attr('status','down');
|
||||
$('#desc').val('0');
|
||||
}
|
||||
$('#condition').val(condition);//排序条件
|
||||
$('#currPage').val('0');//当前页归零
|
||||
$('#shops-list').html('');
|
||||
shopsList();
|
||||
}
|
||||
function orderSelect(id){
|
||||
$('.wst-shl-select').addClass('active');
|
||||
$('.evaluate .choice').removeClass('active');
|
||||
$('.wst-shl-head .evaluate i').addClass('down').removeClass('down2');
|
||||
$('#catId').val(id);
|
||||
$('#currPage').val('0');//当前页归零
|
||||
$('#shops-list').html('');
|
||||
shopsList();
|
||||
}
|
||||
function searchCondition(id){
|
||||
$("#wst-shops-search").hide();
|
||||
$('#catId').val(id);
|
||||
$('#currPage').val('0');//当前页归零
|
||||
$('#shops-list').html('');
|
||||
shopsList();
|
||||
}
|
||||
//获取店铺列表
|
||||
function shopsList(){
|
||||
$('#Load').show();
|
||||
loading = true;
|
||||
var param = {};
|
||||
param.id = $('#catId').val();
|
||||
param.condition = $('#condition').val();
|
||||
param.desc = $('#desc').val();
|
||||
param.keyword = $('#keyword').val();
|
||||
param.pagesize = 10;
|
||||
param.page = Number( $('#currPage').val() ) + 1;
|
||||
$.post(WST.U('wechat/shops/pageQuery'), param,function(data){
|
||||
var json = WST.toJson(data);
|
||||
$('#currPage').val(json.CurrentPage);
|
||||
$('#totalPage').val(json.TotalPage);
|
||||
var gettpl = document.getElementById('list').innerHTML;
|
||||
laytpl(gettpl).render(json.Rows, function(html){
|
||||
$('#shops-list').append(html);
|
||||
});
|
||||
imgShop('j-imgAdapt');
|
||||
imgShop('goods-item');
|
||||
loading = false;
|
||||
$('#Load').hide();
|
||||
echo.init();//图片懒加载
|
||||
});
|
||||
}
|
||||
var currPage = totalPage = 0;
|
||||
var loading = false;
|
||||
$(document).ready(function(){
|
||||
WST.initFooter('home');
|
||||
$('.wst-se-search').on('submit', '.input-form', function(event){
|
||||
event.preventDefault();
|
||||
})
|
||||
|
||||
if($('.wst-shl-ads a').hasClass("adsImg")){
|
||||
//中间小广告
|
||||
new Swiper('.swiper-container', {
|
||||
slidesPerView: 3,
|
||||
freeMode : true,
|
||||
spaceBetween: 0,
|
||||
autoplay : 2000,
|
||||
speed:1200,
|
||||
loop : true,
|
||||
autoplayDisableOnInteraction : false,
|
||||
onSlideChangeEnd: function(swiper){
|
||||
echo.init();//图片懒加载
|
||||
}
|
||||
});
|
||||
}else{
|
||||
$('.wst-shl-ads').hide();
|
||||
}
|
||||
shopsList();
|
||||
$(window).scroll(function(){
|
||||
if (loading) return;
|
||||
if ((5 + $(window).scrollTop()) >= ($(document).height() - screen.height)) {
|
||||
currPage = Number( $('#currPage').val() );
|
||||
totalPage = Number( $('#totalPage').val() );
|
||||
if( totalPage > 0 && currPage < totalPage ){
|
||||
shopsList();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
function goShopHome(sid){
|
||||
location.href=WST.U('wechat/shops/home','shopId='+sid,true);
|
||||
}
|
||||
//适应图片大小正方形
|
||||
function imgShop(name){
|
||||
var w = $('.'+name).width();
|
||||
if(name == 'j-imgAdapt'){
|
||||
$('.'+name).css({"width": w+"px","height": w+"px"});
|
||||
}else{
|
||||
$('.'+name).css({"width": w+"px","height": w+20+"px"});
|
||||
}
|
||||
$('.'+name+' a').css({"width": w+"px","height": w+"px"});
|
||||
$('.'+name+' a img').css({"width": w+"px","height": w+"px"});
|
||||
$('.'+name+' a .goodsPrice').css({"width": w+"px"});
|
||||
}
|
16
hyhproject/wechat2/view/default/js/swiper.jquery.min.js
vendored
Executable file
16
hyhproject/wechat2/view/default/js/swiper.jquery.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user