|
|
@@ -2,21 +2,24 @@
|
|
|
<page-meta :page-style="sharePopupVisible ? 'overflow:hidden;' : 'overflow:visible;'" />
|
|
|
|
|
|
<view class="page">
|
|
|
- <LoginRequiredState v-if="!isLoggedIn" />
|
|
|
-
|
|
|
- <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
|
|
|
@@ -97,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,
|
|
|
@@ -118,7 +121,6 @@ import { useUserStore } from '@/stores/modules/user'
|
|
|
import AcademicInfoPanel from './components/academic/AcademicInfoPanel.vue'
|
|
|
import ProductAlbumPanel from './components/album/ProductAlbumPanel.vue'
|
|
|
import InformationTabs from './components/shared/InformationTabs.vue'
|
|
|
-import LoginRequiredState from './components/shared/LoginRequiredState.vue'
|
|
|
|
|
|
type TabKey = 'academic' | 'album'
|
|
|
|
|
|
@@ -156,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: '学术信息',
|
|
|
@@ -185,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
|
|
|
)
|
|
|
})
|
|
|
|
|
|
@@ -225,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 = ''
|
|
|
@@ -239,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) {
|
|
|
@@ -274,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
|
|
|
@@ -310,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()
|
|
|
@@ -327,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
|
|
|
|