index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view class="phone-haibao-page">
  3. <view class="icon-title-navBar-box">
  4. <view @click="goUpPage" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">职业海报</text>
  6. </view>
  7. <view class="haibao-body-box">
  8. <view class="haibao-menu-box">
  9. <view v-for="menu in menuData" :key="menu.id" class="menu-item-box"
  10. :class="{ active: selectedCategory == menu.id }"
  11. @click="menuBtn(menu.id)">
  12. {{ menu.name }}
  13. </view>
  14. </view>
  15. <view class="haibao-show-box">
  16. <view class="haibao-title">共{{cardData.length}}个海报</view>
  17. <view class="card-list-box">
  18. <view v-for="item in cardData" :key="item.id" class="haibao-card-box"
  19. @click="cardBtn(item.id)">
  20. <img :src="item.image"/>
  21. <view class="card-name">{{ item.name }}</view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script setup>
  29. import * as httpApi from '@/api/haibao.js'
  30. import { ref, reactive } from "vue"
  31. import {onLoad} from "@dcloudio/uni-app";
  32. const menuData = ref([])
  33. const cardData = ref([])
  34. // 当前选中的分类
  35. const selectedCategory = ref(null)
  36. function goUpPage() {
  37. uni.redirectTo({
  38. url: `/pages/admin/ShouYe/shouye`
  39. })
  40. }
  41. function getHaibaoListData(data) {
  42. httpApi.getHaibaoList({zyId:data}).then(res =>{
  43. cardData.value = res.data;
  44. })
  45. }
  46. function menuBtn(id){
  47. getHaibaoListData(id);
  48. selectedCategory.value = id;
  49. console.log('selectedCategory.value',selectedCategory.value);
  50. }
  51. function cardBtn(data){
  52. uni.redirectTo({
  53. url:`/pages/admin/haibao/haibaoInfo?cardId=${data}&menuId=${selectedCategory.value}`
  54. })
  55. }
  56. function pageInit(){
  57. httpApi.getHaibaoOpsZhiye().then(res =>{
  58. menuData.value = res.data;
  59. if(menuData.value){
  60. selectedCategory.value = menuData.value[0].id;
  61. getHaibaoListData(selectedCategory.value);
  62. }
  63. })
  64. }
  65. function pageRecover(data){
  66. httpApi.getHaibaoOpsZhiye().then(res =>{
  67. menuData.value = res.data;
  68. menuBtn(data.menuId);
  69. })
  70. }
  71. onLoad((options) => {
  72. // 详情页返回
  73. if(options.menuId){
  74. pageRecover(options)
  75. }else{
  76. // 首页进入
  77. pageInit()
  78. }
  79. })
  80. </script>