$(document).ready(function(){
$(".liren_content:odd").css("float",'right');
$('.mall_list').find('ul li:nth-child(3)').css('border','0');
var count=0;
$(".jiaru").click(function () {
// alert(111)
count=parseInt($(".ico_img b").html());
var id = $(this).next().html();
//count++;
$.ajax({
url:"__MODULE__/Qiangbao/check",
type:"POST",
data:"id="+id,
dataType:"text",
async:true,
success:function(res){
//alert(count);
if(res=="M"){
//alert(count);
var a = count +1;
parseInt($(".ico_img b").html(a));
}
}
});
$(".ico_img b").html(count);
var flyElm = $(this).parents(".liren_content").clone();
flyElm.css({
'opacity':'0.7',
'z-index': 9000,
'display': 'block',
'position': 'absolute',
'top': $(this).parents(".liren_content").offset().top +'px',
'left': $(this).parents(".liren_content").offset().left +'px',
'width': $(this).parents(".liren_content").width() +'px',
'height': $(this).parents(".liren_content").height() +'px'
}).addClass("remove");
$('body').append(flyElm);
flyElm.animate({
top:$('#cart img').offset().top,
left:$('#cart img').offset().left,
width:20,
height:20,
opacity:0
},'slow');
setTimeout(function(){
flyElm.remove();
},1000)
// var id = $(this).next().html();
// var aaa = '<{session.shops.id}>';
// if(in(id,aaa)){
// alert(id);
// }
//alert(id);
//加入购物车操作
$.ajax({
url:"__MODULE__/Qiangbao/addlist",
type:"POST",
data:"id="+id,
dataType:"text",
async:true,
success:function(res){
//alert(res);
if(res=="Y"){
}
if(res=="N"){
alert('请再点击一次!');
}
}
});
})
$('.mall_title').click(function(){
window.location.href="__MODULE__/Qiangbao/Index";
})
$('.liren_title').click(function(){
window.location.href="__MODULE__/Liren/Index";
})
//返回顶部
$('.backtop').click(function (e) {
$(".gotop").css({"background-image":"url(__PUBLIC__/images/images/iconfont-fanhuidingbu_up.png)"});
e.preventDefault();
$('html,body').animate({ scrollTop:0});
});
});
var page = 2;
var num = 6;
$(window).scroll(function () {
var scrollHeight = $(document).height();// 获取页面的文档高度
var scrollTop = $(window).scrollTop();// 获取滚动条到顶部的垂直高度
var height = scrollHeight/2;
scrollTop > 375 ? $(".gotop").fadeIn(200).show() : $(".gotop").fadeOut(200).css({"background-image":"url(__PUBLIC__/images/images/iconfont-fanhuidingbu.png)"});
// $("#lb").text($(window).scrollTop()+' 滚动条的到顶部的距离');
// $("#2b").text($(window).height()+' 文档的高度');
// $("#3b").text($(document).height()+' 整个页面的高度');
if(scrollTop >= height){
chaliren();
page++;
}
});
function chaliren(){
$.post("__URL__/chaliren",{'page':page,'num':num},function(data){
var list = eval("("+data+")")
if(list.length==0){
page = 1;
}else{
str = '';
for (var i = 0; i < list.length; i++) {
str += '<div class="liren_list"><a href="__MODULE__/Qiangbao/rewarddetail/id/'+list[i].id+'"><div class="liren_content"><img src="'+list[i].zhongpic+'">';
if(list[i].zeroqiang > 0){str +='<img src="__PUBLIC__/images/images/Groupc 2@2x.png" class="lingyuanchou">';}else if(list[i].sala >0){str +='<img src="__PUBLIC__/images/images/Group@2x.png" class="jinritejia">';}
str +='<nobr><h2>'+list[i].name+'</h2></nobr><div class="jindu">';
if(list[i].zeroqiang >0){str +='<p style="margin-top:6px;">已参与 <b>'+list[i].click+'</b></p><button class="button">立即参与</button><span style="display:none;">'+list[i].id+'</span>';}else{str +='<p>开奖进度<b>'+list[i].jindu+'%</b></p><a href="javascript:;" class="button jiaru">加入清单</a><span style="display:none;">'+list[i].id+'</span><span><i style="width:'+list[i].jindu+'%"></i></span>';}
str += '</div></div> </a></div>';
};
var div = $('.liren');
div.append(str)
$(".liren_content:odd").css("float",'right');
}
})
}
在H5页面的JS 怎么封装到另一个JS文件中呢