Scanimgs.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Scanimgs extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model("Model_scanimgs","scanimgs");
  7. $this->load->_model("Model_shop","shop");
  8. }
  9. private $show_url = "https://lyerposs.wepolicy.cn";
  10. //定义方法的调用规则 获取URI第二段值
  11. public function _remap($arg,$arg_array)
  12. {
  13. if($arg == 'detail')//添加
  14. {
  15. $this->_detail($arg_array);
  16. }
  17. else
  18. {
  19. $this->_index($arg_array);
  20. }
  21. }
  22. private function _index(){
  23. if(isset($_SESSION['api']))
  24. {
  25. $user = $this->user->get_api($_SESSION['api']);
  26. $usp = $user;
  27. $fgshop = "";$sid = "";
  28. $usersp = explode('|',trim($user['shop'],'|'));
  29. foreach ($usersp as $value)
  30. {
  31. $fgshop .= " shop = ".$value." or";
  32. $sid .= " id = ".$value." or";
  33. }
  34. $fgshop .= " shop = '0' or";
  35. if($user['vip'] == 1)
  36. {
  37. $vip = 1;
  38. }
  39. else
  40. {
  41. $vip = 0;
  42. }
  43. }
  44. else
  45. {
  46. $vip = 0;
  47. }
  48. $post = $this->input->post(NULL, TRUE);
  49. if(isset($post['page']))
  50. {
  51. $page = $this->input->post('page',true);
  52. $perpage = $this->input->post('perpage',true);
  53. $number = $this->input->post('number',true);
  54. $shop = $this->input->post('shop',true);
  55. $timetk = $this->input->post('timetk',true);
  56. $timetj = $this->input->post('timetj',true);
  57. $timetk = strtotime($timetk);
  58. $timetj = strtotime($timetj);
  59. $where = "(".rtrim($fgshop,'or').")";
  60. if($number)
  61. {
  62. $where .= " and number = '$number'";
  63. }
  64. if($shop != '')
  65. {
  66. $where .= " and shop = '$shop'";
  67. }
  68. if($timetk && $timetj)
  69. {
  70. $where .= " and updatetime > '$timetk' and updatetime < '$timetj'";
  71. }
  72. //数据排序
  73. $order_str = " id desc ";
  74. if(empty($page))
  75. {
  76. $start = 0;
  77. $perpage = 1;
  78. }
  79. else
  80. {
  81. $start = ($page - 1)*$perpage;
  82. }
  83. $info_list = $this->scanimgs->find_all($where,'*',$order_str,$start,$perpage);
  84. $shop_list = $this->shop->find_all();
  85. $shop_list =array_column($shop_list,'shopname','id');
  86. $final_list = [];
  87. foreach ($info_list as $key=>$value)
  88. {
  89. $img_str = "<div style='display:flex;flex-direction:row;flex-wrap:wrap'>";
  90. $img_arr = json_decode($value['imgs'],true);
  91. foreach ($img_arr as $k => $v) {
  92. $img_str .= "<div>";
  93. $img_str .= "<div style=''>";
  94. foreach($v['imgurl'] as $img){
  95. $img_str .= "<img src='{$this->show_url}{$img}' style='width:150px;height:auto;margin-right:3px'>";
  96. }
  97. $img_str .= "</div>";
  98. $img_str .= "<div>".date("Y-m-d H:i:s",$value['addtime'])."</div></div>";
  99. }
  100. $img_str .= "</div>";
  101. $final_list[] = [
  102. 'id' => $value['id'],
  103. 'number'=>$value['number'],
  104. "shop" =>isset($shop_list[$value['shop']])?$shop_list[$value['shop']]:'',
  105. "imgs" => $img_str,
  106. "addtime" => date("Y-m-d H:i:s",$value['addtime']),
  107. "updatetime" => date("Y-m-d H:i:s",$value['updatetime']),
  108. ];
  109. }
  110. $total = $this->scanimgs->find_count($where);
  111. $pagenum = ceil($total/$perpage);
  112. $over = $total-($start+$perpage);
  113. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  114. echo json_encode($rows);exit;
  115. }
  116. $this->_Template('scanimgs',$this->data);
  117. }
  118. private function _detail($arg_array){
  119. }
  120. }