前台页面:
<div class="adddaren_box">
{%if isset($masterDetailsInfo)%}
<div class="adddaren_box1">
删除/修改达人列表
</div>
<input type="hidden" value="{%$masterDetailsInfo->getMasterId()%}" id="master_id">
<div class="adddaren_box2">
用户名
<input type="text" readOnly="true" value="{%$masterDetailsInfo->getUserName()%}" class="adddaren_box2_inp" />
</div>
<div class="adddaren_box3">
推荐理由
<input type="text" value="{%$masterDetailsInfo->getMasterInfo()%}" class="adddaren_box3_inp" />
</div>
<div class="adddaren_box4">
推荐时间
<input type="text" value="{%$masterDetailsInfo->getStartTime()%}" class="adddaren_box4_inp" />
</div>
<div class="adddaren_box5">
结束时间
<input type="text" value="{%$masterDetailsInfo->getEndTime()%}" class="adddaren_box5_inp" />
</div>
<div class="adddaren_box6">
<div class="adddaren_box6_sp1" id="modify">修改</div>
<div class="adddaren_box6_sp2" id="del">删除</div>
</div>
{%else%}
<div class="adddaren_box1">
添加达人列表
</div>
<div class="adddaren_box2">
用户名
<input type="text" value="" class="adddaren_box2_inp" />
</div>
<div class="adddaren_box3">
推荐理由
<input type="text" value="" class="adddaren_box3_inp" />
</div>
<div class="adddaren_box4">
推荐时间
<input type="text" value="" class="adddaren_box4_inp" />
</div>
<div class="adddaren_box5">
结束时间 <input type="text" value="" class="adddaren_box5_inp" /> </div> <div class="adddaren_box6"> <div class="adddaren_box6_sp1" id="add">添加</div> </div> {%/if%}</div>{%script%}require.async('huanzhe_houtai:widget/adddaren/adddaren',function(adddaren){adddaren.run();}){%/script%}
js:
exports.run = function(){
$(function(){
var pages = require('common:widget/page/page');
$(".addbanner").click(function(){
location.href="/huanzhe_houtai/ad_guanli";
});
//排序用
var i=$(this).parents().index();
$(document).on("click", '#prev', function master_order(){
var current_obj = $(this).parent().parent().eq(i);
//alert(current_obj.attr('class'));
if(current_obj.attr('class') == 'data_list_row'){
//alert(1);
var current_id = $(this).data("id");
var current_order = $(this).data("order");
var up = current_obj.prev().children('.edition_box3_sp6');
var prev = up.children('#prev');
var prev_id = prev.data("id");
var prev_order = prev.data("order");
//alert('当前id:'+current_id);
//alert('上一条id'+prev_id);
if(!prev_id){
alert('亲,已经置顶了哟!');
}else{
$(".loading").show();
if(parseInt(current_order) != parseInt(prev_order)) {
$.get("/index.php/master/order_master",
{current_id: current_id,current_order: current_order,swap_id: prev_id, swap_order: prev_order},
function (data) {
console.log(data);
var cur = current_obj.children('.edition_box3_sp6').children('#prev');
var cur_next = current_obj.children('.edition_box3_sp6').children('#next');
cur.data({"order":prev_order});
cur_next.data({"order":prev_order});
prev.data({"order":current_order});
up.children('#next').data({"order":current_order});
current_obj.prev().before(current_obj);
$(".loading").hide();
},'html');
}
}
}
});
$(document).on("click", '#next', function master_order(){
var current_obj = $(this).parent().parent().eq(i); //alert(current_obj.attr('class')); if(current_obj.attr('class') == 'data_list_row'){
//alert(1); var current_id = $(this).data("id"); var current_order = $(this).data("order"); var down = current_obj.next().children('.edition_box3_sp6'); var next = down.children('#next'); var next_id = next.data("id"); var next_order = next.data("order"); if(!next_id){ alert('亲,已经到底了!'); }else{ $(".loading").show(); if(parseInt(current_order) != parseInt(next_order)) { $.get("/index.php/master/order_master", {current_id: current_id,current_order: current_order,swap_id: next_id, swap_order: next_order}, function (data) { console.log(data); var cur = current_obj.children('.edition_box3_sp6').children('#prev'); var cur_next = current_obj.children('.edition_box3_sp6').children('#next'); cur.data({"order":next_order}); cur_next.data({"order":next_order}); // alert(next_order); next.data({"order":current_order}); down.children('#prev').data({"order":current_order}); //alert(current_order); current_obj.next().after(current_obj); $(".loading").hide(); },'html'); } } } }); //这里是分页用的 pages.setCallback(function(page,page_size) { $(".loading").show(); console.log(page+','+page_size); //var param = $('.notice_param').val(); $.get("/index.php/master/load_master_page_list",{"page":page,"page_size":page_size},function(data){ console.log(data); //$(".InitPHP_pages").replaceWith(data); //$(data).replaceAll('.edition_box3'); $(".InitPHP_pages").remove(); $(".edition_box3").remove(); $(".edition_box2").after(data); $(".loading").hide(); },'html'); }); });};