application/app/controller/Product.php

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php
namespace app\app\controller;

use app\common\controller\CommonApp;
use app\common\model\ProductCategory;
use app\common\model\Product as ProductApp;
use app\common\model\WeixinShare;

/**
 * 产品
 */
class Product extends CommonApp
{
	
	public function index()
	{
		cookie('jumpUrl',$this->request->url()); // url缓存
		$nameAll = ProductCategory::column('*','id'); // 所有分类
		$categoryLevelOneId = $this->request->param('categoryLevelOneId')?$this->request->param('categoryLevelOneId'):'all';
		$categoryLevelTwoId = $this->request->param('categoryLevelTwoId')?$this->request->param('categoryLevelTwoId'):'all';
		$pagesize = $this->request->param('pagesize')?intval($this->request->param('pagesize')):20;//默认加载20个
		$minId = $this->request->param('minId')?$this->request->param('minId'):'max';
	    
	    if($categoryLevelOneId != 'all'){
	    	if(!is_numeric($categoryLevelOneId) || $categoryLevelOneId<=0 || empty($categoryLevelOneId)){
				$this->error("上传数据有误",cookie('jumpUrl'));
			}
	    }

	    if($categoryLevelTwoId != 'all'){
	    	if(!is_numeric($categoryLevelTwoId) || $categoryLevelTwoId<=0 || empty($categoryLevelTwoId)){
				$this->error("上传数据有误",cookie('jumpUrl'));
			}
	    }

	    //分类
		$listLevelOne = ProductCategory::where('depth',1)->order(['rank'=>'desc','id'=>'asc'])->select();
		if ($listLevelOne) {
			foreach ($listLevelOne as $key => $value) {
				if($value['pid'] > 0){
					$listLevelOne[$key]['pname'] = $nameAll[$value['pid']]['name'];
				}else{
					$listLevelOne[$key]['pname'] = '产品';
				}
			}
		}
	    //产品
	    $map = [];
	    $order = ['rank'=>'desc','id'=>'desc'];
	    //一级分类限制参数
		if($categoryLevelOneId != 'all'){
			$listLevelTwo = ProductCategory::where('pid',$categoryLevelOneId)->select();
			foreach ($listLevelTwo as $key => $value) {
				if($value['pid'] > 0){
					$listLevelTwo[$key]['pname'] = $nameAll[$value['pid']]['name'];
				}else{
					$listLevelTwo[$key]['pname'] = '产品';
				}
			}

后面还有 79 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。