💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
控制器-简单 ~~~ public function search() { $type='city'; $res=Db::name('city')->order('zm','asc')->order('sort','asc')->select(); $this->assign('res',$res); $this->assign('type',$type); return $this->fetch('search'); } ~~~ 控制器-复杂 ~~~ public function search(){ $type='brand'; if(input('brand_id')){ $res=model('brandSon')->where('brand_id',input('brand_id'))->select(); $type='son'; } elseif(input('son_id')){ $res=model('cars')->where('son_id',input('son_id'))->order('sort','asc')->select(); $type='cars'; } elseif(input('cars_id')){ $res=model('configure')->where('cars_id',input('cars_id'))->select(); $type='configure'; } else{ $res=model('brand')->order('zm','asc')->order('sort','asc')->select(); } $this->assign('res',$res); $this->assign('type',$type); return $this->fetch(); } ~~~ 前端-简单 ~~~ <div > <?php $zmArr=array(); ?> {foreach name="res" item="vo"} {if condition="isset($vo.zm)"} {if condition="!in_array($vo.zm,$zmArr)"} <span class="item text-center text-red large"><strong>{$vo.zm}</strong></span> {/if} <?php $zmArr[]=$vo['zm']; ?> {/if} <a href="{:url('search',[$type.'_id'=>$vo.id])}" brand_id='{$vo.id}' class="item text-center"> {$vo.name} </a> {/foreach} </div> ~~~ 前端-多 ~~~ <?php $zmArr=array(); ?> {foreach name="res" item="vo"} {if condition="isset($vo.zm)"} {if condition="!in_array($vo.zm,$zmArr)"} <div ng-repeat="(key,item) in cityList" class="clearboth ng-scope"> <div class="cityList_mainWord_div" id="cityList_mainWord_div_A"> <span ng-bind="key" class="cityList_mainWord ng-binding">A</span> </div> {/if} <?php $zmArr[]=$vo['zm']; ?> {/if} <div class="cityList_mainCity_div"> <div ng-repeat="citem in item" class="cityList_mainCity ng-scope"> <div class="click_city"><span ng-bind="citem.city_name" data-pinyin="ANYANG" class="ng-binding">安阳</span> </div> </div> </div> </div> {/foreach} ~~~