$(function() { /* 搜索切换 */ var $more_where = $('.more-where'); $more_submit = $('.more-submit'); $more_submit.find('input[name="is_more"]').change(function() { if($more_submit.find('i').hasClass('am-icon-angle-down')) { $more_submit.find('i').removeClass('am-icon-angle-down'); $more_submit.find('i').addClass('am-icon-angle-up'); } else { $more_submit.find('i').addClass('am-icon-angle-down'); $more_submit.find('i').removeClass('am-icon-angle-up'); } if($more_submit.find('input[name="is_more"]:checked').val() == undefined) { $more_where.addClass('none'); } else { $more_where.removeClass('none'); } }); // 日期选择 var $time_start = $('#time_start'); var $time_end = $('#time_end'); var nowTemp = new Date(); var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0); var checkin = $time_start.datepicker({}).on('changeDate.datepicker.amui', function(ev) { var newDate = new Date(ev.date) newDate = (ev.date.valueOf() > checkout.date.valueOf() || ev.date.valueOf() == checkout.date.valueOf()) ? newDate.setDate(newDate.getDate() + 1) : checkout.date.valueOf(); checkout.setValue(newDate); checkin.close(); $time_end[0].blur(); }).data('amui.datepicker'); var checkout = $time_end.datepicker({ onRender:function(date) { return date.valueOf() <= checkin.date.valueOf() ? 'am-disabled' : ''; } }).on('changeDate.datepicker.amui', function(ev) { checkout.close(); }).data('amui.datepicker'); //文件上传 var uploader = WebUploader.create({ // 选完文件后,是否自动上传。 auto: true, // 表单文件名称 fileVal: 'upfile', // 文件接收服务端。 server: '/admin.php?m=Admin&c=Ueditor&a=Index&action=uploadimage', // 内部根据当前运行是创建,可能是input元素,也可能是flash. pick: '#uploader', // 不压缩image, 默认如果是jpeg,文件上传前会压缩一把再上传! resize: false, }); //上传成功 uploader.on( 'uploadSuccess', function( file , response) { if(response.state != 'SUCCESS'){ Prompt(response.state); return false; } var $li = $( '' ), $img = $li.find('img'); var $list = $("#fileList"); // $list为容器jQuery实例 $list.html( $li ); $("#thumb").val(response.url); }); // 文件上传失败,显示上传出错。 uploader.on('uploadError', function( file, response ) { Prompt(response.state); }); $('#decorate_type_id').chosen({ disable_search_threshold: 10, no_results_text: '没有选项', width: '200px !important' }); //专属联动 $('#decorate_target_type_id').chosen({ disable_search_threshold: 10, no_results_text: '没有选项', width: '200px !important' }); //有选项初始化 if($("#decorate_target_id option").length > 1){ $('#decorate_target_id').chosen({ disable_search_threshold: 10, no_results_text: '没有选项', width: '200px !important' }); } if($("#decorate_target_property_id option").length > 1){ $('#decorate_target_property_id').chosen({ disable_search_threshold: 10, no_results_text: '没有选项', width: '200px !important' }); } $('#decorate_target_type_id').on('change', function(){ var decorate_target_type_id = $(this).val(); //销毁插件 、 删除选项 if($("#decorate_target_property_id_chosen").length != 0){ $("#decorate_target_property_id option:gt(0)").remove(); $('#decorate_target_property_id').chosen('destroy'); } if($("#decorate_target_id_chosen").length != 0){ $("#decorate_target_id option:gt(0)").remove(); $('#decorate_target_id').chosen("destroy"); } //获取数据 $.get('/admin.php?m=Admin&c=CultureDecorate&a=getDecorateTarget', {decorate_target_type_id : decorate_target_type_id}, function(responsedata){ if(responsedata.code != 0){ return false; } //设置option for(x in responsedata.data){ $("#decorate_target_id").append(""); } //初始化插件 $('#decorate_target_id').chosen({ disable_search_threshold: 10, no_results_text: '没有选项', width: '200px !important', }); },'JSON'); //获取装饰类型数据 $.get('/admin.php?m=Admin&c=CultureDecorate&a=getDecorateType', {decorate_target_type_id : decorate_target_type_id}, function(responsedata){ if($("#decorate_type_id_chosen").length != 0){ $("#decorate_type_id option:gt(0)").remove(); $('#decorate_type_id').chosen("destroy"); } if(responsedata.code != 0){ $('#decorate_type_id').chosen({ disable_search_threshold: 10, no_results_text: '没有选项', width: '200px !important', }) return false; } //设置option for(x in responsedata.data){ $("#decorate_type_id").append(""); } //初始化插件 $('#decorate_type_id').chosen({ disable_search_threshold: 10, no_results_text: '没有选项', width: '200px !important', }) },'JSON'); }); $('#decorate_target_id').on('change', function(){ var decorate_target_type_id = $("#decorate_target_type_id").val(); var decorate_target_id = $(this).val(); //销毁插件 、 删除选项 if($("#decorate_target_property_id_chosen").length != 0){ $("#decorate_target_property_id option:gt(0)").remove(); $('#decorate_target_property_id').chosen('destroy'); } //获取数据 $.get('/admin.php?m=Admin&c=CultureDecorate&a=getDecorateTargetProperty', { decorate_target_type_id : decorate_target_type_id, decorate_target_id : decorate_target_id }, function(responsedata){ if(responsedata.code != 0){ return false; } //设置option for(x in responsedata.data){ $("#decorate_target_property_id").append(""); } //初始化插件 $('#decorate_target_property_id').chosen({ disable_search_threshold: 10, no_results_text: '没有选项', width: '200px !important' }); },'JSON'); //获取装饰类型数据 $.get('/admin.php?m=Admin&c=CultureDecorate&a=getDecorateType', { decorate_target_type_id : decorate_target_type_id, decorate_target_id : decorate_target_id }, function(responsedata){ if($("#decorate_type_id_chosen").length != 0){ $("#decorate_type_id option:gt(0)").remove(); $('#decorate_type_id').chosen("destroy"); } if(responsedata.code != 0){ return false; } //设置option for(x in responsedata.data){ $("#decorate_type_id").append(""); } //初始化插件 $('#decorate_type_id').chosen({ disable_search_threshold: 10, no_results_text: '没有选项', width: '200px !important', }) },'JSON'); }); $('#decorate_target_property_id').on('change', function(){ var decorate_target_type_id = $("#decorate_target_type_id").val(); var decorate_target_id = $("#decorate_target_id").val(); var decorate_target_property_id = $(this).val(); //获取装饰类型数据 $.get('/admin.php?m=Admin&c=CultureDecorate&a=getDecorateType', { decorate_target_type_id : decorate_target_type_id, decorate_target_id : decorate_target_id, decorate_target_property_id : decorate_target_property_id }, function(responsedata){ if($("#decorate_type_id_chosen").length != 0){ $("#decorate_type_id option:gt(0)").remove(); $('#decorate_type_id').chosen("destroy"); } if(responsedata.code != 0){ return false; } //设置option for(x in responsedata.data){ $("#decorate_type_id").append(""); } //初始化插件 $('#decorate_type_id').chosen({ disable_search_threshold: 10, no_results_text: '没有选项', width: '200px !important', }) },'JSON'); }); });