IndexController.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace App\Http\Home\Ocr;
  3. use App\Http\Home\HttpBaseController;
  4. use Illuminate\Support\Facades\DB;
  5. use Illuminate\Support\Facades\Request;
  6. class IndexController extends HttpBaseController
  7. {
  8. private $softInfo = [
  9. 'id' => 7,
  10. 'mid' => "79b9a46daa57",
  11. 'weight' => "0.00",
  12. 'is_delete' => 0,
  13. 'title' => "助友音频处理器",
  14. ];
  15. public function __construct()
  16. {
  17. parent::__construct();
  18. }
  19. /**
  20. * 首页
  21. */
  22. public function index()
  23. {
  24. return view('ocr/index');
  25. }
  26. public function buy()
  27. {
  28. // 获取产品信息
  29. $info = DB::table('product')->find($this->softInfo['id']);
  30. return view('ocr/buy', ['info' => $info]);
  31. }
  32. public function help()
  33. {
  34. $size = 15;
  35. $page = Request::input('page', 1);
  36. $cid = Request::input('cid');
  37. // 获取资讯分类
  38. $category = DB::table('news_category')->where('product_id', $this->softInfo['id'])->get();
  39. // 获取资讯列表
  40. $find = DB::table('news')->where('product_id', $this->softInfo['id'])
  41. ->offset($size * ($page - 1))
  42. ->limit($size);
  43. if ($cid) {
  44. $info = DB::table('news_category')->select('id')->where('mid', $cid)->first();
  45. if ($info) {
  46. $find->where('category_id', $info->id);
  47. }
  48. }
  49. $list = $find->get();
  50. return view('ocr/help', ['category' => $category, 'list' => $list]);
  51. }
  52. public function about()
  53. {
  54. return view('ocr/about');
  55. }
  56. public function newsDetail($mid)
  57. {
  58. // 获取资讯分类
  59. $category = DB::table('news_category')->where('product_id', $this->softInfo['id'])->get();
  60. $info = DB::table('news')->where('mid', $mid)->first();
  61. return view('ocr/news_detail', ['info' => $info, 'category' => $category]);
  62. }
  63. }