Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mayi-mp-shop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
程默
mayi-mp-shop
Commits
de742053
Commit
de742053
authored
Apr 11, 2023
by
howie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'弹窗广告组件修复'
parent
a2bc5993
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
51 deletions
+76
-51
static/nativeComponents/PopUp/index.js
+76
-51
No files found.
static/nativeComponents/PopUp/index.js
View file @
de742053
...
...
@@ -23,51 +23,72 @@ Component({
},
ready
()
{
this
.
setData
({
img
:
app
.
DFSImg
(
this
.
data
.
datas
.
componentData
.
imageUrl
,
700
,
null
,
1
)
})
console
.
log
(
this
.
data
.
datas
.
componentData
,
'this.data.datas.componentData.once'
)
// if(!this.data.datas.componentData.once){
// console.log('laizhelile')
// let routes = getCurrentPages()
// let page = routes[routes.length - 1].route
// wx.removeStorageSync(`${app.globalData.shopInfo.shopCode}_popFlag_${page}_${this.data.datas.id}`)
// }
// if (this.getPopFlag() == 'true'){
// this.setData({
// domainShow : false
// })
// }else{
// this.setData({
// domainShow: true
// })
// if (this.data.datas.componentData.columnNum > 0 && this.data.datas.componentData.autoOff){
// this.autoOff()
// }
// }
let
nowTime
=
Date
.
now
()
let
pushTime
=
this
.
data
.
datas
.
componentData
.
pushTime
// 如果没有设置时间范围,按老客户的需求执行(30天后过期),将条件设置为按天推送,间隔时间30天
if
(
pushTime
.
length
==
0
)
{
this
.
data
.
datas
.
componentData
.
pushDay
=
30
this
.
data
.
datas
.
componentData
.
pushFrequency
=
'2'
this
.
data
.
datas
.
componentData
.
isDayOrWeek
=
'0'
this
.
isPush
()
}
// 设置了时间范围,且在时间范围中,根据条件推送
else
if
(
pushTime
.
length
>
0
&&
nowTime
>=
pushTime
[
0
]
&&
nowTime
<=
pushTime
[
1
])
{
this
.
isPush
()
}
else
{
// 不在时间范围中,关闭
this
.
setData
({
domainShow
:
false
})
let
userInfo
=
wx
.
getStorageSync
(
"loginUserInfo"
)
console
.
log
(
"用户信息"
,
userInfo
);
if
(
this
.
data
.
datas
.
componentData
.
pushPeople
==
'1'
)
{
if
(
userInfo
.
tagInfoResponseDTOS
)
{
try
{
userInfo
.
tagInfoResponseDTOS
.
forEach
(
item
=>
{
if
(
this
.
data
.
datas
.
componentData
.
pushDesignee
.
includes
(
item
.
id
))
{
this
.
init
()
throw
Error
()
}
})
}
catch
(
e
)
{
console
.
log
(
e
);
}
}
}
},
/**
* 组件的方法列表
*/
methods
:
{
init
()
{
this
.
setData
({
img
:
app
.
DFSImg
(
this
.
data
.
datas
.
componentData
.
imageUrl
,
700
,
null
,
1
)
})
console
.
log
(
this
.
data
.
datas
.
componentData
,
'this.data.datas.componentData.once'
)
// if(!this.data.datas.componentData.once){
// console.log('laizhelile')
// let routes = getCurrentPages()
// let page = routes[routes.length - 1].route
// wx.removeStorageSync(`${app.globalData.shopInfo.shopCode}_popFlag_${page}_${this.data.datas.id}`)
// }
// if (this.getPopFlag() == 'true'){
// this.setData({
// domainShow : false
// })
// }else{
// this.setData({
// domainShow: true
// })
// if (this.data.datas.componentData.columnNum > 0 && this.data.datas.componentData.autoOff){
// this.autoOff()
// }
// }
let
nowTime
=
Date
.
now
()
let
pushTime
=
this
.
data
.
datas
.
componentData
.
pushTime
// 如果没有设置时间范围,按老客户的需求执行(30天后过期),将条件设置为按天推送,间隔时间30天
if
(
pushTime
.
length
==
0
)
{
// if(this.datas.componentData.once){
// this.datas.componentData.pushFrequency = '0'
// }else {
// // 每次进入推送
// this.datas.componentData.pushFrequency = '1'
// } 暂时不兼容了
this
.
isPush
()
}
// 设置了时间范围,且在时间范围中,根据条件推送
else
if
(
pushTime
.
length
>
0
&&
nowTime
>=
pushTime
[
0
]
&&
nowTime
<=
pushTime
[
1
])
{
this
.
isPush
()
}
else
{
// 不在时间范围中,关闭
this
.
setData
({
domainShow
:
false
})
}
},
// 判断何时定时关闭
autoOff
()
{
if
(
...
...
@@ -82,57 +103,61 @@ Component({
},
// 根据条件判断是否推送
isPush
()
{
let
routes
=
getCurrentPages
()
let
page
=
routes
[
routes
.
length
-
1
].
route
switch
(
this
.
data
.
datas
.
componentData
.
pushFrequency
)
{
case
'0'
:
// 永久一次 推送
let
pushCount
=
wx
.
getStorageSync
(
'onlyPushOnceCount'
);
let
pushCount
=
wx
.
getStorageSync
(
`
${
app
.
globalData
.
shopInfo
.
shopCode
}
_
${
page
}
_
${
this
.
data
.
datas
.
id
}
_onlyPushOnceCount`
);
if
(
pushCount
!=
'pushed'
)
{
wx
.
setStorageSync
(
'onlyPushOnceCount'
,
'pushed'
);
wx
.
setStorageSync
(
`
${
app
.
globalData
.
shopInfo
.
shopCode
}
_
${
page
}
_
${
this
.
data
.
datas
.
id
}
_onlyPushOnceCount`
,
'pushed'
);
this
.
setData
({
domainShow
:
true
})
this
.
autoOff
()
wx
.
removeStorageSync
(
'dayPushTimeInfo'
)
//清除按天推送的缓存,防止切换配置后出错
wx
.
removeStorageSync
(
`
${
app
.
globalData
.
shopInfo
.
shopCode
}
_
${
page
}
_
${
this
.
data
.
datas
.
id
}
_dayPushTimeInfo`
)
//清除按天推送的缓存,防止切换配置后出错
}
else
{
break
;
}
break
;
case
'1'
:
// 每次进入 推送
wx
.
removeStorageSync
(
'dayPushTimeInfo'
)
//清除按天推送的缓存,防止切换配置后出错
wx
.
removeStorageSync
(
'onlyPushOnceCount'
)
//清除永久推送的缓存,防止切换配置后出错
wx
.
removeStorageSync
(
`
${
app
.
globalData
.
shopInfo
.
shopCode
}
_
${
page
}
_
${
this
.
data
.
datas
.
id
}
_dayPushTimeInfo`
)
//清除按天推送的缓存,防止切换配置后出错
wx
.
removeStorageSync
(
`
${
app
.
globalData
.
shopInfo
.
shopCode
}
_
${
page
}
_
${
this
.
data
.
datas
.
id
}
_onlyPushOnceCount`
)
//清除永久推送的缓存,防止切换配置后出错
this
.
setData
({
domainShow
:
true
})
this
.
autoOff
()
break
;
case
'2'
:
// 自定义
if
(
this
.
data
.
datas
.
componentData
.
isDayOrWeek
==
0
)
{
if
(
this
.
data
.
datas
.
componentData
.
isDayOrWeek
==
'0'
)
{
// 按天推送
this
.
timedDayPush
()
wx
.
removeStorageSync
(
'onlyPushOnceCount'
)
//清除永久推送的缓存,防止切换配置后出错
}
else
if
(
this
.
data
.
datas
.
componentData
.
isDayOrWeek
==
1
)
{
wx
.
removeStorageSync
(
`
${
app
.
globalData
.
shopInfo
.
shopCode
}
_
${
page
}
_
${
this
.
data
.
datas
.
id
}
_onlyPushOnceCount`
)
//清除永久推送的缓存,防止切换配置后出错
}
else
if
(
this
.
data
.
datas
.
componentData
.
isDayOrWeek
==
'1'
)
{
// 按周推送
this
.
timedWeekPush
()
wx
.
removeStorageSync
(
'dayPushTimeInfo'
)
//清除按天推送的缓存,防止切换配置后出错
wx
.
removeStorageSync
(
'onlyPushOnceCount'
)
//清除永久推送的缓存,防止切换配置后出错
wx
.
removeStorageSync
(
`
${
app
.
globalData
.
shopInfo
.
shopCode
}
_
${
page
}
_
${
this
.
data
.
datas
.
id
}
_dayPushTimeInfo`
)
//清除按天推送的缓存,防止切换配置后出错
wx
.
removeStorageSync
(
`
${
app
.
globalData
.
shopInfo
.
shopCode
}
_
${
page
}
_
${
this
.
data
.
datas
.
id
}
_onlyPushOnceCount`
)
//清除永久推送的缓存,防止切换配置后出错
}
break
;
}
},
// 自定义定时推送,按天数
timedDayPush
()
{
let
routes
=
getCurrentPages
()
let
page
=
routes
[
routes
.
length
-
1
].
route
// 如果缓存中没有信息,或者缓存中应该弹窗的时间已经过去了,则弹窗,并算出下一次弹窗的时间。
let
nowTime
=
Date
.
now
()
let
pushTimeInfo
=
wx
.
getStorageSync
(
'dayPushTimeInfo'
);
let
pushTimeInfo
=
wx
.
getStorageSync
(
`
${
app
.
globalData
.
shopInfo
.
shopCode
}
_
${
page
}
_
${
this
.
data
.
datas
.
id
}
_dayPushTimeInfo`
);
if
(
!
pushTimeInfo
||
nowTime
>=
pushTimeInfo
)
{
this
.
setData
({
domainShow
:
true
})
this
.
autoOff
()
let
nextPushTime
=
nowTime
+
Number
(
this
.
data
.
datas
.
componentData
.
pushDay
)
*
24
*
60
*
60
*
1000
;
wx
.
setStorageSync
(
'dayPushTimeInfo'
,
JSON
.
stringify
(
nextPushTime
))
wx
.
setStorageSync
(
`
${
app
.
globalData
.
shopInfo
.
shopCode
}
_
${
page
}
_
${
this
.
data
.
datas
.
id
}
_dayPushTimeInfo`
,
JSON
.
stringify
(
nextPushTime
))
}
},
// 自定义定时推送,按周几
timedWeekPush
()
{
// 当天是周几
let
currentDayOfWeek
=
new
Date
().
getDay
()
let
currentDayOfWeek
=
new
Date
().
getDay
()
.
toString
()
// 如果当天在推送的周几中,则推送
if
(
this
.
data
.
datas
.
componentData
.
pushWeek
.
includes
(
currentDayOfWeek
))
{
this
.
setData
({
domainShow
:
true
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment