Commit aa586c35 authored by agping's avatar agping

bug

parent 3efe6da4
define (['doT', 'text!temp/schoolBusiness_template_tpl.html','ckfinder','ckfinderStart', 'css!style/home.css',"datetimepicker",'pagination','bootstrapJs'], function (doT, template) { define(['doT', 'text!temp/schoolBusiness_template_tpl.html', 'ckfinder', 'ckfinderStart', 'css!style/home.css', "datetimepicker", 'pagination', 'bootstrapJs'], function(doT, template) {
var user = { var user = {
pageNo: 1, /*第几页*/ pageNo: 1,
pageSize: 15, /*每页显示多少条*/ /*第几页*/
user_id : 0, pageSize: 15,
/*每页显示多少条*/
user_id: 0,
urls: '', urls: '',
agent_id_two:'', agent_id_two: '',
agent_id2 : 0, agent_id2: 0,
init: function () { init: function() {
//初始化dot //初始化dot
$ ("body").append (template); $("body").append(template);
//判断 是点击编辑按钮跳转的 还是新增文章 跳转的 通过id判断 //判断 是点击编辑按钮跳转的 还是新增文章 跳转的 通过id判断
user.event (); user.event();
//获取学院标签 //获取学院标签
user.getDistrict(function(){ user.getDistrict(function() {
$(document).on('input', '#district_id, #district_id2', function(){ $(document).on('input', '#district_id, #district_id2', function() {
var _this = $(this); var _this = $(this);
var _id = _this.val(); var _id = _this.val();
_this.next().html('');//先清空 _this.next().html(''); //先清空
if(_id && _id != '0'){ if(_id && _id != '0') {} else {};
}else{
};
//77777 //77777
}); });
}); });
if(getUrlParam('id')){
user.text_details();
}
}, },
event: function () { event: function() {
var _doc = $(document); var _doc = $(document);
var _imgMaskObj = $('#img_mask_area'); //预览大图的mask var _imgMaskObj = $('#img_mask_area'); //预览大图的mask
var _imgUploadLunbo = $('#xiangqing_pic_ul'); //详情页轮播图ul var _imgUploadLunbo = $('#xiangqing_pic_ul'); //详情页轮播图ul
$ (".Bannertu").click (function () { $(".Bannertu").click(function() {
BrowseServer ('cover_image'); BrowseServer('cover_image');
}); });
_doc.on('click', '.add-pic', function(){ _doc.on('click', '.add-pic', function() {
follow.getaddPicList(); follow.getaddPicList();
}); });
$("#search").click(function(){ $("#search").click(function() {
user.getList(1); user.getList(1);
}); });
$("#reset").click(function () { $("#reset").click(function() {
document.getElementById("form_search").reset(); document.getElementById("form_search").reset();
}); });
$("#close").click(function() {
$("#close").click(function () {
document.getElementById("add_user_form").reset(); document.getElementById("add_user_form").reset();
$(".user-ul").empty(); $(".user-ul").empty();
}); });
$(".close").click(function(){ $(".close").click(function() {
document.getElementById("add_user_form").reset(); document.getElementById("add_user_form").reset();
$(".user-ul").empty(); $(".user-ul").empty();
}); });
$ (document).delegate (".announcement-del", "click", function () { $(document).delegate(".announcement-del", "click", function() {
user.announcementdel_id = $ (this).attr ("data-id"); user.announcementdel_id = $(this).attr("data-id");
console.log(user.announcementdel_id); console.log(user.announcementdel_id);
}); });
$ (document).delegate (".add_alert", "click", function () {//新增客户 $(document).delegate(".add_alert", "click", function() { //新增客户
document.getElementById("add_user_form").reset(); document.getElementById("add_user_form").reset();
}); });
// 新增文章 // 新增文章
$ (document).delegate ("#add_news", "click", function () {//保存新增文章 $(document).delegate("#add_news", "click", function() { //保存新增文章
user.user_id = $ (this).attr ("data-id"); user.user_id = $(this).attr("data-id");
user.add_news(); user.add_news();
}); });
_doc.on('click', '.jian_class>ul>li', function(){ _doc.on('click', '.jian_class>ul>li', function() {
var _this = $(this); var _this = $(this);
_this.parent().prev().val(_this.html()).attr('data-id',_this.attr('data-id')); _this.parent().prev().val(_this.html()).attr('data-id', _this.attr('data-id'));
_this.parent().html('').hide(); _this.parent().html('').hide();
}); });
//图片上传,附件上传处理事件 //图片上传,附件上传处理事件
...@@ -117,7 +114,7 @@ define (['doT', 'text!temp/schoolBusiness_template_tpl.html','ckfinder','ckfinde ...@@ -117,7 +114,7 @@ define (['doT', 'text!temp/schoolBusiness_template_tpl.html','ckfinder','ckfinde
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
_this.parent().remove(); _this.parent().remove();
if(confirm('确定删除该文件吗?')){ if(confirm('确定删除该文件吗?')) {
var _imgId = _this.parent().attr('data-imgid'); var _imgId = _this.parent().attr('data-imgid');
}; };
...@@ -131,7 +128,7 @@ define (['doT', 'text!temp/schoolBusiness_template_tpl.html','ckfinder','ckfinde ...@@ -131,7 +128,7 @@ define (['doT', 'text!temp/schoolBusiness_template_tpl.html','ckfinder','ckfinde
}); });
}, },
//筛选 获取文章列表 //筛选 获取文章列表
getList: function (pageNo) { getList: function(pageNo) {
user.pageNo = pageNo; user.pageNo = pageNo;
var params = {}; var params = {};
params.start_time = $("#start_date").val(); params.start_time = $("#start_date").val();
...@@ -141,112 +138,112 @@ define (['doT', 'text!temp/schoolBusiness_template_tpl.html','ckfinder','ckfinde ...@@ -141,112 +138,112 @@ define (['doT', 'text!temp/schoolBusiness_template_tpl.html','ckfinder','ckfinde
params.pageNo = user.pageNo; params.pageNo = user.pageNo;
params.pageSize = user.pageSize; params.pageSize = user.pageSize;
$.ajax ({ $.ajax({
url: '/index/business_school', url: '/index/business_school',
type: 'GET', type: 'GET',
async: true, async: true,
data: params, data: params,
dataType: 'json', dataType: 'json',
success: function (data) { success: function(data) {
console.log('公告'); console.log('公告');
var temp = document.getElementById ('schoolBusiness_list_tpl').innerHTML; var temp = document.getElementById('schoolBusiness_list_tpl').innerHTML;
var doTtmpl = doT.template (temp); var doTtmpl = doT.template(temp);
$ ("#users_list").html (doTtmpl (data.data.list)); $("#users_list").html(doTtmpl(data.data.list));
/*分页代码*/ /*分页代码*/
add_page(data.data.total,pageNo,user.pageSize,user.getList); add_page(data.data.total, pageNo, user.pageSize, user.getList);
$("#total_page").html(data.data.total); $("#total_page").html(data.data.total);
} }
}); });
}, },
//点击编辑 调用的接口 //点击编辑 调用的接口
text_details: function() { text_details: function() {
var news_id = getUrlParam('id');//地址栏获取的商铺或者街铺id var news_id = getUrlParam('id'); //地址栏获取的商铺或者街铺id
var _imgUploadLunbo = $('#xiangqing_pic_ul'); //详情页轮播图ul var _imgUploadLunbo = $('#xiangqing_pic_ul'); //详情页轮播图ul
var _imgUploadLiebiao = $('#liebiao_pic_ul');//列表页封面图ul var _imgUploadLiebiao = $('#liebiao_pic_ul'); //列表页封面图ul
var _urlCut = location.origin + '/resource/lib/Attachments/images/';//要截取的部分url var _urlCut = location.origin + '/resource/lib/Attachments/images/'; //要截取的部分url
var _dajiangtangObj = $('#dajiangtang'); //大讲堂 var _dajiangtangObj = $('#dajiangtang'); //大讲堂
$.ajax({ $.ajax({
'type': 'GET', 'type': 'GET',
'url': '/index/getNewsInfo', 'url': '/index/getNewsInfo',
data: { data: {
'id':news_id, 'id': news_id,
}, },
dataType: "json", dataType: "json",
success: function(data) { success: function(data) {
if(data.code == 200) { if(data.code == 200) {
$("#announcement_title").val(data.data.title); $("#announcement_title").val(data.data.title);
$("#district_id2").val(data.data.s_label_id*1);//商学院标签id $("#district_id2").val(data.data.s_label_id * 1); //商学院标签id
var _data = data['data']; var _data = data['data'];
if(_data['cover_plan']){ if(_data['cover_plan']) {
_imgUploadLiebiao.html('<li><img title="点击查看大图" src="{0}" /><a href="javascript:;" class="delet-pic-btn">删除</a></li>'.stringFormatObj({ _imgUploadLiebiao.html('<li><img title="点击查看大图" src="{0}" /><a href="javascript:;" class="delet-pic-btn">删除</a></li>'.stringFormatObj({
'0': _data['cover_plan'] '0': _data['cover_plan']
})); }));
}; };
//获取编辑器里的内容 //获取编辑器里的内容
// setCKeditorValue(id,content) // setCKeditorValue(id,content)
setCKeditorValue("goods_sup_id",_data['content']); setCKeditorValue("goods_sup_id", _data['content']);
} else { } else {}
}
} }
}); });
}, },
getDistrict : function (fn) { getDistrict: function(fn) {
$.ajax ({ $.ajax({
url: '/index/getNewsLabel', url: '/index/getNewsLabel',
type: 'GET', type: 'GET',
async: true, async: true,
data: {}, data: {},
dataType: 'json', dataType: 'json',
success: function (data) { success: function(data) {
if (data.code == 200 && data.data != null) { if(data.code == 200 && data.data != null) {
var str = ''; var str = '';
$.each(data.data, function(i,item) { $.each(data.data, function(i, item) {
str += '<option value="'+item.id+'">'+item.label_name+'</option>'; str += '<option value="' + item.id + '">' + item.label_name + '</option>';
}); });
$("#district_id").append(str); $("#district_id").append(str);
$("#district_id2").append(str); $("#district_id2").append(str);
if(getUrlParam('id')) {
user.text_details();
}
fn && fn(); fn && fn();
} }
} }
}); });
}, },
add_news : function () {//新增文章 编辑文章 add_news: function() { //新增文章 编辑文章
var _imgUploadLiebiao = $('#liebiao_pic_ul');//列表页封面图ul var _imgUploadLiebiao = $('#liebiao_pic_ul'); //列表页封面图ul
var _liebiaoPicObj = _imgUploadLiebiao.find('li>img'); var _liebiaoPicObj = _imgUploadLiebiao.find('li>img');
var _urlCut = location.origin + '/resource/lib/Attachments/images/';//要截取的部分url var _urlCut = location.origin + '/resource/lib/Attachments/images/'; //要截取的部分url
var _dajiangtangObj = $('#dajiangtang'); //大讲堂 var _dajiangtangObj = $('#dajiangtang'); //大讲堂
var _dajiangtangVal = getCKeditorValue("goods_sup_id"); var _dajiangtangVal = getCKeditorValue("goods_sup_id");
console.log( _dajiangtangVal); console.log(_dajiangtangVal);
if(_liebiaoPicObj.length < 1) { if(_liebiaoPicObj.length < 1) {
alert('列表页封面图需要上传'); alert('列表页封面图需要上传');
return false; return false;
}; };
var _data = {}; var _data = {};
if(getUrlParam('id')){ if(getUrlParam('id')) {
_data.id = getUrlParam('id'); _data.id = getUrlParam('id');
}; };
_data.title = $("#announcement_title").val(); _data.title = $("#announcement_title").val();
_data.s_label_id = $("#district_id2").val();//商学院标签id _data.s_label_id = $("#district_id2").val(); //商学院标签id
_data.file_img = _liebiaoPicObj[0].src.replace(_urlCut, '');//封面图 剪切后的字符串 _data.file_img = _liebiaoPicObj[0].src.replace(_urlCut, ''); //封面图 剪切后的字符串
_data.content = _dajiangtangVal; _data.content = _dajiangtangVal;
$.ajax ({ $.ajax({
url: '/index/addNews', url: '/index/addNews',
type: 'POST', type: 'POST',
async: true, async: true,
data: _data, data: _data,
dataType: 'json', dataType: 'json',
success: function (data) { success: function(data) {
if (data.code == 200) { if(data.code == 200) {
$ ("#modal_add_user").modal ('hide');//提交成功 关闭模态框 $("#modal_add_user").modal('hide'); //提交成功 关闭模态框
// user.getList(1); // user.getList(1);
alert('提交成功') alert('提交成功')
window.location.href='/index/business_school'; window.location.href = '/index/business_school';
console.log(66); console.log(66);
} else { } else {
alert(data.msg); alert(data.msg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment