93 lines
2.3 KiB
Vue
93 lines
2.3 KiB
Vue
![]() |
<script>
|
||
|
import baseUrl from '@/config/config';
|
||
|
import { onLaunch } from '@dcloudio/uni-app'
|
||
|
import { debugWarn } from '@tuniao/tnui-vue3-uniapp/utils'
|
||
|
import storage from '@/utils/storage'
|
||
|
export default {
|
||
|
onLaunch: function() {
|
||
|
console.log('App Launch')
|
||
|
uni.loadFontFace({
|
||
|
family: 'handsome',
|
||
|
source:'url("https://static1.cqtlcm.com/attachment/kxc-xcx/handsome.ttf")',
|
||
|
global:true,
|
||
|
fail: (err) => {
|
||
|
debugWarn('load-font', `加载字体失败: ${err}`)
|
||
|
console.error(err)
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
onShow: function() {
|
||
|
let storageUser = storage.get('storageUser')
|
||
|
let isLogin = storage.get('isLogin')
|
||
|
if (storageUser && isLogin && storageUser.id) {
|
||
|
uni.request({
|
||
|
url:baseUrl + '/front/user/' + storageUser.id,
|
||
|
method:'GET',
|
||
|
success:(res)=>{
|
||
|
if(res.data.code === 0){
|
||
|
storage.set('storageUser',res.data.data)
|
||
|
}else{
|
||
|
uni.showToast({
|
||
|
icon:'none',
|
||
|
title:res.data.message
|
||
|
}).then(()=>{
|
||
|
storage.remove('storageUser')
|
||
|
storage.remove('isLogin')
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
//更新
|
||
|
// #ifdef MP
|
||
|
let updateManager = uni.getUpdateManager();
|
||
|
if(!updateManager){
|
||
|
return;
|
||
|
}else{
|
||
|
if(uni.canIUse('getUpdateManager')){
|
||
|
updateManager.onCheckForUpdate((res)=>{
|
||
|
if(res.hasUpdate){
|
||
|
updateManager.onUpdateReady(()=>{
|
||
|
uni.showModal({
|
||
|
title:'更新提升',
|
||
|
content:'新版本已经准备好,是否重启应用?',
|
||
|
success: (res) => {
|
||
|
if(res.confirm){
|
||
|
updateManager.applyUpdate();
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
});
|
||
|
updateManager.onUpdateFailed(()=>{
|
||
|
uni.showModal({
|
||
|
title:'已经有新版本了',
|
||
|
content:'新版本已经上线了,请删除当前小程序,到微信“发现-小程序”页,重新搜索打开'
|
||
|
})
|
||
|
})
|
||
|
}else{
|
||
|
|
||
|
}
|
||
|
})
|
||
|
}else{
|
||
|
uni.showModal({
|
||
|
title:"温馨提示",
|
||
|
content:"当前微信版本过低,部分功能无法使用,请升级到最新微信版本后重试。"
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
// #endif
|
||
|
},
|
||
|
onHide: function() {
|
||
|
console.log('App Hide')
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style>
|
||
|
/*每个页面公共css */
|
||
|
@import '@/uni_modules/tuniaoui-vue3/index.css';
|
||
|
page{
|
||
|
background-color: #ffffff;
|
||
|
}
|
||
|
</style>
|