增加开屏广告和修改轮播图问题

This commit is contained in:
A1300399510 2025-02-26 18:56:47 +08:00
parent b55f1ddfac
commit efc800d474
14 changed files with 299 additions and 11 deletions

3
app.js
View File

@ -240,5 +240,8 @@ App({
isConnected: false,
offerkaipingadvertisement: {}, // 开屏广告 数据
offerkaipingadvertisementState: false, // 开屏广告 状态
initialState: false,
}
})

View File

@ -23,7 +23,7 @@
<!-- 群发 -->
<view class="information-item" wx:if="{{ item.event == 'certapplication' }}">
<view class="time"><text>{{ item.timestamp }}</text>
<image wx:if="{{ item.isread == 0 }}" mode="widthFix" src="../../img/u20.png"></image>
<image wx:if="{{ item.status == 0 }}" mode="widthFix" src="../../img/u20.png"></image>
</view>
<view code="true" class="information-title">
<view class="information-message" style="display: inline; word-break: break-all;">{{ item.message }}</view>
@ -41,7 +41,7 @@
<!-- 中介 -->
<view class="information-item" wx:elif="{{ item.event == 'middlemanauth' }}">
<view class="time"><text>{{ item.timestamp }}</text>
<image wx:if="{{ item.isread == 0 }}" mode="widthFix" src="../../img/u20.png"></image>
<image wx:if="{{ item.status == 0 }}" mode="widthFix" src="../../img/u20.png"></image>
</view>
<view code="true" class="information-title">
<view class="information-message" style="display: inline; word-break: break-all;">{{ item.message }}</view>
@ -59,7 +59,7 @@
<!-- 房源认证 -->
<view class="information-item" wx:elif="{{ item.event == 'tenementcertified' }}">
<view class="time"><text>{{ item.timestamp }}</text>
<image wx:if="{{ item.isread == 0 }}" mode="widthFix" src="../../img/u20.png"></image>
<image wx:if="{{ item.status == 0 }}" mode="widthFix" src="../../img/u20.png"></image>
</view>
<view code="true" class="information-title">
<view class="information-message" style="display: inline; word-break: break-all;">{{ item.message }}</view>
@ -87,7 +87,7 @@
<!-- 到期 -->
<view class="information-item" wx:elif="{{ item.event == 'overduenotice' }}">
<view class="time"><text>{{ item.timestamp }}</text>
<image wx:if="{{ item.isread == 0 }}" mode="widthFix" src="../../img/u20.png"></image>
<image wx:if="{{ item.status == 0 }}" mode="widthFix" src="../../img/u20.png"></image>
</view>
<view code="true" class="information-title">
<view class="information-message" style="display: inline; word-break: break-all;">{{ item.message }}</view>
@ -116,7 +116,7 @@
<!-- 举报等其他数据 -->
<view class="information-item" wx:else>
<view class="time"><text>{{ item.timestamp }}</text>
<image wx:if="{{ item.isread == 0 }}" mode="widthFix" src="../../img/u20.png"></image>
<image wx:if="{{ item.status == 0 }}" mode="widthFix" src="../../img/u20.png"></image>
</view>
<view code="true" class="information-title">
<view class="information-message" style="display: inline; word-break: break-all;">{{ item.message }}</view>

View File

@ -33,7 +33,7 @@
</block>
<!-- 数据长度大于1时需要高度最大值加滚动 -->
<block wx:else>
<swiper class="swiper" autoplay="{{false}}" interval="{{ 200 }}" duration="{{ 500 }}" bindchange="change" style="height: {{ swiperHeight }}px;" circular="{{ true }}" current="{{current}}">
<swiper class="swiper" autoplay="{{false}}" interval="{{ 200 }}" duration="{{ 500 }}" bindanimationfinish="change" style="height: {{ swiperHeight }}px;" circular="{{ true }}" current="{{current}}">
<swiper-item wx:for="{{ targetData }}" wx:key="index">
<view class="text content{{ index }}">
<text wx:if="{{ !item.iswxParse }}" class="content-box">{{ item.message }}</text>

View File

