1
0

2 Коммитууд 5635783208 ... 28be456900

Эзэн SHA1 Мессеж Огноо
  yuanmingze 28be456900 Merge branch 'feature/caitianxia/261010' into pre 1 долоо хоног өмнө
  yuanmingze 7790f3f145 完成咨询页面未登录状态游客接口 1 долоо хоног өмнө

+ 2 - 0
src/pages/information/components/academic/AcademicArticleItem.vue

@@ -18,6 +18,7 @@
       </view>
 
       <button
+        v-if="shareEnabled"
         class="share-button"
         hover-class="share-button--hover"
         @tap.stop="emit('share', item)"
@@ -43,6 +44,7 @@ import type { ArticleItem } from '@/services/modules/information/type'
 
 const props = defineProps<{
   item: ArticleItem
+  shareEnabled: boolean
 }>()
 
 const emit = defineEmits<{

+ 15 - 3
src/pages/information/components/academic/AcademicInfoPanel.vue

@@ -2,7 +2,7 @@
   <view class="academic-panel">
     <InformationBannerSwiper />
 
-    <view class="search-section">
+    <view v-if="isLoggedIn" class="search-section">
       <InformationSearchBar @search="handleSearch" />
     </view>
 
@@ -11,6 +11,7 @@
         v-for="item in articleList"
         :key="item.id"
         :item="item"
+        :share-enabled="isLoggedIn"
         @select="handleArticleClick"
         @share="emit('share', $event)"
       />
@@ -29,9 +30,9 @@
 </template>
 
 <script setup lang="ts">
-import { onMounted, ref } from 'vue'
+import { computed, onMounted, ref } from 'vue'
 
-import { getArticlePageApi } from '@/services/modules/information'
+import { getArticlePageApi, getGuestArticlePageApi } from '@/services/modules/information'
 import type { ArticleItem, ArticlePageRequest } from '@/services/modules/information/type'
 
 import { useUserStore } from '@/stores/modules/user'
@@ -47,6 +48,7 @@ const emit = defineEmits<{
 }>()
 
 const userStore = useUserStore()
+const isLoggedIn = computed(() => userStore.isLoggedIn)
 
 const articleList = ref<ArticleItem[]>([])
 const loading = ref(false)
@@ -79,6 +81,14 @@ const getArticleList = async (current = 1, append = false): Promise<void> => {
   loading.value = true
 
   try {
+    if (!isLoggedIn.value) {
+      const { data } = await getGuestArticlePageApi()
+      articleList.value = Array.isArray(data) ? data : data?.records || []
+      currentPage.value = 1
+      finished.value = true
+      return
+    }
+
     const { data } = await getArticlePageApi(buildRequestParams(current))
 
     const records = Array.isArray(data?.records) ? data.records : []
@@ -116,6 +126,8 @@ const handleSearch = (params: { region: string; keyword: string }): void => {
 }
 
 const handleArticleClick = (item: ArticleItem): void => {
+  if (!isLoggedIn.value) return
+
   uni.navigateTo({
     url: `/pages/information/detail/index?type=academic&id=${item.id}`,
   })

+ 2 - 0
src/pages/information/components/album/ProductAlbumItem.vue

@@ -28,6 +28,7 @@
         </text>
 
         <button
+          v-if="shareEnabled"
           class="share-button"
           hover-class="share-button--hover"
           @tap.stop="emit('share', item)"
@@ -54,6 +55,7 @@ import type { AlbumPageNewItem } from '@/services/modules/information/type'
 
 const props = defineProps<{
   item: AlbumPageNewItem
+  shareEnabled: boolean
 }>()
 
 const emit = defineEmits<{

+ 15 - 3
src/pages/information/components/album/ProductAlbumPanel.vue

@@ -1,6 +1,6 @@
 <template>
   <view class="album-panel">
-    <view class="search-section">
+    <view v-if="isLoggedIn" class="search-section">
       <view class="search-card">
         <input
           v-model="keyword"
@@ -24,6 +24,7 @@
         v-for="item in albumList"
         :key="item.id"
         :item="item"
+        :share-enabled="isLoggedIn"
         @select="handleAlbumClick"
         @share="emit('share', $event)"
       />
@@ -42,11 +43,11 @@
 </template>
 
 <script setup lang="ts">
-import { onBeforeUnmount, onMounted, ref } from 'vue'
+import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
 
 import { debounce } from '@/plugins/debounce'
 
-import { getAlbumPageApi } from '@/services/modules/information'
+import { getAlbumPageApi, getGuestAlbumPageApi } from '@/services/modules/information'
 import type { AlbumPageNewItem } from '@/services/modules/information/type'
 
 import { useUserStore } from '@/stores/modules/user'
@@ -60,6 +61,7 @@ const emit = defineEmits<{
 }>()
 
 const userStore = useUserStore()
+const isLoggedIn = computed(() => userStore.isLoggedIn)
 
 const albumList = ref<AlbumPageNewItem[]>([])
 const loading = ref(false)
@@ -89,6 +91,14 @@ const getAlbumList = async (current = 1, append = false) => {
   loading.value = true
 
   try {
+    if (!isLoggedIn.value) {
+      const { data } = await getGuestAlbumPageApi()
+      albumList.value = Array.isArray(data) ? data : data?.records || []
+      currentPage.value = 1
+      finished.value = true
+      return
+    }
+
     const { data } = await getAlbumPageApi(buildRequestParams(current))
 
     const records = Array.isArray(data?.records) ? data.records : []
@@ -156,6 +166,8 @@ const clearKeyword = async () => {
 }
 
 const handleAlbumClick = (item: AlbumPageNewItem) => {
+  if (!isLoggedIn.value) return
+
   if (!item.id) {
     uni.showToast({
       title: '相册信息异常',

+ 57 - 23
src/pages/information/index.vue

@@ -2,23 +2,24 @@
   <page-meta :page-style="sharePopupVisible ? 'overflow:hidden;' : 'overflow:visible;'" />
 
   <view class="page">
-    <view v-if="!isLoggedIn" class="empty-state">
-      <wd-empty icon="no-content" tip="暂无数据" />
-    </view>
-
-    <template v-else>
-      <InformationTabs v-model="activeTab" :tabs="tabs" />
-
-      <AcademicInfoPanel
-        v-if="activeTab === 'academic'"
-        ref="academicPanelRef"
-        @share="openArticleShare"
-      />
-
-      <ProductAlbumPanel v-else ref="albumPanelRef" @share="openAlbumShare" />
-    </template>
+    <InformationTabs v-model="activeTab" :tabs="tabs" />
+
+    <AcademicInfoPanel
+      v-if="activeTab === 'academic'"
+      :key="`academic:${panelKey}`"
+      ref="academicPanelRef"
+      @share="openArticleShare"
+    />
+
+    <ProductAlbumPanel
+      v-else
+      :key="`album:${panelKey}`"
+      ref="albumPanelRef"
+      @share="openAlbumShare"
+    />
   </view>
   <wd-popup
+    v-if="isLoggedIn"
     v-model="sharePopupVisible"
     position="bottom"
     root-portal
@@ -99,9 +100,9 @@
 </template>
 
 <script setup lang="ts">
-import { computed, ref } from 'vue'
+import { computed, ref, watch } from 'vue'
 
-import { onPullDownRefresh, onReachBottom, onShareAppMessage } from '@dcloudio/uni-app'
+import { onPullDownRefresh, onReachBottom, onShareAppMessage, onShow } from '@dcloudio/uni-app'
 
 import {
   getPackageListByTaskTypeAndAlbumIdApi,
@@ -157,6 +158,10 @@ const isLoggedIn = computed<boolean>(() => {
   return Boolean(userStore.isLoggedIn)
 })
 
+const panelKey = computed(() => {
+  return `${userStore.access_token || 'guest'}:${userStore.currentUserInfo?.userId || ''}`
+})
+
 const tabs: TabItem[] = [
   {
     label: '学术信息',
@@ -186,7 +191,10 @@ const selectedPackage = computed<SharePackageItem | undefined>(() => {
 
 const canSubmitShare = computed<boolean>(() => {
   return Boolean(
-    shareTarget.value?.id && selectedPackage.value?.value && !sharePickerScrolling.value
+    isLoggedIn.value &&
+    shareTarget.value?.id &&
+    selectedPackage.value?.value &&
+    !sharePickerScrolling.value
   )
 })
 
@@ -226,8 +234,9 @@ const openAlbumShare = async (item: AlbumPageNewItem): Promise<void> => {
 }
 
 const openShare = async (target: ShareTarget): Promise<void> => {
-  if (loadingSharePackages.value || showBlacklistWarning()) return
+  if (!isLoggedIn.value || loadingSharePackages.value || showBlacklistWarning()) return
 
+  const requestPanelKey = panelKey.value
   loadingSharePackages.value = true
   shareTarget.value = target
   shareRemark.value = ''
@@ -240,6 +249,8 @@ const openShare = async (target: ShareTarget): Promise<void> => {
       target.type === 'academic'
         ? await getPackageListByTaskTypeApi(ARTICLE_TASK_TYPE)
         : await getPackageListByTaskTypeAndAlbumIdApi(ALBUM_TASK_TYPE, target.id)
+    if (!isLoggedIn.value || requestPanelKey !== panelKey.value) return
+
     const packageList = Array.isArray(res.data) ? res.data : []
 
     if (packageList.length === 0) {
@@ -275,6 +286,8 @@ const reportShare = async (params: {
   packageId: string
   remark: string
 }): Promise<void> => {
+  if (!isLoggedIn.value) return
+
   const userId = userStore.currentUserInfo?.userId || ''
 
   if (!userId) return
@@ -311,16 +324,30 @@ const reportShare = async (params: {
   }
 }
 
-onReachBottom(() => {
-  if (!isLoggedIn.value) return
+const updateShareMenu = (): void => {
+  // #ifdef MP-WEIXIN
+  if (isLoggedIn.value) {
+    wx.showShareMenu({ menus: ['shareAppMessage'] })
+  } else {
+    wx.hideShareMenu({ menus: ['shareAppMessage', 'shareTimeline'] })
+  }
+  // #endif
+}
+
+watch(panelKey, () => {
+  sharePopupVisible.value = false
+  resetShareForm()
+  updateShareMenu()
+})
+
+onShow(updateShareMenu)
 
+onReachBottom(() => {
   void currentPanel.value?.loadMore()
 })
 
 onPullDownRefresh(async () => {
   try {
-    if (!isLoggedIn.value) return
-
     await currentPanel.value?.refresh()
   } finally {
     uni.stopPullDownRefresh()
@@ -328,6 +355,13 @@ onPullDownRefresh(async () => {
 })
 
 onShareAppMessage((res) => {
+  if (!isLoggedIn.value) {
+    return {
+      title: '要易小助手',
+      path: '/pages/information/index',
+    }
+  }
+
   const dataset =
     res.from === 'button' ? (res.target?.dataset as ShareDataset | undefined) : undefined
 

+ 22 - 0
src/services/modules/information/index.ts

@@ -18,6 +18,17 @@ export const getArticlePageApi = (data: ArticlePageRequest) => {
   })
 }
 
+export const getGuestArticlePageApi = () => {
+  return http.get<ArticlePageResponse | ArticleItem[]>(
+    `/admin/api/getGuestArticlePage`,
+    undefined,
+    {
+      loading: true,
+      loadingText: '加载中...',
+    }
+  )
+}
+
 export const getAlbumPageApi = (data: AlbumPageNewRequest) => {
   return http.get<AlbumPageNewResponse>(`/admin/api/getAlbumPageNew`, data, {
     loading: true,
@@ -25,6 +36,17 @@ export const getAlbumPageApi = (data: AlbumPageNewRequest) => {
   })
 }
 
+export const getGuestAlbumPageApi = () => {
+  return http.get<AlbumPageNewResponse | AlbumPageNewItem[]>(
+    `/admin/api/getGuestAlbumPage`,
+    undefined,
+    {
+      loading: true,
+      loadingText: '加载中...',
+    }
+  )
+}
+
 export const getArticleByIdApi = (id: string) => {
   return http.get<ArticleItem>(`/admin/api/getArticleById?id=${id}`)
 }