['special_type'], ]; } public function queryWhere() { $where = []; if (!empty($this->params['id'])) { if(empty($this->params['limit'])){ $where[] = ['id','>=',$this->params['id']]; } $where[] = ['cover_type','=',1]; } return $where; } /** * @notes 获取列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2024/11/18 10:05 */ public function lists(): array { return HomeSpecial::where($this->searchWhere) ->where($this->queryWhere()) ->where('status',1) ->field(['id', 'special_type','special_way', 'title', 'cover_type', 'cover', 'user_head', 'user_nickname', 'vue_web', 'vue_param', 'view_num', 'tags', 'status', 'original_price' ,'present_price','goods_id']) ->limit($this->limitOffset, $this->limitLength) ->order(['weight' => 'desc']) ->select() ->each(function($item){ if($item->goods_id){ $item->goods = Goods::where('id',$item->goods_id)->field('goods_banners,goods_name,service_total,service_fee')->findOrEmpty(); } if($item->vue_web=='pages/preview/videoPre' || $item->vue_web=='pages/preview/imagePre' || $item->vue_web=='pages/preview/richView'){ $item->vue_param = 'id='.$item->id; } if($item->vue_web=='pages/web_view/index'){ $token = !empty($this->userInfo->token)?$this->userInfo->token:''; $item->vue_param = rawurlencode('https://weixiu.kyjlkj.com/static/wxapp/H5/adver5/index.html?property_activity_id=2&token='.$token); } }) ->toArray(); } /** * @notes 获取数量 * @return int * @author likeadmin * @date 2024/11/18 10:05 */ public function count(): int { return HomeSpecial::where($this->searchWhere)->where($this->queryWhere())->count(); } }