You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
135 lines
3.1 KiB
135 lines
3.1 KiB
<?php
|
|
|
|
namespace app\appapi\controller;
|
|
|
|
use app\appapi\BaseController;
|
|
use support\Request;
|
|
use think\facade\Db;
|
|
|
|
class IndexController extends BaseController
|
|
{
|
|
public function getConfig(Request $request)
|
|
{
|
|
$param = $request->get();
|
|
// $where[] = ['lang', $param['lang']];
|
|
|
|
$list = Db::name('config')
|
|
// ->where($where)
|
|
->select()
|
|
->toArray();
|
|
|
|
$result = [];
|
|
foreach ($list as $key => $val) {
|
|
$result[$val['lang']][$val['code']] = $val['value'];
|
|
}
|
|
|
|
return $this->Success($result);
|
|
}
|
|
|
|
public function getBannerList(Request $request)
|
|
{
|
|
$param = $request->get();
|
|
// $where[] = ['lang', $param['lang']];
|
|
|
|
$list = Db::name('banner')
|
|
->where('lang', $param['lang'])
|
|
->order('id', 'desc')
|
|
->order('sort_order', 'asc')
|
|
->select()
|
|
->toArray();
|
|
|
|
|
|
$result = $list;
|
|
|
|
return $this->Success($result);
|
|
}
|
|
|
|
public function getParentCateList(Request $request)
|
|
{
|
|
$param = $request->get();
|
|
|
|
$where = [];
|
|
|
|
$list = Db::name('category')
|
|
->where('lang', $param['lang'])
|
|
->where('parent_id', 0)
|
|
->order('sort_order', 'asc')
|
|
->select()
|
|
->toArray();
|
|
|
|
|
|
// foreach($list as $key => $val){
|
|
|
|
// }
|
|
|
|
return $this->Success($list);
|
|
}
|
|
|
|
public function getSupplierList(Request $request)
|
|
{
|
|
$param = $request->get();
|
|
// $where[] = ['lang', $param['lang']];
|
|
|
|
$list = Db::name('supplier')
|
|
->order('sort_order', 'asc')
|
|
->order('id', 'asc')
|
|
->select()
|
|
->toArray();
|
|
|
|
|
|
foreach ($list as $key => $val) {
|
|
switch($param['lang']){
|
|
case 'tw':
|
|
$list[$key]['name'] = $val['name1'];
|
|
break;
|
|
case 'en':
|
|
$list[$key]['name'] = $val['name2'];
|
|
break;
|
|
case 'cn':
|
|
$list[$key]['name'] = $val['name3'];
|
|
break;
|
|
}
|
|
|
|
$list[$key]['imageurl'] = $val['imageurl'];
|
|
}
|
|
|
|
$result = $list;
|
|
|
|
return $this->Success($result);
|
|
}
|
|
|
|
public function getCateList(Request $request)
|
|
{
|
|
$param = $request->get();
|
|
|
|
$where = [];
|
|
|
|
$list = Db::name('category')
|
|
->where('lang', $param['lang'])
|
|
->order('sort_order', 'asc')
|
|
->order('id', 'asc')
|
|
->select()
|
|
->toArray();
|
|
|
|
$list = $this->genCategoryTree($list);
|
|
|
|
// foreach($list as $key => $val){
|
|
|
|
// }
|
|
|
|
return $this->Success($list);
|
|
}
|
|
|
|
public function genCategoryTree($list, $parent_id = 0)
|
|
{
|
|
$tree = [];
|
|
foreach ($list as $key => $val) {
|
|
if ($val['parent_id'] == $parent_id) {
|
|
$val['children'] = $this->genCategoryTree($list, $val['id']);
|
|
$tree[] = $val;
|
|
}
|
|
}
|
|
return $tree;
|
|
}
|
|
}
|