diff --git a/app/app/appapi/controller/IndexController.php b/app/app/appapi/controller/IndexController.php index f4a1e50..105f1f3 100644 --- a/app/app/appapi/controller/IndexController.php +++ b/app/app/appapi/controller/IndexController.php @@ -47,6 +47,7 @@ class IndexController extends BaseController return $this->Success($result); } + // 取得父類別列表 public function getParentCateList(Request $request) { $param = $request->get(); @@ -61,9 +62,15 @@ class IndexController extends BaseController ->toArray(); - // foreach($list as $key => $val){ - - // } + foreach($list as $key => $val){ + // 取得子類別編號 + $list[$key]['cid'] = Db::name('category') + ->where('lang', $param['lang']) + ->where('parent_id', $val['id']) + ->order('sort_order', 'asc') + ->limit(1) + ->value('id'); + } return $this->Success($list); } diff --git a/web/pages/index.vue b/web/pages/index.vue index 7397f83..1db9847 100644 --- a/web/pages/index.vue +++ b/web/pages/index.vue @@ -6,6 +6,7 @@ import featureImg from '@/assets/img/iStock.jpg'; const { locale } = useI18n() const store = useStore(); +const router = useRouter(); const { config } = storeToRefs(store); @@ -58,6 +59,13 @@ onMounted(async () => { }); }) + +// 至產品頁 +const goProd = (cid) => { + if(cid && cid !== null){ + router.push({ path: '/products/list/' + cid }); + } +}