Home.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace Active\Src;
  3. use Dever;
  4. use Active\Lib\Core;
  5. Class Home extends Core
  6. {
  7. protected $check = false;
  8. #活动首页
  9. public function get()
  10. {
  11. $data['info'] = Dever::db('active/info')->getAll(array('state'=>1));
  12. $config = Dever::db('active/info')->config['config_act_status'];
  13. foreach($data['info'] as $k=>$v){
  14. $data['info'][$k]['act_status_name'] = Dever::status($config,$v['act_status']);
  15. if ($v['act_status'] == 2) {
  16. if ($v['sign_end']) {
  17. $data['info'][$k]['day'] = '剩余'.floor(($v['sign_end'] - time())/86400).'天';
  18. } else {
  19. $data['info'][$k]['day'] = '剩余'.floor(($v['act_start'] - time())/86400).'天';
  20. }
  21. }else {
  22. $data['info'][$k]['day'] = '';
  23. }
  24. }
  25. return $data;
  26. }
  27. # 活动报名获取信息
  28. public function getSign()
  29. {
  30. $uid = $this->uid;
  31. $id = Dever::input('id');
  32. $this->data['info'] = Dever::db('active/info')->find($id);
  33. $this->data['info']['banner'] = explode(',', $this->data['info']['banner']);
  34. $this->data['info']['field'] = Dever::db('active/info_field')->getList(array('active_id'=>$id,'state'=>1));
  35. foreach($this->data['info']['field'] as $k => $v){
  36. if($v['type'] == 2) {
  37. $this->data['info']['field'][$k]['value_name']= Dever::db('active/info_field_value')->getList(array('active_id'=>$id,'field_id'=>$v['id']));
  38. }else{
  39. $this->data['info']['field'][$k]['value_name'] = '';
  40. }
  41. }
  42. if ($uid > 0) {
  43. $this->data['user'] = Dever::db('active/user')->find($uid);
  44. }
  45. return $this->data;
  46. }
  47. # 活动报名页
  48. public function upSign()
  49. {
  50. $data['name'] = Dever::input('name');
  51. $data['mobile'] = Dever::input('mobile');
  52. $data['idcard'] = Dever::input('idcard');
  53. $uid = $this->uid;
  54. if ($this->uid <= 0) {
  55. $user = Dever::db('active/user')->find(array('mobile'=>$data['mobile']));
  56. if ($user) {
  57. $uid = $user['id'];
  58. } else {
  59. # 注册
  60. $uid = Dever::db('active/user')->insert($data);
  61. }
  62. }
  63. $result = array();
  64. $result = Dever::load('passport/reg')->getSign($uid);
  65. $id = Dever::input('id');
  66. if (!$id) {
  67. Dever::alert('活动id不能为空');
  68. }
  69. $num = Dever::input('num');
  70. if (!$num) {
  71. Dever::alert('购买数量不能为空');
  72. }
  73. $remark = Dever::input('remark');
  74. $path = Dever::input('path');
  75. $result += Dever::load('active/lib/active')->action($uid, $id, $num, $path, $remark);
  76. return $result;
  77. }
  78. }