111
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

215 lines
5.8 KiB

<script>
import Vue from 'vue'
import accountApi from '@/api/account.js'
import oilSiteApi from '@/api/oil-site.js'
import wxCode from '@/api/wxcode.js'
import tools from '@/utils/tools.js'
let loginTimer = null
let onlineTimer = null
export default {
data() {
return {
loginStatus: 'online',
msg: ''
}
},
onLaunch(option) {
uni.getSystemInfo({
success: function(e) {
// #ifndef MP
Vue.prototype.StatusBar = e.statusBarHeight;
if (e.platform == 'android') {
Vue.prototype.CustomBar = e.statusBarHeight + 50;
} else {
Vue.prototype.CustomBar = e.statusBarHeight + 45;
};
// #endif
// #ifdef MP-WEIXIN
Vue.prototype.StatusBar = e.statusBarHeight;
let custom = wx.getMenuButtonBoundingClientRect();
Vue.prototype.Custom = custom;
Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
// #endif // #ifdef MP-ALIPAY
Vue.prototype.StatusBar = e.statusBarHeight;
Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
// #endif
}
})
this.onShareAppMessage(option.query.scene);
},
onLoad(e) {
console.log(e,'666666666666666666666666666666')
},
methods: {
getFilterData() {
oilSiteApi.getCheckInfo().then(res => {
if (res.code == 20000) {
let channelCodes = []
res.data.channelCodes.map(item => {
channelCodes.push({
title: item.name,
value: item.id
})
})
let productCodes = []
res.data.productCodes.map(item => {
productCodes.push({
title: item.name,
value: item.id
})
})
let siteBrands = []
res.data.siteBrands.map(item => {
siteBrands.push({
title: item.name,
value: item.id
})
})
console.log(channelCodes, productCodes, siteBrands)
this.menuList[0].detailList = this.menuList[0].detailList.concat(channelCodes)
this.menuList[1].detailList = this.menuList[1].detailList.concat(productCodes)
this.menuList[2].detailList = this.menuList[2].detailList.concat(siteBrands)
uni.setStorageSync('filterData', this.menuList)
// this.$refs.slFilter.resetMenuList(this.menuList)
}
})
},
onShareAppMessage(e) {
let that = this
wx.onAppRoute((res) => {
console.log(res, '当前页面路由发生变化 触发该事件onShareAppMessage');
const pages = getCurrentPages() //获取加载的页面
const view = pages[pages.length - 1] //获取当前页面的对象
if (!view) return false //如果不存在页面对象 则返回
// 若想给个别页面做特殊处理 可以给特殊页面加isOverShare为true 就不会重写了
// const data = view.data
// if (!data.isOverShare) {
// data.isOverShare = true
view.onShareAppMessage = () => { //重写分享配置
return {
title: '一路油你,星油能源',
path: "/pages/index/startPage/startPage", //若无path 默认跳转分享页
// imageUrl:'/image/onshowMessage.png' //若无imageUrl 截图当前页面
imageUrl: 'https://xoi-support.oss-cn-hangzhou.aliyuncs.com/星油admin小程序/xxxxx.png',
}
}
if (view.route != 'pages/index/startPage/startPage' && view.route.indexOf('BagAuth') == -1) {
const token = uni.getStorageSync('Authorization')
const openid = uni.getStorageSync('openid')
if (token && openid) {
this.getAmount()
onlineTimer = setTimeout(() => {
if (this.loginStatus == 'offline') {
uni.clearStorageSync()
uni.showModal({
title: '需要您重新登录',
content: this.msg,
duration: '3000',
success: function(res) {
if (res.confirm) {
uni.redirectTo({
url: '/BagAuth/pages/login/login'
})
}
},
complete: () => {
clearTimeout(onlineTimer)
}
})
}
}, 1000)
} else {
// loginTimer = setTimeout(() => {
// uni.showModal({
// title: '请您登录',
// content: '您还没有登录,暂时查不到油站哦',
// duration: '3000',
// success: function(res) {
// if (res.confirm) {
// uni.redirectTo({
// url: '/BagAuth/pages/login/login'
// })
// }
// }
// })
// }, 1000)
}
}
// }
})
},
// 是否token过期或ip更改
getAmount() {
clearTimeout(loginTimer)
accountApi.getTotalOilCardInfo().then(res => {
if (res.code == 20000) {
this.loginStatus = 'online'
} else if (res.code == 42011) {
this.loginStatus = 'offline'
this.msg = res.msg
}
})
},
},
onReady() {
},
onShow: function(option) {
const token = uni.getStorageSync('Authorization')
const openid = uni.getStorageSync('openid')
let key = ''
if (token && openid) {
this.getAmount()
key = '真在线'
} else {
key = '离线'
}
if (key == '在线') {
}
setTimeout(() => {
console.log(key)
if (key == '在线') {
} else {
// uni.redirectTo({
// url: '/BagAuth/pages/login/login'
// })
}
}, 2000)
// uni.showShareMenu()
// console.log('App Show')
uni.getLocation({
type: 'wgs84',
success: function(res) {
uni.setStorageSync('location', {
longitude: res.longitude + '',
latitude: res.latitude + ''
})
}
});
},
onHide: function() {
// console.log('App Hide')
}
}
</script>
<style lang="scss">
</style>
<style>
/*每个页面公共css */
@import '@/static/icon/iconfont.css';
@import "colorui/main.css";
@import "colorui/icon.css";
@import "colorui/animation.css";
@import "common/common.css";
</style>