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
a2bc5993
Commit
a2bc5993
authored
Apr 10, 2023
by
howie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'弹窗广告新增配置项'
parent
82e4f016
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
119 additions
and
41 deletions
+119
-41
static/nativeComponents/PopUp/index.js
+119
-41
No files found.
static/nativeComponents/PopUp/index.js
View file @
a2bc5993
...
@@ -28,32 +28,39 @@ Component({
...
@@ -28,32 +28,39 @@ Component({
img
:
app
.
DFSImg
(
this
.
data
.
datas
.
componentData
.
imageUrl
,
700
,
null
,
1
)
img
:
app
.
DFSImg
(
this
.
data
.
datas
.
componentData
.
imageUrl
,
700
,
null
,
1
)
})
})
console
.
log
(
this
.
data
.
datas
.
componentData
,
'this.data.datas.componentData.once'
)
console
.
log
(
this
.
data
.
datas
.
componentData
,
'this.data.datas.componentData.once'
)
if
(
!
this
.
data
.
datas
.
componentData
.
once
){
// if(!this.data.datas.componentData.once){
console
.
log
(
'laizhelile'
)
// console.log('laizhelile')
let
routes
=
getCurrentPages
()
// let routes = getCurrentPages()
let
page
=
routes
[
routes
.
length
-
1
].
route
// let page = routes[routes.length - 1].route
wx
.
removeStorageSync
(
`
${
app
.
globalData
.
shopInfo
.
shopCode
}
_popFlag_
${
page
}
_
${
this
.
data
.
datas
.
id
}
`
)
// wx.removeStorageSync(`${app.globalData.shopInfo.shopCode}_popFlag_${page}_${this.data.datas.id}`)
}
// }
if
(
this
.
getPopFlag
()
==
'true'
){
// if (this.getPopFlag() == 'true'){
this
.
setData
({
// this.setData({
domainShow
:
false
// domainShow : false
})
// })
}
else
{
// }else{
this
.
setData
({
// this.setData({
domainShow
:
true
// domainShow: true
})
// })
// if (this.data.datas.componentData.columnNum > 0 && this.data.datas.componentData.autoOff){
if
(
this
.
data
.
datas
.
componentData
.
columnNum
>
0
&&
this
.
data
.
datas
.
componentData
.
autoOff
){
// this.autoOff()
clearTimeout
(
this
.
data
.
timeout
);
// }
this
.
data
.
timeout
=
setTimeout
(()
=>
{
// }
this
.
setData
({
let
nowTime
=
Date
.
now
()
domainShow
:
false
let
pushTime
=
this
.
data
.
datas
.
componentData
.
pushTime
})
// 如果没有设置时间范围,按老客户的需求执行(30天后过期),将条件设置为按天推送,间隔时间30天
if
(
this
.
data
.
datas
.
componentData
.
once
){
if
(
pushTime
.
length
==
0
)
{
this
.
setPopFlag
(
'true'
)
this
.
data
.
datas
.
componentData
.
pushDay
=
30
}
this
.
data
.
datas
.
componentData
.
pushFrequency
=
'2'
},
this
.
data
.
datas
.
componentData
.
columnNum
*
1000
)
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
})
}
}
},
},
...
@@ -61,28 +68,99 @@ Component({
...
@@ -61,28 +68,99 @@ Component({
* 组件的方法列表
* 组件的方法列表
*/
*/
methods
:
{
methods
:
{
getPopFlag
()
{
// 判断何时定时关闭
let
routes
=
getCurrentPages
()
autoOff
()
{
let
page
=
routes
[
routes
.
length
-
1
].
route
if
(
return
wx
.
getStorageSync
(
`
${
app
.
globalData
.
shopInfo
.
shopCode
}
_popFlag_
${
page
}
_
${
this
.
data
.
datas
.
id
}
`
)
this
.
data
.
datas
.
componentData
.
columnNum
>
0
&&
this
.
data
.
datas
.
componentData
.
autoOff
)
{
clearTimeout
(
this
.
timeout
);
this
.
data
.
timeout
=
setTimeout
(()
=>
{
this
.
setData
({
domainShow
:
false
})
},
this
.
data
.
datas
.
componentData
.
columnNum
*
1000
);
}
},
},
setPopFlag
(
value
)
{
// 根据条件判断是否推送
app
.
globalData
.
setPopupStorage
=
1
;
isPush
()
{
let
routes
=
getCurrentPages
()
switch
(
this
.
data
.
datas
.
componentData
.
pushFrequency
)
{
let
page
=
routes
[
routes
.
length
-
1
].
route
case
'0'
:
wx
.
setStorageSync
(
`
${
app
.
globalData
.
shopInfo
.
shopCode
}
_popFlag_
${
page
}
_
${
this
.
data
.
datas
.
id
}
`
,
value
)
// 永久一次 推送
let
popUpList
=
wx
.
getStorageSync
(
'popUpList'
)
||
[];
let
pushCount
=
wx
.
getStorageSync
(
'onlyPushOnceCount'
);
popUpList
.
push
(
`
${
app
.
globalData
.
shopInfo
.
shopCode
}
_popFlag_
${
page
}
_
${
this
.
data
.
datas
.
id
}
`
)
if
(
pushCount
!=
'pushed'
)
{
wx
.
setStorageSync
(
'popUpList'
,
popUpList
)
wx
.
setStorageSync
(
'onlyPushOnceCount'
,
'pushed'
);
console
.
log
(
app
.
globalData
)
this
.
setData
({
domainShow
:
true
})
this
.
autoOff
()
wx
.
removeStorageSync
(
'dayPushTimeInfo'
)
//清除按天推送的缓存,防止切换配置后出错
}
else
{
break
;
}
break
;
case
'1'
:
// 每次进入 推送
wx
.
removeStorageSync
(
'dayPushTimeInfo'
)
//清除按天推送的缓存,防止切换配置后出错
wx
.
removeStorageSync
(
'onlyPushOnceCount'
)
//清除永久推送的缓存,防止切换配置后出错
this
.
setData
({
domainShow
:
true
})
this
.
autoOff
()
break
;
case
'2'
:
// 自定义
if
(
this
.
data
.
datas
.
componentData
.
isDayOrWeek
==
0
)
{
// 按天推送
this
.
timedDayPush
()
wx
.
removeStorageSync
(
'onlyPushOnceCount'
)
//清除永久推送的缓存,防止切换配置后出错
}
else
if
(
this
.
data
.
datas
.
componentData
.
isDayOrWeek
==
1
)
{
// 按周推送
this
.
timedWeekPush
()
wx
.
removeStorageSync
(
'dayPushTimeInfo'
)
//清除按天推送的缓存,防止切换配置后出错
wx
.
removeStorageSync
(
'onlyPushOnceCount'
)
//清除永久推送的缓存,防止切换配置后出错
}
break
;
}
},
},
// 自定义定时推送,按天数
timedDayPush
()
{
// 如果缓存中没有信息,或者缓存中应该弹窗的时间已经过去了,则弹窗,并算出下一次弹窗的时间。
let
nowTime
=
Date
.
now
()
let
pushTimeInfo
=
wx
.
getStorageSync
(
'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
))
}
},
// 自定义定时推送,按周几
timedWeekPush
()
{
// 当天是周几
let
currentDayOfWeek
=
new
Date
().
getDay
()
// 如果当天在推送的周几中,则推送
if
(
this
.
data
.
datas
.
componentData
.
pushWeek
.
includes
(
currentDayOfWeek
))
{
this
.
setData
({
domainShow
:
true
})
this
.
autoOff
()
}
},
// getPopFlag() {
// let routes = getCurrentPages()
// let page = routes[routes.length - 1].route
// return wx.getStorageSync(`${app.globalData.shopInfo.shopCode}_popFlag_${page}_${this.data.datas.id}`)
// },
// setPopFlag(value) {
// app.globalData.setPopupStorage = 1;
// let routes = getCurrentPages()
// let page = routes[routes.length - 1].route
// wx.setStorageSync(`${app.globalData.shopInfo.shopCode}_popFlag_${page}_${this.data.datas.id}`, value)
// let popUpList = wx.getStorageSync('popUpList') || [];
// popUpList.push(`${app.globalData.shopInfo.shopCode}_popFlag_${page}_${this.data.datas.id}`)
// wx.setStorageSync('popUpList', popUpList)
// console.log(app.globalData)
// },
backHandle
(
e
){
backHandle
(
e
){
this
.
setData
({
this
.
setData
({
domainShow
:
false
domainShow
:
false
})
})
if
(
this
.
data
.
datas
.
componentData
.
once
){
//
if(this.data.datas.componentData.once){
this
.
setPopFlag
(
"true"
);
//
this.setPopFlag("true");
}
//
}
app
.
trackCpn
(
e
,
this
.
data
.
datas
.
componentName
,
'关闭自动弹窗广告'
)
app
.
trackCpn
(
e
,
this
.
data
.
datas
.
componentName
,
'关闭自动弹窗广告'
)
clearTimeout
(
this
.
data
.
timeout
);
clearTimeout
(
this
.
data
.
timeout
);
},
},
...
...
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