ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## ajax下拉列表 基础用例: ``` ['type' => 'selectajax', 'name' => 'user_id', 'title' =>'会员ID'], ``` 默认可以搜索会员并返回会员ID 高级用例: ``` ['type' => 'selectajax', 'name' => 'goods_id', 'title' =>'商品ID','url' => url('searchGoods')], ``` 可以指定url获取数据,需要自己写一个控制器方法: ``` /** * selectAJAX插件搜索商品 */ public function searchGoods() { // 查询 $key = input('key/s', ''); if ($key == '') { return ''; } $where[] = ["goods.status", "=", 1]; $where[] = ["goods.is_sale", "=", 1]; $where[] = ['goods.is_delete', '=', 0]; $where[] = ['goods.name', 'like', "%".$key."%"]; // 数据列表 $data_list = Goods::view("goods","id,name,shop_price,thumb") ->view("goods_category","name as cate_name","goods.cid = goods_category.id","left") ->where($where) ->paginate(20); $results = []; foreach ($data_list as $v) { $str = '<img src="'.get_thumb($v["thumb"]).'" height="28px" style="float:left;margin-right:10px"/>【'.$v['cate_name'] . '】/' .$v['id'] . '/' . $v['name'] . '/¥' . $v['shop_price'] ; $results[] = ['id' => $v['id'], 'text' => $str]; } $data['results'] = $results; $data['pagination'] = $data_list->currentPage() == $data_list->lastPage() ? ['more' => true] : ['more' => false]; return json($data, JSON_UNESCAPED_UNICODE); } ``` PS:如需使用此插件,需升级到2.0版本,需要注意2.0版本与之前版本不兼容