作者 v_bairong06

入会申请功能制作及后台管理

... ... @@ -9,29 +9,31 @@
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li><a href="{:U('WillProduceApply/index')}">双创项目列表</a></li>
<li class="active"><a target="_self">编辑双创项目</a></li>
<li class="active"><a target="_self">发布双创项目</a></li>
</ul>
<form action="{:U('WillProduceApply/edit_post')}" method="post" class="form-horizontal js-ajax-forms" enctype="multipart/form-data">
<form action="{:U('WillProduceApply/add_post')}" method="post" class="form-horizontal js-ajax-forms" enctype="multipart/form-data">
<div class="row-fluid">
<div class="span9">
<table class="table table-bordered">
<tr>
<th width="150">项目名称</th>
<td>
<input type="text" style="width:400px;" name="post[name]" id="name" value="{$post.name}" required placeholder="请输入项目名称"/>
<input type="text" style="width:400px;" name="post[name]" id="name" value="{$name}" required placeholder="请输入项目名称"/>
<span class="form-required">*</span>
<input type="hidden" name="id" value="{$id}"/>
<input type="hidden" name="post[user_id]" value="{$user_id}"/>
</td>
</tr>
<tr>
<th>简介</th>
<td>
<textarea name="post[description]" placeholder="请输入项目简介">{$post.description}</textarea>
<textarea name="post[description]" placeholder="请输入项目简介">{$product}</textarea>
</td>
</tr>
<tr>
<th>详情</th>
<td>
<script type="text/plain" id="content" name="post[content]">{$post.content}</script>
<script type="text/plain" id="content" name="post[content]">{$product_description}</script>
</td>
</tr>
</table>
... ... @@ -44,12 +46,12 @@
<tr>
<td>
<div style="text-align: center;">
<input type="hidden" name="post[thumb]" id="thumb" value="{$post.thumb|default=''}">
<input type="hidden" name="post[thumb]" id="thumb" value="{$images|default=''}">
<a href="javascript:upload_one_image('图片上传','#thumb');">
<if condition="empty($post['thumb'])">
<if condition="empty($images)">
<img src="__TMPL__Public/assets/images/default-thumbnail.png" id="thumb-preview" width="135" style="cursor: hand" />
<else />
<img src="{:sp_get_image_preview_url($post['thumb'])}" id="thumb-preview" width="135" style="cursor: hand"/>
<img src="{:sp_get_image_preview_url($images)}" id="thumb-preview" width="135" style="cursor: hand"/>
</if>
</a>
<input type="button" class="btn btn-small" onclick="$('#thumb-preview').attr('src','__TMPL__Public/assets/images/default-thumbnail.png');$('#thumb').val('');return false;" value="取消图片">
... ... @@ -60,7 +62,7 @@
</div>
</div>
<div class="form-actions">
<button class="btn btn-primary js-ajax-submit" type="submit">提交</button>
<button class="btn btn-primary js-ajax-submit" type="submit">发布</button>
<a class="btn" href="{:U('WillProduceApply/index')}">返回</a>
</div>
</form>
... ... @@ -169,7 +171,7 @@
//验证未通过提示消息
messages : {
'post[name]' : {
required : '请输入活动名称'
required : '请输入项目名称'
}
},
//给未通过验证的元素加效果,闪烁等
... ...
<admintpl file="header" />
</head>
<body>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li class="active"><a href="javascript:;">双创项目提交列表</a></li>
</ul>
<form class="well form-search" method="post" action="{:U('WillProduceApply/index')}">
时间:
<input type="text" name="start_time" class="js-datetime" value="{$formget.start_time|default=''}" style="width: 120px;" autocomplete="off">-
<input type="text" class="js-datetime" name="end_time" value="{$formget.end_time|default=''}" style="width: 120px;" autocomplete="off"> &nbsp; &nbsp;
关键字:
<input type="text" name="keyword" style="width: 200px;" value="{$keyword|default=''}" placeholder="请输入关键字...">
<input type="submit" class="btn btn-primary" value="搜索" />
<a class="btn btn-danger" href="{:U('WillProduceApply/index')}">清空</a>
</form>
<form class="js-ajax-form" action="" method="post">
<div class="table-actions">
<button class="btn btn-danger btn-small js-ajax-submit" type="submit" data-action="{:U('WillProduceApply/delete')}" data-subcheck="true" data-msg="您确定删除吗?">{:L('DELETE')}</button>
</div>
<table class="table table-hover table-bordered table-list">
<thead>
<tr>
<th width="15"><label><input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x"></label></th>
<th width="50">ID</th>
<th>用户id</th>
<th width="50">投稿人姓名</th>
<th>所在省市</th>
<th>年龄</th>
<th>性别</th>
<th>高校</th>
<th>专业</th>
<th>手机号码</th>
<th>年级</th>
<th>邮箱</th>
<th width="100">提交时间</th>
<th>状态</th>
<th width="70">操作</th>
</tr>
</thead>
<foreach name="list" item="vo">
<tr>
<td><input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]" value="{$vo.id}" title="ID:{$vo.id}"></td>
<td><b>{$vo.id}</b></td>
<td>{$vo.user_id}</td>
<td>{$vo.name}</td>
<td>{$vo.province}{$vo.city}</td>
<td>{$vo.age}</td>
<td><eq name="vo.sex" value="1"></eq><eq name="vo.sex" value="2"></eq></td>
<td>{$vo.school}</td>
<td>{$vo.major}</td>
<td>{$vo.mobile}</td>
<td>{$vo.classes}</td>
<td>{$vo.email}</td>
<td>{:date('Y-m-d H:i',$vo['ctime'])}</td>
<td>
<eq name="vo.status" value="1">待审核</eq><eq name="vo.status" value="2">审核通过</eq>
<eq name="vo.status" value="3">审核不通过</eq><eq name="vo.status" value="4">重新提交审核</eq>
</td>
<td>
<a href="{:U('WillProduceApply/view',array('id'=>$vo['id']))}">查看</a> |
<eq name="vo.is_issue" value="0"><a href="{:U('WillProduceApply/send',array('id'=>$vo['id']))}">发布</a> |</eq>
<a href="{:U('WillProduceApply/delete',array('id'=>$vo['id']))}" class="js-ajax-delete">删除</a>
</td>
</tr>
</foreach>
<tfoot>
<tr>
<th width="15"><label><input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x"></label></th>
<th width="50">ID</th>
<th>用户id</th>
<th width="50">投稿人姓名</th>
<th>所在省市</th>
<th>年龄</th>
<th>性别</th>
<th>高校</th>
<th>专业</th>
<th>手机号码</th>
<th>年级</th>
<th>邮箱</th>
<th width="50">提交时间</th>
<th>状态</th>
<th width="70">操作</th>
</tr>
</tfoot>
</table>
<div class="table-actions">
<button class="btn btn-danger btn-small js-ajax-submit" type="submit" data-action="{:U('WillProduceApply/delete')}" data-subcheck="true" data-msg="你确定删除吗?">{:L('DELETE')}</button>
</div>
<div class="pagination">{$page}</div>
</form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
</body>
</html>
\ No newline at end of file
... ...
<admintpl file="header" />
</head>
<body>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li><a href="{:U('WillProduceApply/index')}">双创项目提交列表</a></li>
<li class="active"><a href="">双创项目提交详情</a></li>
</ul>
<form action="" method="post" class="form-horizontal js-ajax-forms">
<div class="row-fluid">
<div class="span9">
<table class="table table-bordered">
<tr>
<th width="80">用户ID</th>
<td>{$user_id}</td>
</tr>
<tr>
<th>姓名</th>
<td>{$name}</td>
</tr>
<tr>
<th>所在省市</th>
<td>{$province}{$city}</td>
</tr>
<tr>
<th>出生年份</th>
<td>{$birth}</td>
</tr>
<tr>
<th>性别</th>
<td>
<eq name="sex" value="1"></eq>
<eq name="sex" value="2"></eq>
</td>
</tr>
<tr>
<th>高校</th>
<td>{$school}</td>
</tr>
<tr>
<th>专业</th>
<td>{$major}</td>
</tr>
<tr>
<th>手机号码</th>
<td>{$mobile}</td>
</tr>
<tr>
<th>年级</th>
<td>{$classes}</td>
</tr>
<tr>
<th>邮箱</th>
<td>{$email}</td>
</tr>
<tr>
<th>团队成员或个人相关经验</th>
<td>{$experience}</td>
</tr>
<tr>
<th>团队成员或个人描述</th>
<td>{$product}</td>
</tr>
<tr>
<th>双创项目创意概述</th>
<td>{$product_description}</td>
</tr>
<tr>
<th>提交时间</th>
<td>{:date('Y-m-d H:i',$ctime)}</td>
</tr>
</table>
</div>
</div>
<div class="form-actions">
<a class="btn" href="{:U('WillProduceApply/index')}">返回</a>
</div>
</form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -26,12 +26,13 @@
<th width="50">ID</th>
<th>活动名称</th>
<th>活动时间</th>
<th>参与人数</th>
<th>可参与总人数</th>
<th>剩余人数</th>
<th>开始时间-结束时间</th>
<th width="100">是否支付</th>
<th width="150">添加时间</th>
<!--<th width="50">{:L('STATUS')}</th>-->
<th width="70">{:L('ACTIONS')}</th>
<th width="130">{:L('ACTIONS')}</th>
</tr>
</thead>
<foreach name="posts" item="vo">
... ... @@ -44,11 +45,13 @@
<td>{$vo.name}</td>
<td>{$vo.stime}</td>
<td>{$vo.num}</td>
<td>{$vo.surplus}</td>
<td>{$vo.starttime}-{$vo.endtime}</td>
<td><eq name="vo.is_pay" value="0"></eq><eq name="vo.is_pay" value="1">是(¥{$vo.price})</eq></td>
<td>{:date('Y-m-d H:i',$vo['ctime'])}</td>
<td>
<a href="{:U('AdminWillEvents/edit',array('id'=>$vo['id']))}">{:L('EDIT')}</a> |
<a href="{:U('AdminWillEvents/join',array('id'=>$vo['id']))}">参与用户</a> |
<a href="{:U('AdminWillEvents/delete',array('id'=>$vo['id']))}" class="js-ajax-delete">{:L('DELETE')}</a>
</td>
</tr>
... ... @@ -59,12 +62,13 @@
<th width="50">ID</th>
<th>活动名称</th>
<th>活动时间</th>
<th>参与人数</th>
<th>可参与总人数</th>
<th>剩余人数</th>
<th>开始时间-结束时间</th>
<th width="100">是否支付</th>
<th width="150">添加时间</th>
<!--<th width="50">{:L('STATUS')}</th>-->
<th width="70">{:L('ACTIONS')}</th>
<th width="130">{:L('ACTIONS')}</th>
</tr>
</tfoot>
</table>
... ...
<admintpl file="header" />
</head>
<body>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li><a href="{:U('AdminWillEvents/index')}">近期活动列表</a></li>
<li class="active"><a href="javascript:;" target="_self">活动参与列表</a></li>
</ul>
<!--<form class="well form-search" method="post" action="{:U('AdminWillEvents/index')}">-->
<!--时间:-->
<!--<input type="text" name="start_time" class="js-datetime" value="{$formget.start_time|default=''}" style="width: 120px;" autocomplete="off">- -->
<!--<input type="text" class="js-datetime" name="end_time" value="{$formget.end_time|default=''}" style="width: 120px;" autocomplete="off"> &nbsp; &nbsp;-->
<!--关键字:-->
<!--<input type="text" name="keyword" style="width: 200px;" value="{$formget.keyword|default=''}" placeholder="请输入关键字...">-->
<!--<input type="submit" class="btn btn-primary" value="搜索" />-->
<!--<a class="btn btn-danger" href="{:U('AdminWillEvents/index')}">清空</a>-->
<!--</form>-->
<form class="js-ajax-form" action="" method="post">
<!--<div class="table-actions">-->
<!--<button class="btn btn-danger btn-small js-ajax-submit" type="submit" data-action="{:U('AdminWillEvents/delete_join', array('id'=>$id))}" data-subcheck="true" data-msg="你确定删除吗?">{:L('DELETE')}</button>-->
<!--</div>-->
<table class="table table-hover table-bordered table-list">
<thead>
<tr>
<th width="15"><label><input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x"></label></th>
<th width="50">ID</th>
<th>用户ID</th>
<th>活动名称</th>
<th>报名时间</th>
</tr>
</thead>
<foreach name="posts" item="vo">
<tr>
<td><input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]" value="{$vo.id}" title="ID:{$vo.id}"></td>
<td><b>{$vo.id}</b></td>
<td>{$vo.user_id}</td>
<td>{$vo.name}</td>
<td>{:date('Y-m-d H:i',$vo['ctime'])}</td>
</tr>
</foreach>
<tfoot>
<tr>
<th width="15"><label><input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x"></label></th>
<th width="50">ID</th>
<th>用户ID</th>
<th>活动名称</th>
<th>报名时间</th>
</tr>
</tfoot>
</table>
<!--<div class="table-actions">-->
<!--<button class="btn btn-danger btn-small js-ajax-submit" type="submit" data-action="{:U('AdminWillEvents/delete_join', array('id'=>$id))}" data-subcheck="true" data-msg="你确定删除吗?">{:L('DELETE')}</button>-->
<!--</div>-->
<div class="pagination">{$page}</div>
</form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -12,9 +12,13 @@ use Common\Controller\AdminbaseController;
class WillProduceApplyController extends AdminbaseController {
protected $will_produce_apply_model;
protected $will_produce_model;
function _initialize() {
parent::_initialize(); // TODO: Change the autogenerated stub
$this->will_produce_apply_model = D('Common/WillProduceApply');
$this->will_produce_model = D('Common/WillProduce');
}
// 双创项目提交列表
... ... @@ -30,11 +34,46 @@ class WillProduceApplyController extends AdminbaseController {
// 查看
public function view(){
$id= I("get.id",0,'intval');
$this->assign($this->will_produce_apply_model->where(array('id'=>$id, 'is_del'=>0))->find());
$id = I("get.id",0,'intval');
$info = $this->will_produce_apply_model->where(array('id'=>$id, 'is_del'=>0))->find();
$info['images'] = explode(',', $info['images']);
$this->assign($info);
$this->display();
}
// 发布
public function send(){
$id = I("get.id",0,'intval');
$info = $this->will_produce_apply_model->where(array('id'=>$id, 'is_del'=>0))->find();
$info['images'] = explode(',', $info['images'])[0];
$this->assign($info);
$this->display();
}
// 发布提交
public function add_post(){
if (IS_POST) {
$id = I('post.id',0,'intval');
$info = I('post.post');
$info['content'] = htmlspecialchars_decode($info['content']);
$info['ctime'] = time();
if(!$id) {
$this->error("参数错误");
}
if(!$this->will_produce_model->create($info)) {
$this->error($this->will_produce_model->getError());
}
$result = $this->will_produce_model->add($info);
if ($result) {
$this->will_produce_apply_model->where(array('id'=>$id))->save(array('is_issue'=>1));
$this->success("添加成功!");
} else {
$this->error("添加失败!");
}
}
}
// 删除
public function delete(){
if(I('get.id')){
... ...
<?php
/**
* Created by PhpStorm.
* User: 29925
* Date: 2018/4/26
* Time: 11:32
*/
namespace Admin\Controller;
use Common\Controller\AdminbaseController;
class WillUserApplyController extends AdminbaseController {
protected $will_user_apply_model;
function _initialize() {
parent::_initialize(); // TODO: Change the autogenerated stub
$this->will_user_apply_model = D('Common/WillUserApply');
}
// 鹿鸣社申请列表
public function index() {
$this->assign('list', $this->will_user_apply_model->getList(I('get.p'), I('post.keyword'), strtotime(I('post.start_time')), strtotime(I('post.end_time'))));
$count = $this->will_user_apply_model->getCount(I('post.keyword'), strtotime(I('post.start_time')), strtotime(I('post.end_time')));
$page = $this->page($count, C('MAX_PAGE_NUM'));
$this->assign('page', $page->show('Admin'));
$this->assign('formget', I('post.'));
$this->assign('keyword', I('post.keyword'));
$this->display();
}
// 查看
public function view(){
$id = I("get.id",0,'intval');
$info = $this->will_user_apply_model->where(array('id'=>$id, 'is_del'=>0))->find();
$info['images'] = explode(',', $info['images']);
$this->assign($info);
$this->display();
}
// 删除
public function delete(){
if(I('get.id')){
$id = I("get.id",0,'intval');
if ($this->will_produce_apply_model->where(array('id'=>$id))->save(array('is_del'=>1,'dtime'=>time())) !==false) {
$this->success("删除成功!");
} else {
$this->error("删除失败!");
}
}
if(I('post.ids')){
$ids = I('post.ids/a');
if (!$this->will_produce_apply_model->where(array('id'=>array('in',$ids)))->save(array('is_del'=>1,'dtime'=>time()))) {
$this->error("删除失败!");
}
$this->success("删除成功!");
}
}
}
\ No newline at end of file
... ...
... ... @@ -77,6 +77,16 @@ class HomebaseController extends AppframeController {
}
/**
* 获取活动报名剩余人数
*/
protected function getSurplus($list, $user_id, $field, $modelname) {
$model = D('Common/'.$modelname);
foreach($list as $k=>$v) {
$count = $model->where(array($field=>$v['id']))->count();
}
}
/**
* 获取商品导航分类
*/
protected function getGoodsNacList() {
... ...
... ... @@ -20,11 +20,9 @@ class WillEventsApplyModel extends CommonModel {
);
// 获取近期活动参与列表
public function getList($keyword = null) {
public function getList($eid) {
$where['is_del'] = 0;
if($keyword) {
$where['name'] = array('like', '%'.$keyword.'%');
}
$where['eid'] = $eid;
return $this->where($where)->select();
}
... ... @@ -34,4 +32,11 @@ class WillEventsApplyModel extends CommonModel {
$where['id'] = $id;
return $this->where($where)->find();
}
// 获取近期活动用户参与
public function getInfoByUserId($user_id) {
$where['is_del'] = 0;
$where['user_id'] = $user_id;
return $this->where($where)->find();
}
}
\ No newline at end of file
... ...
... ... @@ -32,6 +32,18 @@ class WillEventsModel extends CommonModel {
return $this->where($where)->select();
}
// 获取近期活动参与列表
public function getJoinList($id) {
$where['we.is_del'] = 0;
$where['we.id'] = $id;
$where['wea.eid'] = $id;
return $this->field(array('we.id,we.name,wea.user_id,wea.ctime'))
->alias('we')
->join('__WILL_EVENTS_APPLY__ as wea on we.id = wea.eid')
->where($where)
->select();
}
// 获取近期活动详情
public function getInfo($id) {
$where['is_del'] = 0;
... ...
... ... @@ -17,26 +17,30 @@ class WillUserApplyModel extends CommonModel {
//array(验证字段,验证规则,错误提示,验证条件,附加规则,验证时间)
array('user_id', 'number', '用户ID不能为空', 1, 'regex', CommonModel::MODEL_BOTH),
array('name', 'require', '姓名不能为空', 1, 'regex', CommonModel::MODEL_BOTH),
// array('province', 'require', '所在省不能为空', 1, 'regex', CommonModel::MODEL_BOTH),
array('city', 'require', '城市不能为空', 1, 'regex', CommonModel::MODEL_BOTH),
array('sex', array(0,1,2), '性别格式错误', 1, 'in', CommonModel::MODEL_BOTH),
array('age', 'number', '年龄格式错误', 1, 'regex', CommonModel::MODEL_BOTH),
array('sex', array(0,1,2), '性别格式错误', 1, 'regex', CommonModel::MODEL_BOTH),
array('school', 'require', '高校不能为空', 1, 'regex', CommonModel::MODEL_BOTH),
array('major', 'require', '专业不能为空', 1, 'regex', CommonModel::MODEL_BOTH),
array('mobile', 'require', '手机号码不能为空', 1, 'regex', CommonModel::MODEL_BOTH),
array('mobile', 'mobile', '手机号码格式错误', 1, 'regex', CommonModel::MODEL_BOTH),
array('email', 'require', '邮箱不能为空', 1, 'regex', CommonModel::MODEL_BOTH),
array('email', 'email', '邮箱格式错误', 1, 'regex', CommonModel::MODEL_BOTH),
array('province', 'require', '所在省不能为空', 1, 'regex', CommonModel::MODEL_BOTH),
array('city', 'require', '城市不能为空', 1, 'regex', CommonModel::MODEL_BOTH),
array('school', 'require', '所在公司或高校不能为空', 1, 'regex', CommonModel::MODEL_BOTH),
array('major', 'require', '专业不能为空', 1, 'regex', CommonModel::MODEL_BOTH),
array('classes', 'require', '年级不能为空', 1, 'regex', CommonModel::MODEL_BOTH),
array('experience', 'require', '相关经验不能为空', 1, 'regex', CommonModel::MODEL_BOTH),
array('skill', 'require', '个人技能不能为空', 1, 'regex', CommonModel::MODEL_BOTH),
);
// 获取入会申请列表
public function getList($keyword = null) {
public function getList($keyword = null, $start_time = null, $end_time = null) {
$where['is_del'] = 0;
if($keyword) {
$where['name'] = array('like', '%'.$keyword.'%');
}
if($start_time && $end_time) {
$where['ctime'] = array('between', array($start_time,$end_time));
}
return $this->where($where)->select();
}
... ... @@ -46,4 +50,29 @@ class WillUserApplyModel extends CommonModel {
$where['id'] = $id;
return $this->where($where)->find();
}
// 获取用户是否提交入会申请
public function check($user_id) {
$where['is_del'] = 0;
$where['user_id'] = $user_id;
return $this->where($where)->find();
}
/**
* 获取数据总数
* @author Liuzhen
*/
public function getCount($keyword = null, $start_time = null, $end_time = null) {
$where = array();
if($keyword) {
$where['name'] = array('like', '%'.$keyword.'%');
}
if($start_time && $end_time) {
$where['ctime'] = array('between', array($start_time,$end_time));
}
$where['is_del'] = 0;
$count = $this->where($where)
->count();
return $count;
}
}
\ No newline at end of file
... ...
... ... @@ -13,10 +13,12 @@ use Common\Controller\AdminbaseController;
class AdminWillEventsController extends AdminbaseController {
protected $will_events_model;
protected $will_events_apply_model;
function _initialize() {
parent::_initialize();
$this->will_events_model = D("Common/WillEvents");
$this->will_events_apply_model = D("Common/WillEventsApply");
}
// 近期活动列表
... ... @@ -113,6 +115,10 @@ class AdminWillEventsController extends AdminbaseController {
->order("ctime DESC")
->select();
foreach($posts as $k=>$v) {
$count = $this->will_events_apply_model->where(array('eid'=>$v['id']))->count();
$posts[$k]['surplus'] = $v['num'] - $count;
}
$this->assign("page", $page->show('Admin'));
$this->assign("formget",array_merge($_GET,$_POST));
$this->assign("posts",$posts);
... ... @@ -140,4 +146,13 @@ class AdminWillEventsController extends AdminbaseController {
}
}
}
// 参与用户
public function join() {
$id = I('get.id',0,'intval');
$list = $this->will_events_model->getJoinList($id);
$this->assign('id',$id);
$this->assign('posts', $list);
$this->display();
}
}
\ No newline at end of file
... ...
... ... @@ -13,13 +13,20 @@ use Common\Controller\HomebaseController;
class WillController extends HomebaseController {
protected $posts_model;
protected $will_mission_model;
protected $will_events_model;
protected $will_events_apply_model;
protected $will_produce_model;
protected $will_user_apply_model;
function _initialize() {
parent::_initialize();
$this->posts_model = D("Portal/Posts");
$this->will_mission_model = D("Common/WillMission");
$this->will_events_model = D("Common/WillEvents");
$this->will_events_apply_model = D("Common/WillEventsApply");
$this->will_produce_model = D("Common/WillProduce");
$this->will_user_apply_model = D("Common/WillUserApply");
}
// 入会说明
... ... @@ -47,18 +54,88 @@ class WillController extends HomebaseController {
// 近期活动列表
public function events_list() {
$this->assign('list', $this->will_events_model->getList());
$list = $this->will_events_model->getList();
$user_id = 1;
// $user_id = sp_get_current_userid();
// if(!$user_id) {
// $this->ajaxReturn(array('status'=>false,'msg'=>'用户未登录'));
// }
// 计算剩余报名人数及当前用户是否报名
foreach($list as $k=>$v) {
$list[$k]['is_apply'] = 0;
$count = $this->will_events_apply_model->where(array('eid'=>$v['id']))->count();
$list[$k]['surplus'] = $v['num'] - $count;
if($this->will_events_apply_model->where(array('user_id'=>$user_id))->count()) {
$list[$k]['is_apply'] = 1;
}
}
$this->assign('list', $list);
$this->display();
}
// 近期活动详情
public function events_detail() {
$id = I("get.id",0,'intval');
$user_id = 1;
// $user_id = sp_get_current_userid();
// if(!$user_id) {
// $this->ajaxReturn(array('status'=>false,'msg'=>'用户未登录'));
// }
$this->assign($this->will_events_model->getInfo($id));
$info = $this->will_events_model->getInfo($id);
$info['is_apply'] = 0;
$count = $this->will_events_apply_model->where(array('eid'=>$info['id']))->count();
$info['surplus'] = $info['num'] - $count;
if($this->will_events_apply_model->where(array('user_id'=>$user_id))->count()) {
$info['is_apply'] = 1;
}
$this->assign($info);
$this->display();
}
/**
* 报名近期活动
* @param eid 活动ID
* @param user_id 用户ID
*/
public function events_apply() {
if(IS_AJAX) {
$eid = $info['eid'] = I('post.id');
$user_id = $info['user_id'] = 1;
// $user_id = sp_get_current_userid();
// if(!$user_id) {
// $this->ajaxReturn(array('status'=>false,'msg'=>'用户未登录'));
// }
if(!$user_id) {
$this->ajaxReturn(array('status'=>false,'msg'=>'请先登录'));
}
// 判断用户是否报名
if($this->will_events_apply_model->getInfoByUserId($user_id)) {
$this->ajaxReturn(array('status'=>false,'msg'=>'您已报名该活动'));
}
// 判断活动是否存在及名额是否充足
$events = $this->will_events_model->getInfo($eid);
if(!$events) {
$this->ajaxReturn(array('status'=>false,'msg'=>'活动不存在或已结束'));
}
if($events['num'] == 0) {
$this->ajaxReturn(array('status'=>false,'msg'=>'活动名额不足'));
}
// 插入报名表
$info['ctime'] = time();
if(!$this->will_events_apply_model->create($info)) {
$this->ajaxReturn(array('status'=>false,'msg'=>$this->will_events_apply_model->getError()));
}
if(!$this->will_events_apply_model->add($info)) {
$this->ajaxReturn(array('status'=>false,'msg'=>'报名失败,请重试'));
}
$this->ajaxReturn(array('status'=>true,'msg'=>'报名成功'));
} else {
$this->error('非法操作');
}
}
// 双创项目列表
public function produce_list() {
$this->assign('list', $this->will_produce_model->getList());
... ... @@ -73,7 +150,41 @@ class WillController extends HomebaseController {
$this->display();
}
// 入会申请提交
/**
* 加入鹿鸣社
* @param post 提交的加入数据
* @param user_id 用户ID
*/
public function user_join() {
if(IS_AJAX) {
$post =I('post.');
$user_id = $post['user_id'] = 1;
// $user_id = $post['user_id'] = sp_get_current_userid();
// if(!$user_id) {
// $this->ajaxReturn(array('status'=>false,'msg'=>'用户未登录'));
// }
if($this->will_user_apply_model->check($user_id)) {
$this->ajaxReturn(array('status'=>false,'msg'=>'已提交过申请'));
}
$post['ctime'] = $post['utime'] = time();
if(!$this->will_user_apply_model->create($post)) {
$this->ajaxReturn(array('status'=>false,'msg'=>$this->will_user_apply_model->getError()));
}
$will_id = $this->will_user_apply_model->add($post);
if(!$will_id) {
$this->ajaxReturn(array('status'=>false,'msg'=>'提交失败'));
}
$this->ajaxReturn(array('status'=>true,'msg'=>'提交成功','data'=>$will_id));
} else {
$this->error('非法操作');
}
}
/**
* 入会申请提交
* @param post 提交的申请数据
* @param user_id 用户ID
*/
public function submit() {
if(IS_AJAX) {
$post =I('post.');
... ...
... ... @@ -44,10 +44,10 @@
报名时间:<span>{$starttime}~{$endtime}</span>
</div>
<div class="g-item g-number">
报名人数:<span>{$num}人</span>
报名人数:<span>{$surplus}人</span>
</div>
</div>
<a href="" class="btn-signup"><span>立即报名</span></a>
<a href="javascript:;" class="btn-signup"><span>立即报名</span></a>
</div>
</div>
<div class="content">
... ...
... ... @@ -42,12 +42,12 @@
</div>
<div class="slt-list lf" id="city">
<div class="slt-container lf">
<select class="mm-select prov">
<option value=""></option>
<select name="province" class="mm-select prov">
<option value="天津"></option>
</select>
</div>
<div class="slt-container lf">
<select class="mm-select city" disabled="disabled"><option value=""></option></select>
<select name="city" class="mm-select city"><option value="天津"></option></select>
</div>
</div>
<div class="ipt-container lf">
... ... @@ -102,18 +102,35 @@
</div>
<script>
$('input[name=submit]').click(function(){
var btn = $(this);
var text = btn.val();
var form = $('form').serialize();
$.ajax({
url:"{:U('Will/submit')}",
url:"{:U('user_join')}",
type:"POST",
data:form,
dateType:"json",
beforeSend: function () {
// Handle the beforeSend event
btn.val('提交中...').attr('disabled', true);
},
success:function (data) {
console.log(data);
if(data.status) {
alert(data.msg);
location.reload();
} else {
alert(data.msg);
}
})
console.log(form);
})
},
error: function (data, status, e) { //提交失败自动执行的处理函数
alert(e);
},
complete: function () {
// Handle the complete event
btn.val(text).attr('disabled', false);
}
});
});
$('#txt').keyup(function() {
var len=$(this).val().length;
$('#txt_num').html(len);
... ...
... ... @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>9鹿鸣社_4近期活动详情</title>
<title>鹿鸣社_近期活动详情</title>
<link href="__TMPL__Public/assets/css/reset.css" rel="stylesheet" type="text/css" />
<link href="__TMPL__Public/assets/css/common.css" rel="stylesheet" type="text/css" />
<link href="__TMPL__Public/assets/css/style.css" rel="stylesheet" type="text/css" />
... ... @@ -46,10 +46,15 @@
报名时间:<span>{$starttime}~{$endtime}</span>
</div>
<div class="g-item g-number">
报名人数:<span>{$num}人</span>
报名人数:<span>{$surplus}人</span>
</div>
</div>
<a href="" class="btn-signup"><span>立即报名</span></a>
<eq name="is_apply" value="0">
<a href="javascript:;" class="btn-signup" id="apply"><span>立即报名</span></a>
</eq>
<eq name="is_apply" value="1">
<a href="javascript:;" class="btn-signup"><span>已报名</span></a>
</eq>
</div>
</div>
<div class="content">
... ... @@ -78,5 +83,29 @@
<script type="text/javascript">
$("#city").citySelect({nodata:"none",required:false});
</script>
<script>
// 报名
$('#apply').on('click',function(){
$.ajax({
url:"{:U('Will/events_apply')}",
type:"POST",
data:{
id:"{$id}"
},
dateType:"json",
success:function (data) {
if(data.status) {
alert(data.msg);
location.reload();
} else {
alert(data.msg);
}
},
error: function (data, status, e) { //提交失败自动执行的处理函数
alert(e);
}
})
})
</script>
</body>
</html>
... ...
... ... @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>9鹿鸣社_4近期活动</title>
<title>鹿鸣社_近期活动</title>
<link href="__TMPL__Public/assets/css/reset.css" rel="stylesheet" type="text/css" />
<link href="__TMPL__Public/assets/css/common.css" rel="stylesheet" type="text/css" />
<link href="__TMPL__Public/assets/css/style.css" rel="stylesheet" type="text/css" />
... ... @@ -31,15 +31,20 @@
<div class="main">
<ul class="gxwc-list">
<volist name="list" id="vo">
<li>
<li data-id="{$vo.id}">
<div class="gxwc-box">
<div class="gxwc-body">
<div class="gx-title"><a href="{:U('Will/events_detail',array('id'=>$vo['id']))}">{$vo.name}</a></div>
<div class="gx-meta">
<div class="gx-item"><span class="hd">活动时间:</span>{$vo.stime}</div>
<div class="gx-item"><span class="hd">报名时间:</span>{$vo.starttime}~{$vo.endtime}</div>
<div class="gx-item"><span class="hd">名额:</span>{$vo.num}人</div>
<a href="" class="gx-singup"><span>立即报名</span></a>
<div class="gx-item"><span class="hd">名额:</span>{$vo.surplus}人</div>
<eq name="vo.is_apply" value="0">
<a href="javascript:;" class="gx-singup" id="apply"><span>立即报名</span></a>
</eq>
<eq name="vo.is_apply" value="1">
<a href="javascript:;" class="gx-singup"><span>已报名</span></a>
</eq>
</div>
<div class="gx-desc">
{$vo.description}<a href="{:U('Will/events_detail',array('id'=>$vo['id']))}" class="gx-more">查看详情 ></a>
... ... @@ -54,12 +59,13 @@
</ul>
</div>
</div>
<tc_include file="Portal/Will:apply"/>
<tc_include file="Public:footer"/>
<!-- js -->
<script src="__TMPL__Public/assets/js/jquery.min.js"></script>
<script src="__TMPL__Public/assets/js/common.js"></script>
<script src="__TMPL__Public/assets/js/modal.js"></script>
<script type="text/javascript" src="__TMPL__Public/assets/js/jquery.cityselect1.js"></script>
<tc_include file="Portal/Will:apply"/>
<script>
// $('#myModal').modal({
... ... @@ -75,5 +81,30 @@
<script type="text/javascript">
$("#city").citySelect({nodata:"none",required:false});
</script>
<script>
// 报名
$('#apply').on('click',function(){
var id = $(this).parents('li').data('id');
$.ajax({
url:"{:U('Will/events_apply')}",
type:"POST",
data:{
id:id
},
dateType:"json",
success:function (data) {
if(data.status) {
alert(data.msg);
location.reload();
} else {
alert(data.msg);
}
},
error: function (data, status, e) { //提交失败自动执行的处理函数
alert(e);
}
})
})
</script>
</body>
</html>
... ...
... ... @@ -184,12 +184,15 @@ input[type="submit"],input[type="radio"],input[type="file"]{cursor: pointer;}
line-height: 1.42857143;
color: #555;
background-image: none;
appearance:none;
-moz-appearance:none;
-webkit-appearance:none;
-webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
-o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
background: url(../images/selectarr.png) 95% center no-repeat;
}
select::-ms-expand { display: none; }
... ...