1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <template>
- <view>
- <web-view :src="href"></web-view>
- </view>
- </template>
- <script>
- import "@/common/time.js"
- // 返回指定日期距今多少天
- const daysComputed = time => {
- let oldTimeFormat = new Date(time)
- let nowDate = new Date()
- if (nowDate.getTime() - oldTimeFormat.getTime() > 0) {
- let times = nowDate.getTime() - oldTimeFormat.getTime()
- let days = parseInt(times / (60 * 60 * 24 * 1000))
- return days
- } else {
- throw ('传入时间不能大于当前日期')
- }
- }
- // console.log(daysComputed('2022-02-26'))
- export default {
- data() {
- return {
- url: "",
- href: ""
- };
- },
- onLoad() {
- // #ifndef APP-NVUE
- const eventChannel = this.getOpenerEventChannel();
- // #endif
- // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
- eventChannel.on('acceptDataFromOpenerPage', (data) => {
- console.log(data)
- this.url = escape(data.url)
- })
- if (!uni.getStorageSync("oa_login_time")) {
- // 第一次登录
- console.log("第一次登陆")
- let oa_login_time = "2010-01-01"
- uni.setStorageSync("oa_login_time", new Date().format("yyyy-MM-dd"))
- this.href = "http://oa_system.nxjiewei.com:8011/oa_login.html?staff_num=" + uni.getStorageSync('user')
- .staff_num + "&url=" + this.url + "&oa_login_time=" + oa_login_time
- } else {
- // 有登录记录
- console.log("有登录记录")
- let oa_login_time = uni.getStorageSync("oa_login_time")
- if (daysComputed(oa_login_time) > 5) {
- uni.setStorageSync("oa_login_time", new Date().format("yyyy-MM-dd"))
-
- console.log(">5",uni.getStorageSync("oa_login_time"))
- this.href = "http://oa_system.nxjiewei.com:8011/oa_login.html?staff_num=" + uni.getStorageSync('user')
- .staff_num + "&url=" + this.url + "&oa_login_time=" + uni.getStorageSync("oa_login_time")
- } else {
- console.log("<5",oa_login_time)
-
- this.href = "http://oa_system.nxjiewei.com:8011/oa_login.html?staff_num=" + uni.getStorageSync('user')
- .staff_num + "&url=" + this.url + "&oa_login_time=" + oa_login_time
- }
- }
- }
- }
- </script>
- <style lang="scss">
- </style>
|