html代码
<div class="am-scrollable-horizontal am-u-sm-12">
<table width="100%" class="am-table am-table-compact am-table-striped
tpl-table-black am-text-nowrap">
<thead>
<tr>
<th>活动编号</th>
<th>活动名称</th>
<th>封面图</th>
<th>活动类型</th>
<th>活动/报名时间</th>
<th>活动地点</th>
<th>发布方式</th>
<th>是否发布</th>
<th>状态</th>
<th>目标金额</th>
<th>已捐金额</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php if (!empty($list)): foreach ($list as $key=>$item): ?>
<tr>
<td class="am-text-middle">HD-<?= $item['activity_id'] ?></td>
<td class="am-text-middle"><?= $item['activity_name'] ?></td>
<td class="am-text-middle">
<a href="<?= $item['image']['file_path'] ?>" title="点击查看大图" target="_blank">
<img src="<?= $item['image']['file_path'] ?>" height="72" alt="">
</a>
</td>
<td class="am-text-middle">
<?php if($item['activity_type'] == 1 ): ?>
线上活动
<?php endif; ?>
<?php if($item['activity_type'] == 2 ): ?>
线下活动
<?php endif; ?>
</td>
<td class="am-text-middle">开始:<?= $item['activity_start_date'] ?> <br/> 结束:<?= $item['activity_end_date'] ?></td>
<td class="am-text-middle"><?= $item['activity_address'] ?></td>
<td class="am-text-middle">
<?php if($item['activity_publish'] == 1 ): ?>
手动
<?php endif; ?>
<?php if($item['activity_publish'] == 2): ?>
<?= $item['publish_time'] ?> <br/>定时发布
<?php endif; ?>
</td>
<td class="am-text-middle">
<input type="checkbox" name="sex" id="male.<?= $key ?>" class="chooseBtn "
<?php if($item['is_publish'] == 1 ): ?>
checked="checked"
<?php endif; ?>
onclick="choose_fun(<?= $item['activity_id'] ?>,<?= $key?>)" />
<label for="male.<?= $key ?>" class="choose-label"></label>
</td>
<td class="am-text-middle"><?= $item['activity_status'] ?></td>
<td class="am-text-middle">
<?php if($item['activity_type'] == 1): print_r($item['target_money']); endif; ?>
<?php if($item['activity_type'] == 2): print_r('无'); endif; ?>
</td>
<td class="am-text-middle"><?= $item['sum_price'] ?></td>
<td class="am-text-middle">
<div class="tpl-table-black-operation">
<?php if (checkPrivilege('content.activity/edit')): ?>
<a href="#" onclick="editbtn_fun(<?= $item['activity_id'] ?>,<?= $key ?>);">
<i class="am-icon-pencil"></i> 编辑
</a>
<?php endif; ?>
<?php if (checkPrivilege('content.activity/delete')): ?>
<a href="#" class="item-delete tpl-table-black-operation-del" onclick="deletebtn_fun(<?= $item['activity_id'] ?>,<?= $key ?>,this);">
<i class="am-icon-trash"></i> 删除
</a>
<?php endif; ?>
<div id="btn6" style="data-clipboard-text="1"></div>
<button style="margin-top:4%" class="button" data-clipboard-text="<?php if($item['activity_type'] == 1 ): ?>/pages/activityDetails/activityDetails?activity_id=<?= $item['activity_id'] ?>&activity_type=1<?php endif; ?><?php if($item['activity_type'] == 2 ): ?>/pages/activityDetails/activityDetails?activity_id=<?= $item['activity_id'] ?>&activity_type=2<?php endif; ?>">
<i class="am-icon-copy"></i> 复制小程序地址
</button>
</div>
</td>
</tr>
<?php endforeach; else: ?>
<tr>
<td colspan="12" class="am-text-center">暂无记录</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
jq代码
<script>
//修改(如果发布状态不可修改)
function editbtn_fun(activity_id,key) {
var test= $(".chooseBtn").eq(key).is(":checked");
if(test){
layer.msg('发布状态不可修改');
return false;
}else{
var data = {};
data['activity_id'] = activity_id;
window.location = "<?= url('content.activity/edit') ?>" + '&' + $.urlEncode(data);
return false;
}
}
//删除(如果是发布状态不可删除)
function deletebtn_fun(activity_id,key,obj){
var test= $(".chooseBtn").eq(key).is(":checked");
if(test){
layer.msg('发布状态不可删除');
return false;
}else{
if(window.confirm('你确定要删除这项活动吗?')){
$.ajax({
url: "<?= url('content.activity/delete') ?>",
type:"POST",
dataType: 'text',
data:{
activity_id:activity_id
},
dataType:"json",
success: function(data){
if(data === 1){
layer.msg("删除成功!");
var tr = obj.parentNode.parentNode.parentNode;
var tbody = tr.parentNode;
tbody.removeChild(tr);
}else{
layer.msg("删除失败!");
}
}
})
}
}
}
</script>