作者 lihan

后端完善活动批次管理相关内容、加入实际报名人数、虚拟报名人数功能,联动前端报名时选择数量功能

... ... @@ -10,165 +10,142 @@ namespace app\admin\controller;
use cmf\controller\AdminBaseController;
use think\Db;
class ActivityController extends AdminBaseController {
class ActivityController extends AdminBaseController
{
public function index() {
$search=[];
$search['is_del']=['eq', 0];
$post=request()->param();
$t_id=(isset($post['t_id'])) ? $post['t_id'] : 0;
$name=(isset($post['name'])) ? $post['name'] : null;
if($t_id != 0) {
$search['t_id']=['eq', $_POST['t_id']];
public function index()
{
$search = [];
$search['is_del'] = ['eq', 0];
$post = request()->param();
$t_id = (isset($post['t_id'])) ? $post['t_id'] : 0;
$name = (isset($post['name'])) ? $post['name'] : null;
if ($t_id != 0) {
$search['t_id'] = ['eq', $_POST['t_id']];
}
if($name != null) {
$search['name']=['like', "%$_POST[name]%"];
if ($name != null) {
$search['name'] = ['like', "%$_POST[name]%"];
}
$res=Db::name('activity')->alias('a')
$res = Db::name('activity')->alias('a')
->field('a.*,t.type_name,q.qr_code')
->join('type t', 'a.t_id=t.id')
->join('qr q', 'q.activity_id=a.id')
->where($search)
->paginate(20, false, [
'query' => request()->param()
'query' => request()->param()
]);
return $this->fetch('index', [
'activity' => $res,
'page' => $res->render(),
'type' => Db::name('type')->field('id,type_name')->select(),
'search' => ['t_id' => $t_id, 'name' => $name]
'activity' => $res,
'page' => $res->render(),
'type' => Db::name('type')->field('id,type_name')->select(),
'search' => ['t_id' => $t_id, 'name' => $name]
]);
}
public function add() {
$request=request();
if($request->isPost()) {
$post=$request->param();
$post['is_down_payment']=(isset($post['is_down_payment'])) ? 1 : 0;
$post['is_new']=(isset($post['is_new'])) ? 1 : 0;
$post['is_hot']=(isset($post['is_hot'])) ? 1 : 0;
$post['is_on_sale']=(isset($post['is_on_sale'])) ? 1 : 0;
if(!empty($post['thumb'])) {
public function add()
{
$request = request();
if ($request->isPost()) {
$post = $request->param();
$post['is_down_payment'] = (isset($post['is_down_payment'])) ? 1 : 0;
$post['is_new'] = (isset($post['is_new'])) ? 1 : 0;
$post['is_hot'] = (isset($post['is_hot'])) ? 1 : 0;
$post['is_on_sale'] = (isset($post['is_on_sale'])) ? 1 : 0;
$post['date_type'] = 1;
if (!empty($post['thumb'])) {
$post['thumb'] = cmf_get_image_url($post['thumb']);
}
if(!empty($post['content'])) {
if (!empty($post['content'])) {
$post['content'] = htmlspecialchars_decode($post['content']);
}
if(!empty($post['banner'])) {
$banner='';
for($j=0; $j<count($post['banner']); $j++) {
$banner.=cmf_get_image_url($post['banner'][$j]).',';
if (!empty($post['banner'])) {
$banner = '';
for ($j = 0; $j < count($post['banner']); $j++) {
$banner .= cmf_get_image_url($post['banner'][$j]) . ',';
}
$post['banner']=substr($banner, 0, strlen($banner)-1);
$post['banner'] = substr($banner, 0, strlen($banner) - 1);
}
Db::startTrans();
$schedule=$post['schedule'];
$schedule = $post['schedule'];
unset($post['schedule']);
if(Db::name('activity')->insert($post)) {
$activity_id=Db::name('activity')->getLastInsID();
$data=[];
for ($i=0; $i<count($schedule); $i++) {
$data[$i]=[
'activity_id' => $activity_id,
'start_time' => strtotime($schedule[$i]['start_time']),
'end_time' => strtotime($schedule[$i]['end_time']),
'price' => $schedule[$i]['price'],
'maximum' => $schedule[$i]['maximum'],
'deadline' => strtotime($schedule[$i]['deadline'])
if (Db::name('activity')->insert($post)) {
$activity_id = Db::name('activity')->getLastInsID();
$data = [];
for ($i = 0; $i < count($schedule); $i++) {
$data[$i] = [
'activity_id' => $activity_id,
'start_time' => strtotime($schedule[$i]['start_time']),
'end_time' => strtotime($schedule[$i]['end_time']),
'price' => $schedule[$i]['price'],
'maximum' => $schedule[$i]['maximum'],
'deadline' => strtotime($schedule[$i]['deadline'])
];
}
if(Db::name('activity_schedule')->insertAll($data)) {
if (Db::name('activity_schedule')->insertAll($data)) {
//生成二维码
$qr=[
'activity_id' => $activity_id,
'qr_code' => $this->qrCode($activity_id),
$qr = [
'activity_id' => $activity_id,
'qr_code' => $this->qrCode($activity_id),
];
if(Db::name('qr')->insert($qr)) {
if (Db::name('qr')->insert($qr)) {
Db::commit();
$this->success('添加成功');
}else {
} else {
Db::rollback();
$this->error('添加失败');
}
}else {
} else {
Db::rollback();
$this->error('添加失败');
}
}else {
} else {
Db::rollback();
$this->error('添加失败');
}
}else {
} else {
return $this->fetch('add', [
'type' => Db::name('type')->field('id,type_name')->select()
'type' => Db::name('type')->field('id,type_name')->select()
]);
}
}
public function edit() {
$request=request();
if($request->isPost()) {
$post=$request->param();
$post['is_down_payment']=(isset($post['is_down_payment'])) ? 1 : 0;
$post['is_new']=(isset($post['is_new'])) ? 1 : 0;
$post['is_hot']=(isset($post['is_hot'])) ? 1 : 0;
$post['is_on_sale']=(isset($post['is_on_sale'])) ? 1 : 0;
if($post['is_down_payment'] == 0) {
$post['down_price']=0;
public function edit()
{
$request = request();
if ($request->isPost()) {
$post = $request->param();
$post['is_down_payment'] = (isset($post['is_down_payment'])) ? 1 : 0;
$post['is_new'] = (isset($post['is_new'])) ? 1 : 0;
$post['is_hot'] = (isset($post['is_hot'])) ? 1 : 0;
$post['is_on_sale'] = (isset($post['is_on_sale'])) ? 1 : 0;
$post['date_type'] = 1;
if ($post['is_down_payment'] == 0) {
$post['down_price'] = 0;
}
if(!empty($post['thumb'])) {
if (!empty($post['thumb'])) {
$post['thumb'] = cmf_get_image_url($post['thumb']);
}
if(!empty($post['content'])) {
if (!empty($post['content'])) {
$post['content'] = htmlspecialchars_decode($post['content']);
}
if(!empty($post['banner'])) {
$banner='';
for($j=0; $j<count($post['banner']); $j++) {
$banner.=cmf_get_image_url($post['banner'][$j]).',';
if (!empty($post['banner'])) {
$banner = '';
for ($j = 0; $j < count($post['banner']); $j++) {
$banner .= cmf_get_image_url($post['banner'][$j]) . ',';
}
$post['banner']=substr($banner, 0, strlen($banner)-1);
$post['banner'] = substr($banner, 0, strlen($banner) - 1);
}
$schedule=(isset($post['schedule'])) ? $post['schedule'] : null;
if(empty($schedule)) {
$this->error('请添加批次');
}
$schedule=$post['schedule'];
unset($post['schedule']);
Db::startTrans();
if(Db::name('activity')->update($post) >= 0) {
if(Db::name('activity_schedule')->where(['activity_id'=>$request->param('id')])->delete()) {
$data=[];
for ($i=0; $i<count($schedule); $i++) {
$data[$i]=[
'activity_id' => $request->param('id'),
'start_time' => strtotime($schedule[$i]['start_time']),
'end_time' => strtotime($schedule[$i]['end_time']),
'price' => $schedule[$i]['price'],
'maximum' => $schedule[$i]['maximum'],
'deadline' => strtotime($schedule[$i]['deadline'])
];
}
if(Db::name('activity_schedule')->insertAll($data)) {
Db::commit();
$this->success('编辑成功');
}else {
Db::rollback();
$this->error('编辑失败');
}
}else {
Db::rollback();
$this->error('编辑失败');
}
}else {
Db::rollback();
$this->error('编辑失败');
if (Db::name('activity')->update($post)) {
$this->success('编辑成功');
} else {
$this->error('您为做出任何修改');
}
}else {
} else {
$info = Db::name('activity')->where(['id' => $request->param('id')])->find();
$banner = $info['banner'];
$arr = [];
if(!empty($banner)) {
if (!empty($banner)) {
$temp = explode(',', $banner);
for ($i = 0; $i < count($temp); $i++) {
$arr[$i]['url'] = $temp[$i];
... ... @@ -183,11 +160,12 @@ class ActivityController extends AdminBaseController {
}
}
public function del() {
$id=request()->param('id');
if(Db::name('activity')->update(['id'=>$id,'is_del'=>1])) {
public function del()
{
$id = request()->param('id');
if (Db::name('activity')->update(['id' => $id, 'is_del' => 1])) {
$this->success('删除成功');
}else {
} else {
$this->error('删除失败');
}
}
... ... @@ -197,7 +175,8 @@ class ActivityController extends AdminBaseController {
* @param $id
* @return string
*/
private function qrCode($id) {
private function qrCode($id)
{
$savePath = APP_PATH . '/../Public/qrcode/';
$webPath = '/qrcode/';
$qrData = 'https://www.baidu.com';
... ... @@ -208,8 +187,57 @@ class ActivityController extends AdminBaseController {
if ($filename = createQRcode($savePath, $qrData, $qrLevel, $qrSize, $savePrefix)) {
$pic = $webPath . $filename;
}
$qr_code=cmf_get_image_url($pic);
$qr_code = cmf_get_image_url($pic);
return $qr_code;
}
public function addSchedule()
{
$request = request();
if ($request->isPost()) {
$post = $request->param();
$schedule = $post['schedule'];
$data = [];
for ($i = 0; $i < count($schedule); $i++) {
$data[$i] = [
'activity_id' => $request->param('activity_id'),
'start_time' => strtotime($schedule[$i]['start_time']),
'end_time' => strtotime($schedule[$i]['end_time']),
'price' => $schedule[$i]['price'],
'maximum' => $schedule[$i]['maximum'],
'deadline' => strtotime($schedule[$i]['deadline'])
];
}
if (Db::name('activity_schedule')->insertAll($data)) {
$this->success('新增批次成功');
} else {
$this->error('新增批次失败');
}
} else {
return $this->fetch('add_schedule', [
'activity_id' => $request->param('id'),
'schedule' => Db::name('activity_schedule')->where(['activity_id' => $request->param('id')])->select(),
]);
}
}
public function delSchedule()
{
$schedule_id = request()->param('id');
if (Db::name('activity_schedule')->delete($schedule_id)) {
return $this->success('', '', true);
}
}
public function editSchedule()
{
$post = request()->param();
$post['start_time'] = strtotime($post['start_time']);
$post['end_time'] = strtotime($post['end_time']);
$post['deadline'] = strtotime($post['deadline']);
if (Db::name('activity_schedule')->update($post)) {
return $this->success('编辑批次成功', '', true);
}
}
}
\ No newline at end of file
... ...
... ... @@ -83,7 +83,7 @@
</tr>
</table>
<input id="B" type="button" value="新增" style="display: none;">
<input id="B" type="button" value="新增">
<div id="schedule" style="margin-bottom: 20px">
<li id="li_0">开始时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][start_time]">&nbsp;&nbsp;结束时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][end_time]">&nbsp;&nbsp;价格:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][price]">&nbsp;&nbsp;允许参加人数:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][maximum]">&nbsp;&nbsp;报名截止时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][deadline]"></li>
</div>
... ... @@ -145,16 +145,6 @@
</div>
</td>
</tr>
<tr>
<td>
<div class="radio">
<label><input type="radio" class="date_type" name="date_type" value="0" checked>单批次</label>&nbsp;&nbsp;
<label><input type="radio" class="date_type" name="date_type" value="1">多批次</label>
</div>
</td>
</tr>
</table>
</div>
</div>
... ... @@ -221,7 +211,7 @@
}else {
$("#B").show();
}
var text='<li id="li_0">开始时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][start_time]">&nbsp;&nbsp;结束时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][end_time]">&nbsp;&nbsp;价格:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][price]">&nbsp;&nbsp;允许参加人数:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][maximum]">&nbsp;&nbsp;<input id="B" type="button" value="新增" style="display: none;">报名截止时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][deadline]"></li>'
var text='<li id="li_0">开始时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][start_time]">&nbsp;&nbsp;结束时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][end_time]">&nbsp;&nbsp;价格:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][price]">&nbsp;&nbsp;允许参加人数:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][maximum]">&nbsp;&nbsp;报名截止时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][deadline]"></li>'
$("#schedule").html(text);
})
... ... @@ -243,7 +233,7 @@
$("#B").click(function () {
var length=$("#schedule li").length;
var html=$("#schedule").html();
var text='<li id="li_'+length+'">开始时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][start_time]">&nbsp;&nbsp;结束时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][end_time]">&nbsp;&nbsp;价格:<input required autocomplete="off" class="form-control detail" type="text" name="schedule['+length+'][price]">&nbsp;&nbsp;允许参加人数:<input required autocomplete="off" class="form-control detail" type="text" name="schedule['+length+'][maximum]">&nbsp;&nbsp;<input id="B" type="button" value="新增" style="display: none;">报名截止时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][deadline]">&nbsp;<span><font color="red" onclick="clearHtml('+length+')">删除</font></span></li>'
var text='<li id="li_'+length+'">开始时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][start_time]">&nbsp;&nbsp;结束时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][end_time]">&nbsp;&nbsp;价格:<input required autocomplete="off" class="form-control detail" type="text" name="schedule['+length+'][price]">&nbsp;&nbsp;允许参加人数:<input required autocomplete="off" class="form-control detail" type="text" name="schedule['+length+'][maximum]">&nbsp;&nbsp;报名截止时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][deadline]">&nbsp;<span><font color="red" onclick="clearHtml('+length+')">删除</font></span></li>'
$("#schedule").html(html+text);
})
... ...
<include file="public@header"/>
<style type="text/css">
.pic-list li {
margin-bottom: 5px;
}
.detail{width: 150px!important; display: unset!important;}
#schedule li{margin-bottom: 10px; list-style: none}
</style>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li><a href="#X">增加批次</a></li>
</ul>
<div style="padding: 20px">
<input id="B" type="button" value="新增">
<form action="{:url('Activity/addSchedule')}" method="post">
<div id="schedule" style="margin-bottom: 20px">
<li id="li_0">开始时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][start_time]">&nbsp;&nbsp;结束时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][end_time]">&nbsp;&nbsp;价格:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][price]">&nbsp;&nbsp;允许参加人数:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][maximum]">&nbsp;&nbsp;报名截止时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][deadline]"></li>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="hidden" name="activity_id" value="{$activity_id}">
<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
<a class="btn btn-default" href="{:url('Activity/index')}">{:lang('BACK')}</a>
</div>
</div>
</form>
</div>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script>
function showDate() {
var bootstrapDateTimeInput = $("input.js-bootstrap-datetime");
if (bootstrapDateTimeInput.length) {
Wind.css('bootstrapDatetimePicker');
Wind.use('bootstrapDatetimePicker', function () {
bootstrapDateTimeInput.datetimepicker({
language: 'zh-CN',
format: 'yyyy-mm-dd hh:ii',
todayBtn: 1,
autoclose: true
});
});
}
}
$("#B").click(function () {
var length=$("#schedule li").length;
var html=$("#schedule").html();
var text='<li id="li_'+length+'">开始时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][start_time]">&nbsp;&nbsp;结束时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][end_time]">&nbsp;&nbsp;价格:<input required autocomplete="off" class="form-control detail" type="text" name="schedule['+length+'][price]">&nbsp;&nbsp;允许参加人数:<input required autocomplete="off" class="form-control detail" type="text" name="schedule['+length+'][maximum]">&nbsp;&nbsp;报名截止时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][deadline]">&nbsp;<span><font color="red" onclick="clearHtml('+length+')">删除</font></span></li>'
$("#schedule").html(html+text);
})
function clearHtml(n) {
$("#li_"+n).html('');
}
</script>
... ...
... ... @@ -101,10 +101,19 @@
</tr>
</table>
<input id="B" type="button" value="新增" <if condition="$info['date_type'] eq '0'">style="display: none";</if>>
<input id="B" type="button" value="新增" style="display: none">
<div id="schedule" style="margin-bottom: 20px">
<foreach name="schedule" item="v" key="k">
<li id="li_{$k}">开始时间:<input value="{$v['start_time']|date='Y-m-d H:i:s', ###}" required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[{$k}][start_time]">&nbsp;&nbsp;结束时间:<input value="{$v['end_time']|date='Y-m-d H:i:s', ###}" required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[{$k}][end_time]">&nbsp;&nbsp;价格:<input value="{$v['price']}" required autocomplete="off" class="form-control detail" type="text" name="schedule[{$k}][price]">&nbsp;&nbsp;允许参加人数:<input value="{$v['maximum']}" required autocomplete="off" class="form-control detail" type="text" name="schedule[{$k}][maximum]">&nbsp;&nbsp;报名截止时间:<input value="{$v.deadline|date='Y-m-d H:i:s', ###}" required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[{$k}][deadline]">&nbsp;&nbsp;<font color="red" onclick="clearHtml({$k})">删除</font></li>
<li id="li_{$k}">
开始:<input id="start_time_{$v.id}" value="{$v['start_time']|date='Y-m-d H:i:s', ###}" required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[{$k}][start_time]">&nbsp;&nbsp;
结束:<input id="end_time_{$v.id}" value="{$v['end_time']|date='Y-m-d H:i:s', ###}" required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[{$k}][end_time]">&nbsp;&nbsp;
价格:<input style="width: 70px!important;" id="price_{$v.id}" value="{$v['price']}" required autocomplete="off" class="form-control detail" type="text" name="schedule[{$k}][price]">&nbsp;&nbsp;
名额:<input style="width: 50px!important;" id="maximum_{$v.id}" value="{$v['maximum']}" required autocomplete="off" class="form-control detail" type="text" name="schedule[{$k}][maximum]">&nbsp;&nbsp;
参加人数:<input style="width: 50px!important;" id="real_join_num_{$v.id}" value="{$v['real_join_num']}" required autocomplete="off" class="form-control detail" type="text" name="schedule[{$k}][real_join_num_]">&nbsp;&nbsp;
虚拟参加人数:<input style="width: 50px!important;" id="addition_join_num_{$v.id}" value="{$v['addition_join_num']}" required autocomplete="off" class="form-control detail" type="text" name="schedule[{$k}][addition_join_num]">&nbsp;&nbsp;
报名截止时间:<input id="deadline_{$v.id}" value="{$v.deadline|date='Y-m-d H:i:s', ###}" required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[{$k}][deadline]">&nbsp;&nbsp;
<font color="red" onclick="clearHtml({$k}, {$v.id})" style="cursor: pointer">删除</font>
<font color="#4169e1" onclick="edit({$v.id})" style="cursor: pointer">确定</font></li>
</foreach>
</div>
... ... @@ -172,16 +181,6 @@
</div>
</td>
</tr>
<tr>
<td>
<div class="radio">
<label><input <if condition="$info['date_type'] eq '0'">checked</if> type="radio" class="date_type" name="date_type" value="0" checked>单批次</label>&nbsp;&nbsp;
<label><input <if condition="$info['date_type'] eq '1'">checked</if> type="radio" class="date_type" name="date_type" value="1">多批次</label>
</div>
</td>
</tr>
</table>
</div>
</div>
... ... @@ -270,14 +269,54 @@
$("#B").click(function () {
var length=$("#schedule li").length;
var html=$("#schedule").html();
var text='<li id="li_'+length+'">开始时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][start_time]">&nbsp;&nbsp;结束时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][end_time]">&nbsp;&nbsp;价格:<input required autocomplete="off" class="form-control detail" type="text" name="schedule['+length+'][price]">&nbsp;&nbsp;允许参加人数:<input required autocomplete="off" class="form-control detail" type="text" name="schedule['+length+'][maximum]">&nbsp;&nbsp;报名截止时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][deadline]">&nbsp;&nbsp;<span><font color="red" onclick="clearHtml('+length+')">删除</font></span></li>'
var text='<li id="li_'+length+'">开始时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][start_time]">&nbsp;&nbsp;结束时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][end_time]">&nbsp;&nbsp;价格:<input required autocomplete="off" class="form-control detail" type="text" name="schedule['+length+'][price]">&nbsp;&nbsp;允许参加人数:<input required autocomplete="off" class="form-control detail" type="text" name="schedule['+length+'][maximum]">&nbsp;&nbsp;报名截止时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][deadline]">&nbsp;&nbsp;<span><font color="red" onclick="clearHtml('+length+', null)">删除</font></span></li>'
$("#schedule").html(html+text);
})
function clearHtml(n) {
$("#li_"+n).html('');
function clearHtml(n, id) {
if (id != null) {
$.ajax({
url: "{:url('Activity/delSchedule')}",
data: {
id: id
},
type: "POST",
dataType: "JSON",
success: function (data) {
if (data.data == true) {
$("#li_" + n).html('');
}
}
})
} else {
$("#li_" + n).html('');
}
}
function edit(id) {
$.ajax({
url: "{:url('Activity/editSchedule')}",
data: {
id: id,
start_time:$("#start_time_"+id).val(),
end_time:$("#end_time_"+id).val(),
price:$("#price_"+id).val(),
maximum:$("#maximum_"+id).val(),
real_join_num:$("#real_join_num_"+id).val(),
addition_join_num:$("#addition_join_num_"+id).val(),
deadline:$("#deadline_"+id).val()
},
type: "POST",
dataType: "JSON",
success: function (data) {
if(data.data == true) {
alert(data.msg);
}
}
})
}
</script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -47,7 +47,11 @@
<td><if condition="$vo['is_hot'] eq '0'"><font color="red">×</font><else/><font color="green"></font></if></td>
<td><if condition="$vo['is_on_sale'] eq '0'"><font color="red">下架</font><else/><font color="green">在售</font></if></td>
<td><img src="{$vo.qr_code}" width="100px" height="100px"></td>
<td><a href="{:url('Activity/edit',['id'=>$vo['id']])}">编辑</a> | <a href="{:url('Activity/del',['id'=>$vo['id']])}" onclick="return isDel()">删除</a></td>
<td>
<a href="{:url('Activity/edit',['id'=>$vo['id']])}">编辑</a> |
<a href="{:url('Activity/del',['id'=>$vo['id']])}" onclick="return isDel()">删除</a> |
<a href="{:url('Activity/addSchedule',['id'=>$vo['id']])}">新增批次</a>
</td>
</tr>
</volist>
</table>
... ...