Commit de742053 by howie

'弹窗广告组件修复'

parent a2bc5993
...@@ -23,7 +23,30 @@ Component({ ...@@ -23,7 +23,30 @@ Component({
}, },
ready() { ready() {
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({ this.setData({
img: app.DFSImg(this.data.datas.componentData.imageUrl,700,null,1) img: app.DFSImg(this.data.datas.componentData.imageUrl,700,null,1)
}) })
...@@ -50,9 +73,12 @@ Component({ ...@@ -50,9 +73,12 @@ Component({
let pushTime = this.data.datas.componentData.pushTime let pushTime = this.data.datas.componentData.pushTime
// 如果没有设置时间范围,按老客户的需求执行(30天后过期),将条件设置为按天推送,间隔时间30天 // 如果没有设置时间范围,按老客户的需求执行(30天后过期),将条件设置为按天推送,间隔时间30天
if(pushTime.length == 0) { if(pushTime.length == 0) {
this.data.datas.componentData.pushDay = 30 // if(this.datas.componentData.once){
this.data.datas.componentData.pushFrequency = '2' // this.datas.componentData.pushFrequency = '0'
this.data.datas.componentData.isDayOrWeek = '0' // }else {
// // 每次进入推送
// this.datas.componentData.pushFrequency = '1'
// } 暂时不兼容了
this.isPush() this.isPush()
} }
// 设置了时间范围,且在时间范围中,根据条件推送 // 设置了时间范围,且在时间范围中,根据条件推送
...@@ -63,11 +89,6 @@ Component({ ...@@ -63,11 +89,6 @@ Component({
this.setData({ domainShow: false }) this.setData({ domainShow: false })
} }
}, },
/**
* 组件的方法列表
*/
methods: {
// 判断何时定时关闭 // 判断何时定时关闭
autoOff() { autoOff() {
if ( if (
...@@ -82,57 +103,61 @@ Component({ ...@@ -82,57 +103,61 @@ Component({
}, },
// 根据条件判断是否推送 // 根据条件判断是否推送
isPush() { isPush() {
let routes = getCurrentPages()
let page = routes[routes.length - 1].route
switch(this.data.datas.componentData.pushFrequency) { switch(this.data.datas.componentData.pushFrequency) {
case '0': case '0':
// 永久一次 推送 // 永久一次 推送
let pushCount = wx.getStorageSync('onlyPushOnceCount'); let pushCount = wx.getStorageSync(`${app.globalData.shopInfo.shopCode}_${page}_${this.data.datas.id}_onlyPushOnceCount`);
if(pushCount !='pushed') { 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.setData({ domainShow: true })
this.autoOff() this.autoOff()
wx.removeStorageSync('dayPushTimeInfo') //清除按天推送的缓存,防止切换配置后出错 wx.removeStorageSync(`${app.globalData.shopInfo.shopCode}_${page}_${this.data.datas.id}_dayPushTimeInfo`) //清除按天推送的缓存,防止切换配置后出错
}else { }else {
break; break;
} }
break; break;
case '1': case '1':
// 每次进入 推送 // 每次进入 推送
wx.removeStorageSync('dayPushTimeInfo') //清除按天推送的缓存,防止切换配置后出错 wx.removeStorageSync(`${app.globalData.shopInfo.shopCode}_${page}_${this.data.datas.id}_dayPushTimeInfo`) //清除按天推送的缓存,防止切换配置后出错
wx.removeStorageSync('onlyPushOnceCount') //清除永久推送的缓存,防止切换配置后出错 wx.removeStorageSync(`${app.globalData.shopInfo.shopCode}_${page}_${this.data.datas.id}_onlyPushOnceCount`) //清除永久推送的缓存,防止切换配置后出错
this.setData({ domainShow: true }) this.setData({ domainShow: true })
this.autoOff() this.autoOff()
break; break;
case '2': case '2':
// 自定义 // 自定义
if(this.data.datas.componentData.isDayOrWeek == 0) { if(this.data.datas.componentData.isDayOrWeek == '0') {
// 按天推送 // 按天推送
this.timedDayPush() this.timedDayPush()
wx.removeStorageSync('onlyPushOnceCount') //清除永久推送的缓存,防止切换配置后出错 wx.removeStorageSync(`${app.globalData.shopInfo.shopCode}_${page}_${this.data.datas.id}_onlyPushOnceCount`) //清除永久推送的缓存,防止切换配置后出错
}else if(this.data.datas.componentData.isDayOrWeek == 1) { }else if(this.data.datas.componentData.isDayOrWeek == '1') {
// 按周推送 // 按周推送
this.timedWeekPush() this.timedWeekPush()
wx.removeStorageSync('dayPushTimeInfo') //清除按天推送的缓存,防止切换配置后出错 wx.removeStorageSync(`${app.globalData.shopInfo.shopCode}_${page}_${this.data.datas.id}_dayPushTimeInfo`) //清除按天推送的缓存,防止切换配置后出错
wx.removeStorageSync('onlyPushOnceCount') //清除永久推送的缓存,防止切换配置后出错 wx.removeStorageSync(`${app.globalData.shopInfo.shopCode}_${page}_${this.data.datas.id}_onlyPushOnceCount`) //清除永久推送的缓存,防止切换配置后出错
} }
break; break;
} }
}, },
// 自定义定时推送,按天数 // 自定义定时推送,按天数
timedDayPush() { timedDayPush() {
let routes = getCurrentPages()
let page = routes[routes.length - 1].route
// 如果缓存中没有信息,或者缓存中应该弹窗的时间已经过去了,则弹窗,并算出下一次弹窗的时间。 // 如果缓存中没有信息,或者缓存中应该弹窗的时间已经过去了,则弹窗,并算出下一次弹窗的时间。
let nowTime = Date.now() 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) { if(!pushTimeInfo || nowTime >= pushTimeInfo) {
this.setData({ domainShow: true }) this.setData({ domainShow: true })
this.autoOff() this.autoOff()
let nextPushTime = nowTime + Number(this.data.datas.componentData.pushDay) * 24 * 60 * 60 * 1000; 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() { timedWeekPush() {
// 当天是周几 // 当天是周几
let currentDayOfWeek = new Date().getDay() let currentDayOfWeek = new Date().getDay().toString()
// 如果当天在推送的周几中,则推送 // 如果当天在推送的周几中,则推送
if(this.data.datas.componentData.pushWeek.includes(currentDayOfWeek)) { if(this.data.datas.componentData.pushWeek.includes(currentDayOfWeek)) {
this.setData({ domainShow: true }) this.setData({ domainShow: true })
......
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