tradeList.js 12.4 KB
/*! dili 2016-01-06 */
define("tools",function(require,exports){var Tools;return Tools=function(){var self=this;return this.setSelected=function(obj){var Selected=function(data){var $container,$tags,config={type:"click",container:"",tags:"",selected:"act",disabledClass:"disabled",cllback:function(){}},methods={setIndex:function(is){return is.hasClass(config.disabledClass)||is.hasClass(config.selected)?!1:($container.find(config.tags).removeClass(config.selected),is.addClass(config.selected),void("undefined"!=typeof is.index()&&config.cllback(is.index(),is)))}};return $.extend(config,data),$container=$(config.container),$tags=$container.find(config.tags),$tags.on(config.type,function(event){$tags.is("a")&&event&&event.preventDefault&&event.preventDefault(),$(this).hasClass(config.disabledClass)||methods.setIndex($(this))}),this.setIndex=function(index){$tags.eq(index)&&methods.setIndex($tags.eq(index))},this};return new Selected(obj)},this.numberChange=function(){var list=[],subscript=0,NumberChange=function(v,index){var config={view:$(v),addView:$(v).find(".up")?$(v).find(".up"):null,reduceView:$(v).find(".down")?$(v).find(".down"):null,changeView:$(v).find("input")?$(v).find("input"):null,index:index,maxnum:$(v).find("input").attr("maxmun")?parseInt($(v).find("input").attr("maxmun")):9999,minmun:$(v).find("input").attr("minmun")?parseInt($(v).find("input").attr("minmun")):1,value:1},methods={update:function(){config.changeView.val(config.value),self.radio.numCallback(config.value,config.view)},tip:function(key){if(self.radio&&self.radio.num){var text="";text+=key?"该商品最大购买数为"+config.maxnum:"该商品最小购买数为"+config.minmun,self.radio.num(text,config.view)}},interval:function(){config.maxnum=$(v).find("input").attr("maxmun"),config.minmun=$(v).find("input").attr("minmun")}};return config.view.hasClass("disabled")?(config.changeView.attr("disabled",!0),!1):(config.addView&&config.addView.click(function(){methods.interval(),config.value<config.maxnum?(config.value+=1,methods.update()):methods.tip(1)}),config.changeView&&(config.value=parseInt(config.changeView.val()),config.changeView.change(function(){methods.interval();var value=parseInt($(this).val())>=0?parseInt($(this).val()):config.value;value<config.minmun?methods.tip(0):value>config.maxnum?methods.tip(1):config.value=value,methods.update()})),config.reduceView&&config.reduceView.click(function(){methods.interval(),config.value>config.minmun?(config.value-=1,methods.update()):methods.tip(0)}),config.view.parent().bind("selectstart",function(){return!1}),this)};return $(".counter").each(function(){var nc=new NumberChange(this,subscript);subscript+=1,list.push(nc)}),list},this.sollView=function(obj){function SollView(){var config={leftBtn:null,rightBtn:null,sollView:null,view:null,index:0,width:0,maxPage:0,sollWidth:0,leftWidth:28,hoverView:null,isasingle:!1,callBack:function(){}},methods={animation:function(){config.sollView.stop().animate({left:config.index*config.width+"px"}),config.callBack(config.index,config.maxPage)},upadte:function(){if(config.isasingle)maxPage=config.sollView.find("li").length;else{var maxPage=parseInt(config.sollView.find("li").length/4);config.sollView.find("li").length%4&&(maxPage+=1)}try{config.leftWidth=config.sollView.find("li").eq(0).css("marginRight").replace("px",""),config.leftWidth=parseInt(config.leftWidth)}catch(error){}config.maxPage=maxPage,config.isasingle?config.width=config.sollView.find("li").width():config.width=4*config.sollView.find("li").width()+4*config.leftWidth+8,config.sollView.width(config.view.width()*maxPage)}};return config=$.extend(config,obj),methods.upadte(),config.leftBtn&&config.rightBtn?(config.leftBtn.click(function(){config.index<0&&(config.index+=1,methods.animation(config.index))}),config.rightBtn.click(function(){-config.index<config.maxPage-1&&(config.index-=1,methods.animation(config.index))})):config.hoverView&&config.hoverView.find("li").bind("mouseover",function(){config.index=0-$(this).index(),methods.animation(config.index)}),$(window).resize(function(){config.index=0,methods.upadte(),config.sollView.css({left:0}),config.callBack(config.index,config.maxPage)}),config.callBack(config.index,config.maxPage),this.updateInfo=function(data){config=$.extend(config,data),methods.upadte(),config.sollView.css({left:0}),config.callBack(config.index,config.maxPage)},this}return new SollView},this.request=function(paras,_url){var url="";url=_url?_url:location.href;for(var paraString=url.substring(url.indexOf("?")+1,url.length).split("&"),paraObj={},i=0;j=paraString[i];i++)paraObj[j.substring(0,j.indexOf("=")).toLowerCase()]=j.substring(j.indexOf("=")+1,j.length);var returnValue=paraObj[paras.toLowerCase()];return"undefined"==typeof returnValue?"":returnValue},this.cookie=function(){function getsec(str){var str1=1*str.substring(1,str.length),str2=str.substring(0,1);return"s"==str2?1e3*str1:"h"==str2?60*str1*60*1e3:"d"==str2?24*str1*60*60*1e3:void 0}function getcookie(name){var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");return(arr=document.cookie.match(reg))?arr[2]:null}return{set:function(name,value,time){var strsec=getsec(time),exp=new Date;exp.setTime(exp.getTime()+1*strsec),document.cookie=name+"="+escape(value)+";expires="+exp.toGMTString()},get:function(name){return getcookie(name)},remove:function(name){var exp=new Date;exp.setTime(exp.getTime()-1);var cval=getcookie(name);null!=cval&&(document.cookie=name+"="+cval+";expires="+exp.toGMTString())}}}(),this.addValue=function(_view){function AddValue(){var _p_view=$(_view);return this.setData=function(data){_p_view.html("");for(var _show_view="",_aData=[],i=0;i<data.length;i++)_show_view+='<div class="a-v-view"><p>'+data[i].txt+'</p><span class="a-v-view-d" inx="'+i+'">×</span></div>',_aData.push(data[i].val);_show_view+='<input type="hidden" class="a-v-hidden" value="'+_aData+'" name="'+_p_view.attr("data-name")+'" />',_p_view.html(_show_view),$(".a-v-view-d").click(function(){var _index=$(this).attr("inx");_index=parseInt(_index),_aData.splice(_index,1),$(this).parent().remove(),_p_view.find(".a-v-hidden").remove();var _h_view='<input type="hidden" class="a-v-hidden" value="'+_aData+'" name="'+_p_view.attr("data-name")+'" />';_p_view.append(_h_view)})},this}return new AddValue},this.shoppingMsg=function(_v){var _view=$(".q-message"),_top=0,_time=null;return _v&&(_view=$("."+_v)),$(".q-close").click(function(){_view.hide(),_time&&(clearTimeout(_time),_time=null)}),{load:function(_this){_time&&(clearTimeout(_time),_time=null),_view.find(".load").show(),_view.find(".text").hide();var top=$(_this).parent().offset().top,left=$(_this).parent().offset().left;_top=top-55,_view.css({top:_top,left:left-40}).css({height:"50px"}),_view.show(),self.amAdd("q-message","fadeInDown")},show:function(text){_time=setTimeout(function(){_view.hide(),_time&&(clearTimeout(_time),_time=null)},3e3),_view.animate({height:"75px",top:_top-30},function(){_view.find(".load").hide(),_view.find(".text").show(),_view.find(".text").find("p").css("line-height","30px"),"string"==typeof text?(_view.find(".text").find("p").eq(0).show(),_view.find(".text").find("p").eq(1).html('小计金额:<b class="q-total">'+text+"</b>")):(_view.find(".text").find("p").eq(0).hide(),_view.find(".text").find("p").eq(1).html(text.msg).css("line-height","80px"))})}}},this.randomize=function(b,e){return!b&&0!=b||!e?"?":Math.floor(Math.random()*e+b)},this.DiliRaty=function(_view,_xv){var _xing=8;_xv&&(_xing=_xv),$("."+_view).find("span").width(10*_xing),$("."+_view).next().html(_xing/2),$("."+_view).mousemove(function(e){var xx=e.originalEvent.layerX||e.originalEvent.x||0;if(xx&&(xx=e.clientX-$(this).offset().left),1>xx)return!1;xx+="";var pageX=0;pageX=parseInt(xx.substring(1,0)),pageX%2!=0&&(pageX+=1),$(this).find("span").width(10*pageX),$(this).next().html(+pageX/2)})},this.getPageCoord=function(_view){function getOffset(e){var target=e.target;void 0==target.offsetLeft&&(target=target.parentNode);var pageCoord=getPageCoord(target),eventCoord={x:window.pageXOffset+e.clientX,y:window.pageYOffset+e.clientY},offset={offsetX:eventCoord.x-pageCoord.x,offsetY:eventCoord.y-pageCoord.y};return offset}function getPageCoord(element){for(var coord={x:0,y:0};element;)coord.x+=element.offsetLeft,coord.y+=element.offsetTop,element=element.offsetParent;return coord}$(_view).hover(function(e){var _this=$(this),_desc=_this.find(".end").stop(!0,!0),width=103,height=103,left=void 0==e.offsetX?getOffset(e).offsetX:e.offsetX,top=void 0==e.offsetY?getOffset(e).offsetY:e.offsetY,right=width-left,bottom=height-top,rect={},_min=Math.min(left,top,right,bottom),_out="mouseleave"==e.type,spos={};rect[left]=function(epos){spos={left:-width,top:0},_out?_desc.stop().animate(spos,"fast"):_desc.css(spos).stop().animate(epos,"fast")},rect[top]=function(epos){spos={top:-height,left:0},_out?_desc.stop().animate(spos,"fast"):_desc.css(spos).stop().animate(epos,"fast")},rect[right]=function(epos){spos={left:left,top:0},_out?_desc.stop().animate(spos,"fast"):_desc.css(spos).stop().animate(epos,"fast")},rect[bottom]=function(epos){spos={top:height,left:0},_out?_desc.stop().animate(spos,"fast"):_desc.css(spos).stop().animate(epos,"fast")},rect[_min]({left:0,top:0})})},this.tabRolling=function(_obj){var config={rollview:"u-buoy",view:"u-list li",offset:20,istxtwidth:!1,bias:2};config=$.extend(config,_obj);var width=0,left=0;$("."+config.view).hover(function(e){left=$(this).position().left,width=$(this).width()+config.offset,config.istxtwidth&&(width=$(this).find("a").width(),left=left+($(this).width()-$(this).find("a").width())/2+config.offset/2+config.bias),$("."+config.rollview).stop().animate({left:left,width:width},300)})},this.securitycode=function(view){var time=60,btn=$(view);btn.addClass("gray-btn");var date=setInterval(function(){return 0>=time?(clearInterval(date),btn.html("获取验证码"),time=60,btn.removeClass("gray-btn"),!1):(btn.html(time+"s重新获取"),void time--)},1e3)},this.radio={num:function(){},numCallback:function(){}},this}(),function($){$.fn.dilislider=function(options){function slide(){switch(index>=$contents.length&&(index=0),$stag.removeClass(settings.current).eq(index).addClass(settings.current),settings.affect){case"scrollx":$conbox.width($contents.length*$contents.width()),$conbox.stop().animate({left:-$contents.width()*index},settings.speed);break;case"scrolly":$contents.css({display:"block"}),$conbox.stop().animate({top:-$contents.height()*index+"px"},settings.speed);break;case"fade":$contents.eq(last_index).stop().animate({opacity:0},settings.speed/2).css("z-index",1).end().eq(index).css("z-index",9).stop().animate({opacity:1},settings.speed/2);break;case"none":$contents.hide().eq(index).show()}last_index=index,index++}function _pause(){clearInterval(Timer)}function _continue(){settings.auto&&(Timer=setInterval(slide,settings.space))}var settings={affect:"scrollx",speed:500,space:6e3,auto:!0,trigger:"mouseover",conbox:"ul",ctag:"li",switcher:".tab-a",stag:"a",current:"on",rand:!1};options.point&&(options.switcher=options.point.split(" ")[0],options.stag=options.point.split(" ")[1]),settings=$.extend({},settings,options);var index=1,last_index=0,$conbox=$(this).find(settings.conbox),$contents=$conbox.find(settings.ctag),$switcher=$(settings.switcher),$stag=$switcher.find(settings.stag);if(settings.rand&&(index=Math.floor(Math.random()*$contents.length),slide()),"fade"==settings.affect&&$.each($contents,function(k,v){0===k?$(this).css({position:"absolute","z-index":9}):$(this).css({position:"absolute","z-index":1,opacity:0})}),settings.auto)var Timer=setInterval(slide,settings.space);$stag.bind(settings.trigger,function(){_pause(),index=$(this).index(),slide(),_continue()}),$conbox.hover(_pause,_continue)},$.fn.dhover=function(_fun,_sfun){var trigger=null;$($(this).selector).hover(function(e){var thishover=this;this.ufun=_fun,trigger=setTimeout(function(){thishover.ufun(e)},200)},function(e){this.sfun=_sfun,clearTimeout(trigger),this.sfun(e)})}}(jQuery),function($){$.fn.dhover=function(_fun,_sfun){var trigger=null;$($(this).selector).hover(function(e){var thishover=this;this.ufun=_fun,trigger=setTimeout(function(){thishover.ufun(e)},200)},function(e){this.sfun=_sfun,clearTimeout(trigger),this.sfun(e)})}}(jQuery),Tools}),define(function(require,exports,module){var _Tools=require("tools");$(function(){_Tools.sollView({leftBtn:$(".page-left"),rightBtn:$(".page-right"),sollView:$("#move-list ul"),view:$("#move-list"),callBack:function(index,max){$(".page-num").html(-index+1+"/"+max)}});_Tools.setSelected({container:".search-type",selected:"on",tags:"a",cllback:function(index){$(".search-result-list >div").hide(),$(".search-result-list >div").eq(index).show()}})})});