| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace Active\Src;
- use Dever;
- use Active\Lib\Core;
- Class Home extends Core
- {
- protected $check = false;
- #活动首页
- public function get()
- {
- $data['info'] = Dever::db('active/info')->getAll(array('state'=>1));
- $config = Dever::db('active/info')->config['config_act_status'];
- foreach($data['info'] as $k=>$v){
- $data['info'][$k]['act_status_name'] = Dever::status($config,$v['act_status']);
- if ($v['act_status'] == 2) {
- if ($v['sign_end']) {
- $data['info'][$k]['day'] = '剩余'.floor(($v['sign_end'] - time())/86400).'天';
- } else {
- $data['info'][$k]['day'] = '剩余'.floor(($v['act_start'] - time())/86400).'天';
- }
- }else {
- $data['info'][$k]['day'] = '';
- }
- }
- return $data;
- }
- # 活动报名获取信息
- public function getSign()
- {
- $uid = $this->uid;
- $id = Dever::input('id');
- $this->data['info'] = Dever::db('active/info')->find($id);
- $this->data['info']['banner'] = explode(',', $this->data['info']['banner']);
- $this->data['info']['field'] = Dever::db('active/info_field')->getList(array('active_id'=>$id,'state'=>1));
- foreach($this->data['info']['field'] as $k => $v){
- if($v['type'] == 2) {
- $this->data['info']['field'][$k]['value_name']= Dever::db('active/info_field_value')->getList(array('active_id'=>$id,'field_id'=>$v['id']));
-
- }else{
- $this->data['info']['field'][$k]['value_name'] = '';
- }
- }
- if ($uid > 0) {
- $this->data['user'] = Dever::db('active/user')->find($uid);
- }
- return $this->data;
- }
- # 活动报名页
- public function upSign()
- {
- $data['name'] = Dever::input('name');
- $data['mobile'] = Dever::input('mobile');
- $data['idcard'] = Dever::input('idcard');
- $uid = $this->uid;
- if ($this->uid <= 0) {
- $user = Dever::db('active/user')->find(array('mobile'=>$data['mobile']));
- if ($user) {
- $uid = $user['id'];
- } else {
- # 注册
- $uid = Dever::db('active/user')->insert($data);
- }
- }
- $result = array();
- $result = Dever::load('passport/reg')->getSign($uid);
- $id = Dever::input('id');
- if (!$id) {
- Dever::alert('活动id不能为空');
- }
- $num = Dever::input('num');
- if (!$num) {
- Dever::alert('购买数量不能为空');
- }
- $remark = Dever::input('remark');
- $path = Dever::input('path');
- $result += Dever::load('active/lib/active')->action($uid, $id, $num, $path, $remark);
- return $result;
- }
- }
|