$.fn.selectdate = function(){
var postdata = {
act_id:1,
}
//获取所有活动的年份
$.post(url1,postdata,function(data){
if(data.message == 'success'){
var year = data.success;
var yearsel = document.getelementbyid('year');
//获取年份
$.each(year,function(index,value){
var yearopt = document.createelement('option');
yearopt.value = value;
yearopt.innerhtml =value+' 年';
yearsel.appendchild(yearopt);
});
}
},'json');
//根据年份筛选活动
$("#year").change(function(event){
if(!$("#year option:selected").val()) return;
var year = $("#year option:selected").val();
//获取所有活动
if(year =='allactivity'){
var postdata = {
act_id:1
}
getallact(postdata); //调用获取全部活动的方法
}else{
console.log(year);
//根据年份筛选活动:
var postdata = {
act_id:1,
year:year,
}
getactbyyear(postdata); //调用获取该年的活动
//动态获取月份
$.post(url2,postdata,function(data){
if(data.message == 'success'){
var month = data.success;
var monthsel = $('#month');
var sv = $("#month option:selected").val();
var html = '';
html += '';
for(i=0; i'+month[i]+' 月'+'';
}else{
html += '';
}
}
monthsel.html(html);
}
});
}
});
//根据年-月,筛选活动
$("#month").change(function(){
var year = $("#year option:selected").val();
var month = $("#month option:selected").val();
if(month =='allyearactivity'){
var postdata = {
act_id:1,
year:year,
}
getactbyyear(postdata);
}else{
console.log(year+month);
var postdata = {
act_id:1,
year:year,
month:month,
}
getactbymonth(postdata); //获取月份下的活动
}
});
function addoption(num,unit,parent){
//num:选项个数
//unit:单位(年/月/日)
//parent:父对象
for(var index=1;index <= num;index++){
var opt =document.createelement('option')
$(opt).attr('value',index)
if(index<10){index = '0'+index}
$(opt).html(index+unit)
$(parent).append(opt)
}
}
function removeoption(parent){
//parent:父对象
var options = $(parent).find('option')
for(var index = 1;index < options.length;index++){
parent.removechild(options[index])
}
}
/**
* 以下三个主要!
*/
//获取所有活动
function getallact(postdata){
$.post(url5,postdata,function(data){
if(data.message == 'success'){
var result = data.success.row;
var activity_tmpl = dot.template($("#activity_tmpl").text());
$(".activity-content-wrapper").html(activity_tmpl(result));
// $('#count').html(total);
// $('#curpage').html(curpage);
title_change();
openpopup();
}
});
$('#month').html('');
}
//传入年份,获取该年的活动
function getactbyyear(postdata){
//获取年份下的活动
$.post(url3,postdata,function(data){
if(data.message == 'success'){
var result = data.success.row;
var activity_tmpl = dot.template($("#activity_tmpl").text());
$(".activity-content-wrapper").html(activity_tmpl(result));
// $('#count').html(total);
// $('#curpage').html(curpage);
title_change();
openpopup();
}
});
}
/**
* 获取月份下的活动
* @author guangyun song
*/
function getactbymonth(postdata){
$.post(url4,postdata,function(data){
if(data.message == 'success'){
var result = data.success.row;
var activity_tmpl = dot.template($("#activity_tmpl").text());
$(".activity-content-wrapper").html(activity_tmpl(result));
/*$('#count').html(total);
$('#curpage').html(curpage);*/
title_change();
openpopup();
}
});
}
}