SoftController.class.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace Admin\Controller;
  3. use Common\Controller\AdminController;
  4. class SoftController extends AdminController {
  5. public function __construct(){
  6. parent::__construct();
  7. }
  8. public function index(){
  9. $os = I('os');
  10. $condition = array();
  11. if (!empty($os)){
  12. $condition['os'] = $os;
  13. }
  14. $count = M('Soft')->where($condition)->count();
  15. //分页
  16. $Page = new \Think\Page($count);
  17. $show = $Page->show();
  18. $softList = M('Soft')->where($condition)->field()->order('soft_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
  19. $this->assign('page',$show);
  20. $this->assign('list',$softList);
  21. $this->display();
  22. }
  23. public function edit(){
  24. $step = I('step','');
  25. $softId = I('soft_id','');
  26. if (empty($step)){
  27. $info = array();
  28. if (!empty($softId)){
  29. $info = M('Soft')->where(array('soft_id'=>$softId))->find();
  30. }
  31. $this->assign('info',$info);
  32. $this->display();
  33. }else if($step==2){
  34. $data['os'] = I('os');
  35. $data['force_up'] = I('force_up');
  36. $data['new_ver'] = I('new_ver');
  37. $data['up_info'] = I('up_info');
  38. $data['url'] = I('app_url');
  39. if (empty($data['up_info'])){
  40. $this->error('更新内容不能为空');
  41. }
  42. if (empty($data['url'])){
  43. $this->error('app链接不能为空');
  44. }
  45. if (empty($softId)){
  46. $data['operate_dt'] = time();
  47. M('Soft')->add($data);
  48. }else{
  49. M('Soft')->where(array('soft_id'=>$softId))->save($data);
  50. }
  51. $this->success('APP操作成功','/admin/soft/index');
  52. }
  53. }
  54. }