10.13下午跟新

This commit is contained in:
zoujiandong
2025-10-13 17:41:23 +08:00
parent dd9b2984b2
commit 8b1e9bcb41
914 changed files with 303 additions and 258819 deletions
+6 -2
View File
@@ -30,7 +30,7 @@
import { onShow, onLoad, onPageScroll } from "@dcloudio/uni-app";
import my_api from '@/api/my_api.js'
import docUrl from "@/utils/docUrl.js";
const app = getApp()
// 广告数据
const adData = ref({
path: '',
@@ -59,7 +59,9 @@
// 如果有广告图片,开始倒计时
if (res.data.path) {
startCountdown();
} else {
// 没有广告,直接跳转到首页
navigateToHome();
@@ -81,7 +83,9 @@
countdown.value--;
if (countdown.value <= 0) {
clearInterval(timer);
navigateToHome();
if(app.globalData.plAd){
navigateToHome();
}
}
}, 1000);
}
+167 -3
View File
@@ -317,6 +317,25 @@
</view>
</view>
</up-overlay>
<view class="ad-container" v-if="adData.path && showAd">
<!-- 广告图片 -->
<image
class="ad-image"
:src="adData.path"
mode="aspectFill"
@click="handleAdClick"
></image>
<!-- 右上角倒计时跳过按钮 -->
<view class="skip-button" @click="skipAd">
<text class="skip-text">跳过 {{countdown}}s</text>
</view>
<!-- 底部点击跳转按钮 -->
<view class="bottom-button" v-if="adData.url" @click="handleAdClick">
<text class="button-text">点击查看详情</text>
</view>
</view>
</template>
<script setup lang="ts">
@@ -329,7 +348,7 @@ import {
computed,
onUnmounted,
} from "vue";
import { onShow, onLoad, onPageScroll } from "@dcloudio/uni-app";
import { onShow, onLoad, onPageScroll} from "@dcloudio/uni-app";
import CustomTabbar from "@/components/tabBar/tabBar.vue";
import unidialog from "@/components/dialog/dialog.vue";
import { autorun } from "mobx";
@@ -356,6 +375,18 @@ import {
V2NIMLocalConversationForUI,
} from "@/utils/im/nim";
import { setTabUnread } from "@/utils/im/msg";
import my_api from '@/api/my_api.js'
const app = getApp()
// 广告数据
const adData = ref({
path: '',
url: ''
});
// 倒计时
const countdown = ref(5);
const showAd=ref(true);
let timer = null;
const expertDetail = reactive({});
const hasConsult = ref(false);
const hasMsg = ref(false);
@@ -391,6 +422,82 @@ const handleReadMsg = () => {
comparePatient();
}
};
const getStartpage = () => {
my_api.startpage().then(res => {
console.log('开屏广告数据:', res);
if (res && res.data) {
adData.value = {
path: docUrl + res.data.path || '',
url: res.data.url || ''
};
// 如果有广告图片,开始倒计时
if (res.data.path) {
startCountdown();
} else {
// 没有广告,直接跳转到首页
navigateToHome();
}
} else {
// 接口返回异常,直接跳转到首页
navigateToHome();
}
}).catch(err => {
console.error('获取开屏广告失败:', err);
// 接口调用失败,直接跳转到首页
navigateToHome();
});
}
// 开始倒计时
const startCountdown = () => {
timer = setInterval(() => {
countdown.value--;
if (countdown.value <= 0) {
clearInterval(timer);
if(app.globalData.plAd){
navigateToHome();
}
}
}, 1000);
}
// 跳过广告
const skipAd = () => {
clearInterval(timer);
navigateToHome();
}
// 点击广告
const handleAdClick = () => {
if (adData.value.url) {
// 有跳转链接,跳转到指定页面
uni.navigateTo({
url: '/pages/webview/webview?url=' + adData.value.url
});
} else {
// 没有跳转链接,直接跳转到首页
navigateToHome();
}
}
// 跳转到首页
const navigateToHome = () => {
showAd.value=false;
app.globalData.plAd=false;
// uni.redirectTo({
// url: '/pages/index/index'
// });
}
// 页面卸载时清理定时器
onUnmounted(() => {
if (timer) {
clearInterval(timer);
}
});
const goCourseDetail=(item)=>{
navTo({
url: "/pages_course/course_detail/course_detail?id="+item.id,
@@ -1064,8 +1171,12 @@ onPageScroll((e) => {
});
// 页面加载
onLoad(() => {
onLoad((options) => {
if(options.from == 'push'){
app.globalData.plAd=false;
showAd.value=false;
}
getStartpage();
// 获取首页数据
getHomeData();
// 页面加载完成后测试tabbar功能
@@ -1078,6 +1189,8 @@ onShow(() => {
if (conversationList.value?.length) {
subscribeUserStatus(conversationList?.value);
}
handleReadMsg();
getUnReadList();
});
@@ -1916,4 +2029,55 @@ defineExpose({
:deep(.uni-searchbar__box) {
height: 60rpx !important;
}
.ad-container {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: #000;
z-index: 9999;
}
.ad-image {
width: 100%;
height: 100%;
object-fit: cover;
}
.skip-button {
position: absolute;
top: 60rpx;
right: 30rpx;
background-color: rgba(0, 0, 0, 0.6);
border-radius: 40rpx;
padding: 16rpx 24rpx;
z-index: 10000;
}
.skip-text {
color: #fff;
font-size: 28rpx;
font-weight: 500;
}
.bottom-button {
position: absolute;
bottom: 100rpx;
left: 50%;
transform: translateX(-50%);
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-radius: 50rpx;
padding: 24rpx 60rpx;
box-shadow: 0 8rpx 32rpx rgba(102, 126, 234, 0.3);
z-index: 10000;
}
.button-text {
color: #fff;
font-size: 32rpx;
font-weight: 600;
}
</style>