|
|
@@ -7,7 +7,7 @@
|
|
|
<view class="haibao-body-box">
|
|
|
<view class="haibao-menu-box">
|
|
|
<view v-for="menu in menuData" :key="menu.id" class="menu-item-box"
|
|
|
- :class="{ active: selectedCategory == menu.id }"
|
|
|
+ :class="{ active: selectedCategory === Number(menu.id) }"
|
|
|
@click="menuBtn(menu.id)">
|
|
|
{{ menu.name }}
|
|
|
</view>
|
|
|
@@ -42,37 +42,58 @@ function goUpPage() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-function getHaibaoListData(data) {
|
|
|
- httpApi.getHaibaoList({zyId:data}).then(res =>{
|
|
|
- cardData.value = res.data;
|
|
|
- })
|
|
|
- }
|
|
|
+// 加载海报列表
|
|
|
+function getHaibaoListData(zyId) {
|
|
|
+ if (zyId == null) return;
|
|
|
+ httpApi.getHaibaoList({ zyId }).then(res => {
|
|
|
+ cardData.value = Array.isArray(res.data) ? res.data : [];
|
|
|
+ }).catch(err => {
|
|
|
+ console.error('获取海报列表失败:', err);
|
|
|
+ cardData.value = [];
|
|
|
+ uni.showToast({ title: '加载失败', icon: 'none' });
|
|
|
+ });
|
|
|
+}
|
|
|
|
|
|
-function menuBtn(id){
|
|
|
- getHaibaoListData(id);
|
|
|
- selectedCategory.value = id;
|
|
|
- console.log('selectedCategory.value',selectedCategory.value);
|
|
|
+// 菜单按钮点击
|
|
|
+function menuBtn(id) {
|
|
|
+ const numericId = Number(id);
|
|
|
+ selectedCategory.value = numericId;
|
|
|
+ getHaibaoListData(numericId);
|
|
|
}
|
|
|
|
|
|
-function cardBtn(data){
|
|
|
- uni.redirectTo({
|
|
|
- url:`/pages/admin/haibao/haibaoInfo?cardId=${data}&menuId=${selectedCategory.value}`
|
|
|
- })
|
|
|
+// 海报卡片点击
|
|
|
+function cardBtn(data) {
|
|
|
+ uni.redirectTo({
|
|
|
+ url: `/pages/admin/haibao/haibaoInfo?cardId=${data}&menuId=${selectedCategory.value}`
|
|
|
+ });
|
|
|
}
|
|
|
-function pageInit(){
|
|
|
- httpApi.getHaibaoOpsZhiye().then(res =>{
|
|
|
- menuData.value = res.data;
|
|
|
- if(menuData.value){
|
|
|
- selectedCategory.value = menuData.value[0].id;
|
|
|
- getHaibaoListData(selectedCategory.value);
|
|
|
- }
|
|
|
- })
|
|
|
+
|
|
|
+// 首次进入页面初始化
|
|
|
+function pageInit() {
|
|
|
+ httpApi.getHaibaoOpsZhiye().then(res => {
|
|
|
+ menuData.value = Array.isArray(res.data) ? res.data : [];
|
|
|
+ if (menuData.value.length > 0) {
|
|
|
+ const firstId = Number(menuData.value[0].id);
|
|
|
+ selectedCategory.value = firstId;
|
|
|
+ getHaibaoListData(firstId);
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ console.error('初始化职业失败:', err);
|
|
|
+ menuData.value = [];
|
|
|
+ uni.showToast({ title: '职业加载失败', icon: 'none' });
|
|
|
+ });
|
|
|
}
|
|
|
-function pageRecover(data){
|
|
|
- httpApi.getHaibaoOpsZhiye().then(res =>{
|
|
|
- menuData.value = res.data;
|
|
|
- menuBtn(data.menuId);
|
|
|
- })
|
|
|
+
|
|
|
+// 从详情页返回时恢复状态
|
|
|
+function pageRecover(data) {
|
|
|
+ httpApi.getHaibaoOpsZhiye().then(res => {
|
|
|
+ menuData.value = Array.isArray(res.data) ? res.data : [];
|
|
|
+ const menuId = Number(data.menuId);
|
|
|
+ menuBtn(menuId);
|
|
|
+ }).catch(err => {
|
|
|
+ console.error('页面加载:', err);
|
|
|
+ uni.showToast({ title: '页面加载失败', icon: 'none' });
|
|
|
+ });
|
|
|
}
|
|
|
onLoad((options) => {
|
|
|
// 详情页返回
|