Index.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace app\index\controller;
  3. use app\common\controller\Frontend;
  4. use app\job\InsertDataJob;
  5. use think\Queue;
  6. use think\Db;
  7. class Index extends Frontend
  8. {
  9. protected $noNeedLogin = '*';
  10. protected $noNeedRight = '*';
  11. protected $layout = '';
  12. public function index()
  13. {
  14. // $this->redirect("/ReZpnAIXhw.php"); //关键代码->重定向
  15. // 查询product表数据
  16. $products = Db::name('product')->where('product_category','模版')->select();
  17. //baseUrl ip服务器地址 port端口号
  18. $http_url = Db::name('http_url')->field('baseUrl,port')->find();
  19. // 拼接完整的图片URL
  20. if ($products && $http_url) {
  21. $base_url = 'http://' . $http_url['baseUrl'] . ':' . $http_url['port'];
  22. foreach ($products as &$product) {
  23. if (isset($product['txt_image_url'])) {
  24. $product['full_image_url'] = $base_url . $product['txt_image_url'];
  25. }
  26. }
  27. }
  28. // 将数据传递给前端视图
  29. $this->assign('products', $products);
  30. $this->assign('http_url', $http_url);
  31. return $this->view->fetch();
  32. }
  33. }