@ -1,5 +1,5 @@
<view class='container newcontainer'>
<swiper class='swiper' current="{{ swiperCurrent }}" style="height: {{ swiperHeightObj[current] }}rpx;" wx:if="{{ attachment.length > 0 }}" autoplay="{{autoplay}}" circular="{{ circular }}" interval="{{interval}}" duration="{{duration}}" bindchange="bindchangeSwiper">
<swiper class='swiper' current="{{ swiperCurrent }}" style="height: {{ swiperHeightObj[current] }}rpx;" wx:if="{{ attachment.length > 0 }}" autoplay="{{autoplay}}" circular="{{ circular }}" interval="{{interval}}" duration="{{duration}}" bindanimationfinish="bindchangeSwiper">
<block wx:for="{{ attachment }}" wx:key="index">
<swiper-item>
<form bindsubmit="send_form_id" report-submit='true' data-types="confirm" class='submit-form' data-type="{{ item.type }}" data-statid="{{ item.statid }}" data-url='{{ item.url }}' data-appid="{{ item.appid }}" data-finderUserName="{{ item.finderUserName }}" data-feedId="{{ item.feedId }}">

View File

@ -2,7 +2,7 @@
var app = getApp()
Component({
options: {
multipleSlots: true
multipleSlots: true,
},
/**
* 组件的属性列表
@ -34,10 +34,12 @@ Component({
statusBarHeight: 0,
titleBarHeight: 0,
},
isTabPage: false
isTabPage: false,
openDate: {}, // 开屏广告数据
},
lifetimes: {
attached: function () {
this.get_config()
this.attachedIn()
},
},
@ -49,6 +51,25 @@ Component({
* 组件的方法列表
*/
methods: {
get_config() {
if (app.globalData.initialState) {
this.handleOpenAd()
} else setTimeout(() => this.get_config(), 10)
},
handleOpenAd() {
const offerkaipingadvertisement = app.globalData.offerkaipingadvertisement
const offerkaipingadvertisementState = app.globalData.offerkaipingadvertisementState
if (!offerkaipingadvertisementState) {
let data = offerkaipingadvertisement || {}
// if (Date.now() < data.deadline * 1000) {
this.setData({
openDate: data
})
// }
}
},
attachedIn() {
if (app.globalData.screen_data.totalTopHeight > 30) {
this.data.screen_data = app.globalData.screen_data;

View File

@ -1,4 +1,6 @@
{
"component": true,
"usingComponents": {}
"usingComponents": {
"open-ad": "/template/open-ad/open-ad"
}
}

View File

@ -50,4 +50,5 @@
<view class="capsule-holder"></view>
</view>
</view>
<open-ad openDate="{{ openDate }}"></open-ad>
</view>

View File

@ -44,7 +44,6 @@
<view class="root-portal" wx:if="{{ academyState }}">
<view class="root-portal-bj" bindtap="negation" data-key="academyState"></view>
<view class="academy-pop">
<!-- 关闭 -->
<image class="pop-close" bindtap="negation" data-key="academyState" src="/img/u1849.svg"></image>
<view class="academy-headline flexcenter">
房源<image class="academy-headline-icon" src="https://app.gter.net/image/miniApp/HKRenting/arrows-green.svg"

View File

@ -0,0 +1,92 @@
// template/open-ad/open-ad.js
const app = getApp()
Component({
/**
* 组件的属性列表
*/
properties: {
openDate: {
type: Object,
observer: function (res) {
console.log("res", res);
if (res && res.image && !this.data.load) {
this.data.load = true
wx.setStorage({
key: "openAdTimer",
data: Date.now()
})
this.downloadImg(res.image)
}
}
}
},
/**
* 组件的初始数据
*/
data: {
num: 5,
state: false,
timer: null,
url: "",
},
/**
* 组件的方法列表
*/
methods: {
downloadImg(url) {
wx.downloadFile({
url,
success: (res) => {
if (res.statusCode === 200) {
this.setData({
url: res.tempFilePath
})
this.startstart()
}
},
complete: () => {
this.data.load = false
}
})
},
startstart() {
app.globalData.offerkaipingadvertisementState = true
this.setData({
state: true,
})
this.data.timer = setInterval(() => {
this.setData({
num: this.data.num - 1
})
if (this.data.num <= 0) {
this.setData({
state: false,
})
clearInterval(this.data.timer)
}
}, 1000)
},
skip() {
let url = this.data.openDate['url']
if (url.indexOf('http') == 0) url = `/pages/webViewwebweb/index?url=${url}`
else url = url
wx.navigateTo({
url
})
},
jumpOver() {
this.setData({
state: false,
})
clearInterval(this.data.timer)
},
}
})

View File

@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

View File

@ -0,0 +1,75 @@
/* template/open-ad/open-ad.wxss */
.pop {
position: fixed;
top: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.8);
width: 100vw;
height: 100vh;
z-index: 9999999;
display: flex;
justify-content: center;
align-items: center;
.btn {
position: absolute;
// top: 180rpx;
// right: 20rpx;
top: 80rpx;
left: 20rpx;
width: 130rpx;
height: 45rpx;
line-height: 45rpx;
background-color: rgba(0, 0, 0, 0.5);
border-radius: 40rpx;
color: #FFFFFF;
font-size: 26rpx;
display: flex;
align-items: center;
.num {
width: 45rpx;
height: 45rpx;
border-radius: 50%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
}
.text {
flex: 1;
text-align: center;
}
}
.img {
width: 80vw;
max-height: 100vh;
border-radius: 20rpx;
}
.skip {
position: fixed;
left: 50%;
transform: translateX(-50%);
bottom: 280rpx;
width: 45vw;
height: 80rpx;
line-height: 80rpx;
border-radius: 40vh;
// background-color: rgba(0, 0, 0, 0.7);
background: #F44336;
display: flex;
align-items: center;
justify-content: center;
color: rgba(255, 255, 255, 0.8);
font-size: 32rpx;
.icon {
width: 24rpx;
height: 24rpx;
margin-left: 15rpx;
}
}
}

View File

@ -0,0 +1,12 @@
<!--template/open-ad/open-ad.wxml-->
<view class="pop" wx:if="{{ state }}">
<view class="btn" bind:tap="jumpOver">
<view class="num">{{ num }}</view>
<view class="text">跳过</view>
</view>
<image class="img" show-menu-by-longpress src="{{ url }}" mode="widthFix"></image>
<view class="skip" wx:if="{{ openDate.url }}" bind:tap="skip">
<view class="text">点击查看详情</view>
<image class="icon" mode="widthFix" src="https://app.gter.net/image/miniApp/offer/right-double-arrow.png"></image>
</view>
</view>

View File

@ -0,0 +1,66 @@
/* template/open-ad/open-ad.wxss */
.pop {
position: fixed;
top: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.8);
width: 100vw;
height: 100vh;
z-index: 9999999;
display: flex;
justify-content: center;
align-items: center;
}
.pop .btn {
position: absolute;
top: 80rpx;
left: 20rpx;
width: 130rpx;
height: 45rpx;
line-height: 45rpx;
background-color: rgba(0, 0, 0, 0.5);
border-radius: 40rpx;
color: #FFFFFF;
font-size: 26rpx;
display: flex;
align-items: center;
}
.pop .btn .num {
width: 45rpx;
height: 45rpx;
border-radius: 50%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
}
.pop .btn .text {
flex: 1;
text-align: center;
}
.pop .img {
width: 80vw;
max-height: 100vh;
border-radius: 20rpx;
}
.pop .skip {
position: fixed;
left: 50%;
transform: translateX(-50%);
bottom: 280rpx;
width: 45vw;
height: 80rpx;
line-height: 80rpx;
border-radius: 40vh;
background: #F44336;
display: flex;
align-items: center;
justify-content: center;
color: rgba(255, 255, 255, 0.8);
font-size: 32rpx;
}
.pop .skip .icon {
width: 24rpx;
height: 24rpx;
margin-left: 15rpx;
}

View File

@ -50,6 +50,7 @@ function sendData(code) {
app.globalData.config = data.config;
app.globalData.notice = data.notice;
app.globalData.title = data.title;
app.globalData.initialState = true;
app.globalData.user = data.user;
app.globalData.status = data.status;
app.globalData.StudentapartmentNew = data.StudentapartmentNew;
@ -69,6 +70,11 @@ function sendData(code) {
};
// count()
app.globalData.offerkaipingadvertisement = data.popup || {}
const openAdTimer = wx.getStorageSync("openAdTimer")
if (openAdTimer && isToday(openAdTimer)) app.globalData.offerkaipingadvertisementState = true
},
fail: function () {
// fail
@ -80,6 +86,13 @@ function sendData(code) {
})
}
function isToday(timestamp) {
const date = new Date(timestamp)
const today = new Date()
return date.getFullYear() === today.getFullYear() && date.getMonth() === today.getMonth() && date.getDate() === today.getDate()
}
// 发送未读消息数请求
function count() {
return new Promise((resolve, reject) => {