Commit 5d2d5ef3 authored by 潘永坪's avatar 潘永坪

距离上一次登录时间大于7天重新登录

parent 6b03bbe2
...@@ -6,6 +6,18 @@ ...@@ -6,6 +6,18 @@
//4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全 //4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全
export default { export default {
onLaunch: function(options) {//初始化完成时触发(全局只触发一次 onLaunch: function(options) {//初始化完成时触发(全局只触发一次
let today=this.$commonjs.today()
let oldDate=uni.getStorageSync('oldDate')
//大于7天重新登录
if(oldDate){
let number=this.$commonjs.dateDifference(today,oldDate)
if(number>7){
uni.clearStorageSync()
}
}else{
//用于处理这个功能之前登录过的用户,未保存登录时间
uni.clearStorageSync()
}
let path=options.path let path=options.path
uni.setStorageSync('enterOptions',options) uni.setStorageSync('enterOptions',options)
let token=uni.getStorageSync('token') let token=uni.getStorageSync('token')
......
...@@ -26,6 +26,15 @@ export default{ ...@@ -26,6 +26,15 @@ export default{
var seconds = now.getSeconds()<10?'0'+now.getSeconds():now.getSeconds() var seconds = now.getSeconds()<10?'0'+now.getSeconds():now.getSeconds()
var time = hour+":"+minutes+":"+seconds var time = hour+":"+minutes+":"+seconds
return time return time
},
dateDifference:function(start,end){//结束日期与开始日期相差几天
var strSeparator = "-";
var oDate1= start.split(strSeparator);
var oDate2= end.split(strSeparator);
var strDateS = new Date(oDate1[0], oDate1[1]-1, oDate1[2]);
var strDateE = new Date(oDate2[0], oDate2[1]-1, oDate2[2]);
var iDays = parseInt((strDateE- strDateS) / 1000 / 60 / 60 /24)
return iDays
} }
} }
//调用方法时--this.$commonjs.today() //调用方法时--this.$commonjs.today()
\ No newline at end of file
...@@ -275,6 +275,15 @@ ...@@ -275,6 +275,15 @@
} }
} }
,{
"path" : "pages/scenic/scenicProduct/scenicProduct",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
], ],
"globalStyle": { "globalStyle": {
"navigationBarTextStyle": "white", "navigationBarTextStyle": "white",
......
...@@ -42,17 +42,17 @@ ...@@ -42,17 +42,17 @@
}) })
} }
}else{//小程序页面跳转进入 }else{//小程序页面跳转进入
let channelId=option.channelId let channelId=option.channelId||''
let companyId=option.companyId let companyId=option.companyId||''
let merchantId=option.merchantId let merchantId=option.merchantId||''
let groupId=option.groupId let groupId=option.groupId||''
let groupChannelId=option.groupChannelId let groupChannelId=option.groupChannelId||''
let thirdOpenid=option.thirdOpenid//第三方openid let thirdOpenid=option.thirdOpenid||''//第三方openid
let touristType=option.touristType//游客类型 let touristType=option.touristType||''//游客类型
let pdOpenid=uni.getStorageSync("openid")//胖丁小程序openid,临时用,当公众号授权做好之后可以删除 let pdOpenid=uni.getStorageSync("openid")||''//胖丁小程序openid,临时用,当公众号授权做好之后可以删除
let pdToken=uni.getStorageSync("token") let pdToken=uni.getStorageSync("token")||''
let pdCreateUserId=uni.getStorageSync("createUserId") let pdCreateUserId=uni.getStorageSync("createUserId")||''
let pdUserId=uni.getStorageSync("userId") let pdUserId=uni.getStorageSync("userId")||''
let baseUrl="https://wx.pangdly.com/#/combiChoose?thirdOpenid="+thirdOpenid+"&touristType="+touristType let baseUrl="https://wx.pangdly.com/#/combiChoose?thirdOpenid="+thirdOpenid+"&touristType="+touristType
this.outUrl=baseUrl+"&channelId="+channelId+"&merchantId="+merchantId+"&groupId="+groupId+"&groupChannelId="+groupChannelId+"&companyId="+companyId+"&pdOpenid="+pdOpenid+"&pdToken="+pdToken+"&pdCreateUserId="+pdCreateUserId+"&pdUserId="+pdUserId this.outUrl=baseUrl+"&channelId="+channelId+"&merchantId="+merchantId+"&groupId="+groupId+"&groupChannelId="+groupChannelId+"&companyId="+companyId+"&pdOpenid="+pdOpenid+"&pdToken="+pdToken+"&pdCreateUserId="+pdCreateUserId+"&pdUserId="+pdUserId
......
...@@ -42,18 +42,18 @@ ...@@ -42,18 +42,18 @@
} }
}else{//小程序页面跳转进入 }else{//小程序页面跳转进入
let channelId=option.channelId let channelId=option.channelId||''
let companyId=option.companyId let companyId=option.companyId||''
let merchantId=option.merchantId let merchantId=option.merchantId||''
let groupId=option.groupId let groupId=option.groupId||''
let groupChannelId=option.groupChannelId let groupChannelId=option.groupChannelId||''
let thirdOpenid=option.thirdOpenid//第三方openid let thirdOpenid=option.thirdOpenid||''//第三方openid
let touristType=option.touristType//游客类型 let touristType=option.touristType||''//游客类型
let pageCode=option.pageCode//赠送优惠券接口参数 let pageCode=option.pageCode||''//赠送优惠券接口参数
let pdOpenid=uni.getStorageSync("openid")//胖丁小程序openid,临时用,当公众号授权做好之后可以删除 let pdOpenid=uni.getStorageSync("openid")||''//胖丁小程序openid,临时用,当公众号授权做好之后可以删除
let pdToken=uni.getStorageSync("token") let pdToken=uni.getStorageSync("token")||''
let pdCreateUserId=uni.getStorageSync("createUserId") let pdCreateUserId=uni.getStorageSync("createUserId")||''
let pdUserId=uni.getStorageSync("userId") let pdUserId=uni.getStorageSync("userId")||''
let baseUrl="https://wx.pangdly.com/#/distributionCombiChoose?thirdOpenid="+thirdOpenid+"&touristType="+touristType let baseUrl="https://wx.pangdly.com/#/distributionCombiChoose?thirdOpenid="+thirdOpenid+"&touristType="+touristType
this.outUrl=baseUrl+"&channelId="+channelId+"&merchantId="+merchantId+"&groupId="+groupId+"&groupChannelId="+groupChannelId+"&companyId="+companyId+"&pdOpenid="+pdOpenid+"&pdToken="+pdToken+"&pdCreateUserId="+pdCreateUserId+"&pdUserId="+pdUserId+"&pageCode"+pageCode this.outUrl=baseUrl+"&channelId="+channelId+"&merchantId="+merchantId+"&groupId="+groupId+"&groupChannelId="+groupChannelId+"&companyId="+companyId+"&pdOpenid="+pdOpenid+"&pdToken="+pdToken+"&pdCreateUserId="+pdCreateUserId+"&pdUserId="+pdUserId+"&pageCode"+pageCode
} }
......
...@@ -56,6 +56,9 @@ export default { ...@@ -56,6 +56,9 @@ export default {
uni.redirectTo({ uni.redirectTo({
url: '/' + enterOptions.path + '?' + queryTotal url: '/' + enterOptions.path + '?' + queryTotal
}) })
//保存当前日期
let oldDate=_this.$commonjs.today()
uni.setStorageSync('oldDate', oldDate)
// uni.navigateBack({ // uni.navigateBack({
// delta:1 // delta:1
// }) // })
...@@ -75,7 +78,7 @@ export default { ...@@ -75,7 +78,7 @@ export default {
let timer = setTimeout(() => { let timer = setTimeout(() => {
_this.login() _this.login()
}, 2000) }, 2000)
this.$once('hook:beforeDestroy', () => { _this.$once('hook:beforeDestroy', () => {
clearTimeout(timer) clearTimeout(timer)
}) })
}) })
......
...@@ -163,7 +163,7 @@ export default { ...@@ -163,7 +163,7 @@ export default {
let timer=setTimeout(()=>{ let timer=setTimeout(()=>{
_this.login() _this.login()
},2000) },2000)
this.$once('hook:beforeDestroy', () => { _this.$once('hook:beforeDestroy', () => {
clearTimeout(timer) clearTimeout(timer)
}) })
}) })
......
<template>
<view>
<web-view :src="outUrl"></web-view>
</view>
</template>
<script>
export default {
data() {
return {
enterUrl:'',//进入页面路由
outUrl:'',//跳出页面路由
}
},
onLoad(option) {
//#ifdef MP-WEIXIN
this.enterUrl=option.q
//#endif
//#ifdef MP-ALIPAY
this.enterUrl=uni.getStorageSync('alipayQrCode')
//#endif
if(this.enterUrl){//普通二维码扫码进入
let merchantId=this.getUrlKey('merchantId')
let companyId=this.getUrlKey('companyId')
let pdOpenid=uni.getStorageSync('openid')//胖丁小程序openid,临时用,当公众号授权做好之后可以删除
let pdToken=uni.getStorageSync('token')
let pdCreateUserId=uni.getStorageSync('createUserId')
let pdUserId=uni.getStorageSync('userId')
let baseUrl='https://wx.pangdly.com/#/scenicProduct?pdOpenid='+pdOpenid+'&pdToken='+pdToken+'&pdCreateUserId='+pdCreateUserId+'&pdUserId='+pdUserId
let url='&merchantId='+merchantId+'&companyId='+companyId
this.outUrl=baseUrl+url
}else{//小程序页面跳转进入
let merchantId=option.merchantId||''
let companyId=option.companyId||''
let ifyukuaiCode=option.ifyukuaiCode||''//是否是渝快码跳入,渝快码跳入需要在H5端另外走流程
let pdOpenid=uni.getStorageSync('openid')//胖丁小程序openid,临时用,当公众号授权做好之后可以删除
let pdToken=uni.getStorageSync('token')
let pdCreateUserId=uni.getStorageSync('createUserId')
let pdUserId=uni.getStorageSync('userId')
let baseUrl='https://wx.pangdly.com/#/scenicProduct?pdOpenid='+pdOpenid+'&pdToken='+pdToken+'&pdCreateUserId='+pdCreateUserId+'&pdUserId='+pdUserId
let url='&merchantId='+merchantId+'&companyId='+companyId+'&ifyukuaiCode='+ifyukuaiCode
this.outUrl=baseUrl+url
}
},
methods: {
getUrlKey(name){//---------------------------------------------------------------获取url
return(new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(decodeURIComponent(this.enterUrl)) || [, ''])[1].replace(/\+/g, '%20') || ''
},
}
}
</script>
<style>
</style>
\ No newline at end of file
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