Commit c9fc0671 by Sweet Zhang

解决文件在手机上不能直接打开的问题

parent 1e4cf0b9
...@@ -149,6 +149,7 @@ ...@@ -149,6 +149,7 @@
uni.setStorageSync('isLogin','1'); uni.setStorageSync('isLogin','1');
uni.setStorageSync('loginType','codelogin'); uni.setStorageSync('loginType','codelogin');
uni.setStorageSync('cffp_userId', this.userId); uni.setStorageSync('cffp_userId', this.userId);
console.log('============',uni.getStorageSync('cffp_userId'))
uni.setStorageSync('uni-token', res.data['token']); uni.setStorageSync('uni-token', res.data['token']);
this.loginTypeSync = "codelogin"; this.loginTypeSync = "codelogin";
this.queryInfo() this.queryInfo()
......
...@@ -182,6 +182,7 @@ ...@@ -182,6 +182,7 @@
this.userId = String(res['data']['userId']); this.userId = String(res['data']['userId']);
uni.setStorageSync('isLogin','1'); uni.setStorageSync('isLogin','1');
uni.setStorageSync('cffp_userId',this.userId); uni.setStorageSync('cffp_userId',this.userId);
console.log('============',uni.getStorageSync('cffp_userId'))
uni.setStorageSync('loginType',this.loginType); uni.setStorageSync('loginType',this.loginType);
uni.setStorageSync('uni-token', res.data['token']); uni.setStorageSync('uni-token', res.data['token']);
......
...@@ -107,6 +107,7 @@ ...@@ -107,6 +107,7 @@
uni.setStorageSync('isLogin', '1'); uni.setStorageSync('isLogin', '1');
uni.setStorageSync('loginType', 'codelogin'); uni.setStorageSync('loginType', 'codelogin');
uni.setStorageSync('cffp_userId', res.data['userId']); uni.setStorageSync('cffp_userId', res.data['userId']);
console.log('============',uni.getStorageSync('cffp_userId'))
uni.setStorageSync('uni-token', res.data['token']); uni.setStorageSync('uni-token', res.data['token']);
//关闭弹窗 //关闭弹窗
this.$refs.loginPopup.close(); this.$refs.loginPopup.close();
......
...@@ -53,7 +53,7 @@ const config = { ...@@ -53,7 +53,7 @@ const config = {
stage, stage,
prod prod
} }
let env = 'prod'; let env = 'dev';
let baseURL = config[env].base_url; let baseURL = config[env].base_url;
let apiURL = config[env].api_url; let apiURL = config[env].api_url;
......
...@@ -98,6 +98,8 @@ ...@@ -98,6 +98,8 @@
</view> </view>
<!-- 放在 </view> 最后,</template> 之前 --> <!-- 放在 </view> 最后,</template> 之前 -->
<!-- PDF 查看弹窗 --> <!-- PDF 查看弹窗 -->
<!-- 调试用 -->
<view v-if="showPdfModal">Debug URL: {{ currentPdfUrl }}</view>
<uni-popup <uni-popup
ref="pdfPopupRef" ref="pdfPopupRef"
:mask-click="true" :mask-click="true"
...@@ -111,16 +113,17 @@ ...@@ -111,16 +113,17 @@
</view> </view>
<!-- PDF 查看器 --> <!-- PDF 查看器 -->
<view class="pdf-viewer-wrapper" v-if="showPdfModal"> <view class="pdf-viewer-wrapper" v-if="showPdfModal && currentPdfUrl">
<PdfViewer <PdfViewer
:pdfInfo="{ url: currentPdfUrl }" :pdfInfo="{ url: currentPdfUrl }"
:autoLoad="true" :autoLoad="true"
:lazyLoad="true" :lazyLoad="false"
:maxRetryCount="2" :maxRetryCount="2"
:loadingStatus="true" @loadComplete="handlePdfLoadComplete"
style="height: 100%; width: 100%;" @loadError="handlePdfLoadError"
/> @pageChange="handlePageChange"
</view> />
</view>
</view> </view>
</uni-popup> </uni-popup>
</template> </template>
...@@ -130,11 +133,10 @@ import { ref, computed, onMounted } from 'vue'; ...@@ -130,11 +133,10 @@ import { ref, computed, onMounted } from 'vue';
import { useRouter, useRoute } from 'vue-router'; import { useRouter, useRoute } from 'vue-router';
import common from '@/common/common'; import common from '@/common/common';
import api from '@/api/api'; import api from '@/api/api';
// 导入PDF查看器组件
import { onBeforeUnmount } from 'vue';
import PdfViewer from '@/components/pdf-viewer/pdf-viewer.vue'; import PdfViewer from '@/components/pdf-viewer/pdf-viewer.vue';
import { onBeforeUnmount } from 'vue';
import uniPopup from '@dcloudio/uni-ui/lib/uni-popup/uni-popup.vue'; import uniPopup from '@dcloudio/uni-ui/lib/uni-popup/uni-popup.vue';
const pdfPopupRef = ref(); const pdfPopupRef = ref();
// 路由实例 // 路由实例
const router = useRouter(); const router = useRouter();
...@@ -294,16 +296,21 @@ const navigateToPKPage = () => { ...@@ -294,16 +296,21 @@ const navigateToPKPage = () => {
const showPdfModal = ref(false); const showPdfModal = ref(false);
const currentPdfUrl = ref(''); const currentPdfUrl = ref('');
// 修改 getUrl 方法
const getUrl = (fileUrl) => { const getUrl = (fileUrl) => {
if (!fileUrl) { if (!fileUrl) {
uni.showToast({ title: '暂无文档', icon: 'none' }); uni.showToast({ title: '暂无文档', icon: 'none' });
return; return;
} }
uni.showLoading({ title: '加载PDF中...' }); uni.showLoading({ title: '加载PDF中...' });
// 所有平台统一处理:弹出 PdfViewer
currentPdfUrl.value = fileUrl; currentPdfUrl.value = fileUrl;
showPdfModal.value = true; showPdfModal.value = true;
console.log('Opening PDF:', fileUrl);
// 延迟打开弹窗,确保数据已绑定
setTimeout(() => {
pdfPopupRef.value?.open?.();
uni.hideLoading();
}, 100);
}; };
// 关闭弹窗 // 关闭弹窗
...@@ -587,6 +594,9 @@ onMounted(() => { ...@@ -587,6 +594,9 @@ onMounted(() => {
border-radius: 50%; border-radius: 50%;
border: none; border: none;
color: #999; color: #999;
display: flex;
justify-content: center;
align-items: center;
} }
.pdf-viewer-wrapper { .pdf-viewer-wrapper {
......
...@@ -764,10 +764,9 @@ ...@@ -764,10 +764,9 @@
} }
api.loginVerification(params).then((res)=>{ api.loginVerification(params).then((res)=>{
if(res['success']){ if(res['success']){
uni.setStorageSync('isLogin','1'); uni.setStorageSync('isLogin','1');
uni.setStorageSync('loginType','codelogin'); uni.setStorageSync('loginType','codelogin');
uni.setStorageSync('cffp_userId', res.data.userId); uni.setStorageSync('cffp_userId', JSON.stringify(res.data.userId));
uni.setStorageSync('uni-token', res.data['token']); uni.setStorageSync('uni-token', res.data['token']);
this.userId = res.data.userId this.userId = res.data.userId
this.querySystemMessage() this.querySystemMessage()
......
...@@ -130,7 +130,8 @@ const companyPdf = ref<PdfItem>({ ...@@ -130,7 +130,8 @@ const companyPdf = ref<PdfItem>({
// urls: Array.from({ length: 21 }, (_, i) => // urls: Array.from({ length: 21 }, (_, i) =>
// `${OSS_BASE_URL}/public/company-intro_part${i + 1}.pdf` // `${OSS_BASE_URL}/public/company-intro_part${i + 1}.pdf`
// ), // ),
urls: [`${OSS_BASE_URL}/public/company-intro.pdf`], // urls: [`${OSS_BASE_URL}/public/company-intro.pdf`],
urls: [`${OSS_BASE_URL}/wslucky/product/2025/06/24/31c164ac-565c-4990-a584-b5d4935840d0.pdf`],
type: 'showURL' type: 'showURL'
}); });
...@@ -310,7 +311,7 @@ const switchTab = (index: number) => { ...@@ -310,7 +311,7 @@ const switchTab = (index: number) => {
const tabs = filteredCurrentTabs.value; const tabs = filteredCurrentTabs.value;
if (index < 0 || index >= tabs.length || tabs.length === 0) return; if (index < 0 || index >= tabs.length || tabs.length === 0) return;
uni.showLoading({ title: '切换中...' }); loading.value = true;
setTimeout(() => { setTimeout(() => {
activeTab.value = index; activeTab.value = index;
...@@ -318,7 +319,7 @@ const switchTab = (index: number) => { ...@@ -318,7 +319,7 @@ const switchTab = (index: number) => {
uni.setStorageSync('tabsIndex', index); uni.setStorageSync('tabsIndex', index);
setTimeout(() => { setTimeout(() => {
uni.hideLoading(); loading.value = false;
}, 300); }, 300);
}, 100); }, 100);
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment