This commit is contained in:
caolc
2023-03-22 09:23:04 +08:00
parent 84613456a7
commit 7247973c63
14 changed files with 475 additions and 197 deletions

View File

@@ -1,15 +1,23 @@
<template>
<view class="page-content">
<image :src="yellowURL+'start.png'" width="" mode="widthFix"></image>
<Advertisement v-if="showAdvertisement" @informNext='goHome' ref='Advertisement'></Advertisement>
</view>
</template>
<script>
import oilSiteApi from '@/api/oil-site.js'
import wxCode from '@/api/wxcode.js'
import Advertisement from '../../components/Advertisement.vue'
export default {
components: {
Advertisement
},
data() {
return {
showAdvertisement: false,
key: '',
option: null,
imgURL: this.global.imgURL + 'start/',
yellowURL: this.global.yellowURL + 'xq-ad/',
menuList: [{
@@ -44,75 +52,96 @@
}
},
onLoad(option) {
console.log(option,'启动页');
console.log(`%c 二维码进入 ${option.scene}`, 'color:red;font-size:50px')
const token = uni.getStorageSync('Authorization')
const openid = uni.getStorageSync('openid')
let key = ''
if (token && openid) {
key = '在线'
} else {
key = '离线'
}
if (key == '在线') {
if (!uni.getStorageSync('filterData')) {
this.getFilterData()
} else if (uni.getStorageSync('filterData')[0].detailList.length < 2) {
this.getFilterData()
}
}
if (option.scene) {
this.Interceptor(option.scene);
}else{
setTimeout(() => {
if (key == '在线') {
uni.switchTab({
url: '/pages/tabbar/home/home',
fail: (err) => {
console.log(err)
}
// url:'/BagStation/orderDetail/orderDetail'
})
} else {
uni.redirectTo({
url: '/BagAuth/pages/login/login'
// url:'/BagAuth/pages/login/oldLogin'
})
}
}, 2000)
}
mounted() {
console.log('mounted')
},
onReady(option) {
const updateManager = uni.getUpdateManager();
updateManager.onCheckForUpdate(function(res) {
// 请求完新版本信息的回调
console.log('请求完新版本信息的回调', res.hasUpdate);
});
updateManager.onUpdateReady(function(res) {
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
if (res.confirm) {
console.log(res.confirm,'res.confirm版本信息')
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate();
}
onLoad(option) {
this.option = option;
this.versionUpdate()
},
onReady(option) {},
methods: {
versionUpdate() {
console.log('versionUpdate')
let that = this
const updateManager = uni.getUpdateManager();
updateManager.onCheckForUpdate(function(res) {
// 请求完新版本信息的回调
console.log('请求完新版本信息的回调', res.hasUpdate);
if (!res.hasUpdate) {
that.initFn(that.option)
}
});
});
updateManager.onUpdateReady(function(res) {
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
if (res.confirm) {
console.log(res.confirm, 'res.confirm版本信息')
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate();
} else {
that.initFn(that.option)
}
},
});
});
updateManager.onUpdateFailed(function(res) {
// 新的版本下载失败
});
},
methods: {
updateManager.onUpdateFailed(function(res) {
console.log('新的版本下载失败')
// 新的版本下载失败
});
},
initFn(option) {
console.log(option, '启动页');
console.log(`%c 二维码进入 ${option.scene}`, 'color:red;font-size:50px')
const token = uni.getStorageSync('Authorization')
const openid = uni.getStorageSync('openid')
this.key = ''
if (token && openid) {
this.key = '在线'
} else {
this.key = '离线'
}
if (this.key == '在线') {
if (!uni.getStorageSync('filterData')) {
this.getFilterData()
} else if (uni.getStorageSync('filterData')[0].detailList.length < 2) {
this.getFilterData()
}
}
if (option.scene) {
this.Interceptor(option.scene);
} else {
setTimeout(() => {
this.showAdvertisement = true
}, 2000)
}
},
goHome(type) {
if(type){
uni.setStorageSync('isJump',{
page:'Financial/pages/estimate/index',
disposable:true
})
}
if (this.key == '在线') {
console.log(type, 'typetypetypetype');
uni.switchTab({
url: `/pages/tabbar/home/home`,
success() {},
fail: (err) => {
console.log(err)
}
})
} else {
uni.redirectTo({
url: '/BagAuth/pages/login/login'
})
}
},
Interceptor(id) {
let taht = this
console.log(`%c 检测到参数拦截器启动`, 'color:red;font-size:50px');
@@ -131,24 +160,27 @@
// }
// })
// })
wxCode.getQrCodeType({
qrCode: id
}).then(res => {
if (res.code == 20000) {
uni.redirectTo({
url: '/AppletCode/pages/index/index?details=' + JSON.stringify({...res.data,qrCode: id}),
fail(e) {
console.log(e,'跳转失败')
}
})
}
})
wxCode.getQrCodeType({
qrCode: id
}).then(res => {
if (res.code == 20000) {
uni.redirectTo({
url: '/AppletCode/pages/index/index?details=' + JSON.stringify({
...res.data,
qrCode: id
}),
fail(e) {
console.log(e, '跳转失败')
}
})
}
})
},
getFilterData() {
console.log('wodefenzhi')
oilSiteApi.getCheckInfo().then(res => {
if (res.code == 20000) {
let channelCodes = []
res.data.channelCodes.map(item => {
channelCodes.push({
@@ -176,7 +208,7 @@
this.menuList[2].detailList = this.menuList[2].detailList.concat(siteBrands)
uni.setStorageSync('filterData', this.menuList)
uni.setStorageSync('productCodeList', res.data.productCodeList)
console.log(res,'%c 这里是启动页调用的菜单列表','font-size:36px;color:red;')
console.log(res, '%c 这里是启动页调用的菜单列表', 'font-size:36px;color:red;')
// this.$refs.slFilter.resetMenuList(this.menuList)
}
})