Product.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace app\home\controller;
  3. use think\Lang;
  4. use think\Cache;
  5. use think\Request;
  6. use think\Controller;
  7. use think\Validate;
  8. /**
  9. * 主页管理类
  10. */
  11. class Product extends Common
  12. {
  13. /**
  14. * 构造函数
  15. *
  16. * @access public
  17. */
  18. public function __construct()
  19. {
  20. parent::__construct();
  21. }
  22. /**
  23. * 产品与服务
  24. *
  25. * @access public
  26. * @return array JsonString
  27. */
  28. public function product()
  29. {
  30. $fatherProductField = [
  31. 'product_name',
  32. 'product_content',
  33. 'product_img',
  34. 'product_id',
  35. ];
  36. $fatherProductWhere = [
  37. 'product_pid' => 0,
  38. ];
  39. $getFatherProduct = model('Product')->getSelect($fatherProductField, $fatherProductWhere);
  40. $this->assign('fatherProduct', $getFatherProduct);
  41. $id = input('get.id') ?? $getFatherProduct[0]->product_id;
  42. $productWhere = [
  43. 'product_pid' => $id,
  44. ];
  45. $getProduct = model('Product')->getSelect($fatherProductField, $productWhere);
  46. $this->assign('product', $getProduct);
  47. $this->assign('id', $id);
  48. return $this->fetch();
  49. }
  50. /**
  51. * 产品与服务详情
  52. *
  53. * @access public
  54. * @return array JsonString
  55. */
  56. public function details()
  57. {
  58. $findProductinfo = model('Productinfo')->getFind();
  59. $id = input('get.id') ?? $findProductinfo->product_id;
  60. $productWhere = [
  61. 'product_id' => $id,
  62. ];
  63. $getProductInfo = model('Productinfo')->getSelect($productWhere);
  64. $this->assign('productInfo', $getProductInfo);
  65. $getProduct = model('Product')->getFind($productWhere);
  66. $this->assign('product', $getProduct);
  67. $getRenewal = model('Renewal')->getRenewal();
  68. $this->assign('renewal', $getRenewal);
  69. return $this->fetch();
  70. }
  71. }