初始提交
This commit is contained in:
177
App.vue
Normal file
177
App.vue
Normal file
@@ -0,0 +1,177 @@
|
||||
<script>
|
||||
import initApp from '@/common/appInit.js';
|
||||
import openApp from '@/common/openApp.js';
|
||||
import process from './utils/process.js' //UDP处理
|
||||
// import Underlying from './utils/UnderlyingUpdate.js'
|
||||
import { store, mutations } from '@/uni_modules/uni-id-pages/common/store.js'
|
||||
|
||||
// #ifdef H5
|
||||
openApp() //创建在h5端全局悬浮引导用户下载app的功能
|
||||
// #endif
|
||||
import checkIsAgree from '@/pages/uni-agree/utils/uni-agree.js';
|
||||
import { Static } from "vue";
|
||||
|
||||
export default {
|
||||
globalData: {
|
||||
searchText: '',
|
||||
appVersion: {},
|
||||
config: {},
|
||||
$i18n: {},
|
||||
$t: {},
|
||||
},
|
||||
onLaunch: function() {
|
||||
console.log('App Launch')
|
||||
// 定时更新账户状态
|
||||
this.timer = setInterval(() => {
|
||||
//联表查询uni-id-users表的保存的数据
|
||||
db.collection('uni-id-users').where("'_id' == $cloudEnv_uid")
|
||||
.field('mobile,nickname,user_name,email,avatar_file,status')
|
||||
.get().then((res) => {
|
||||
const data = res.result.data[0]
|
||||
console.log(data.status)
|
||||
//如果账号是禁用状态就退出
|
||||
if (1 === data.status) {
|
||||
console.log(data.status)
|
||||
// uni.showToast({
|
||||
// title: '检测到账号异常,请重新登录',
|
||||
// icon: "none",
|
||||
// duration: 10000
|
||||
// });
|
||||
//退出登录
|
||||
mutations.logout()
|
||||
// uni.navigateTo({
|
||||
// url: '/uni_modules/uni-id-pages/pages/login/login-withoutpwd',
|
||||
// })
|
||||
|
||||
} else {
|
||||
console.log("账号正常")
|
||||
}
|
||||
})
|
||||
}, 30 * 1000);
|
||||
|
||||
// //获取缓存中的登录数据
|
||||
// let tokenRes = uni.getStorageSync('token');
|
||||
// let userInfoRes = uni.getStorageSync('userInfo');
|
||||
// if (tokenRes && userInfoRes) { //如果没有token,和userInfo则登录
|
||||
// //通过一个接口测试token是否失效
|
||||
// getDoProcess().then(function(res) {
|
||||
// if (res.code == 401) { //如果 失效 则跳转
|
||||
// uni.navigateTo({
|
||||
// url: '/uni_modules/uni-id-pages/pages/login/login-withpwd',
|
||||
// })
|
||||
// } else { //否则关闭加载动画,进入主界面,这里需要把主界面 放在pages.json中第一个
|
||||
// uni.redirectTo({
|
||||
// url: '/pages/video/video',
|
||||
// });
|
||||
// }
|
||||
// })
|
||||
// } else {
|
||||
// uni.redirectTo({
|
||||
// url: '/pages/video/video',
|
||||
// });
|
||||
// }
|
||||
//获取网络类型
|
||||
uni.getNetworkType({
|
||||
success: function(res) {
|
||||
console.log(res.networkType); //网络类型 wifi、2g、3g、4g、ethernet、unknown、none
|
||||
if (res.networkType === "none") {
|
||||
console.log("当前无网络");
|
||||
uni.showToast({
|
||||
title: '网络异常,请重新启动',
|
||||
icon: "none",
|
||||
duration: 10000
|
||||
});
|
||||
//退出
|
||||
plus.runtime.restart();
|
||||
// uni.reLaunch({
|
||||
// url: '/pages/productlist/productlist'
|
||||
// })
|
||||
|
||||
} else {
|
||||
//有网络
|
||||
console.log("有网络");
|
||||
// uni.showToast({
|
||||
// title: '当前网络类型为' + res.networkType,
|
||||
// icon: "none",
|
||||
// duration: 3000
|
||||
// });
|
||||
}
|
||||
}
|
||||
});
|
||||
//授权程序
|
||||
const db = uniCloud.database();
|
||||
db.collection('config').get().then((res) => {
|
||||
const DownloadData = res.result.data[0]
|
||||
//判断数据库中的RestartApp 的标志为true就 运行程序,
|
||||
if (DownloadData.RestartApp === "true") {
|
||||
//确保只重启一次
|
||||
// db.collection('config').where("ConfigID == 'ConfigID001'").update({
|
||||
// RestartApp:"false",
|
||||
// })
|
||||
// .then((res) => {
|
||||
// console.log(res)
|
||||
// })
|
||||
//重新启动
|
||||
// plus.runtime.restart();
|
||||
} else if (DownloadData.RestartApp === "false") {
|
||||
console.log("退出")
|
||||
//检测到标志量为false就退出程序
|
||||
plus.runtime.quit();
|
||||
} else {}
|
||||
});
|
||||
|
||||
this.globalData.$i18n = this.$i18n
|
||||
this.globalData.$t = str => this.$t(str)
|
||||
initApp();
|
||||
|
||||
//js中初始化函数
|
||||
process.CallbackconnectUDP();
|
||||
// Underlying.ReadUpdateUnderlyingUDP();
|
||||
process.funProcess.TimerStart1000ms();
|
||||
process.funProcess.TimerStart100ms();
|
||||
process.funProcess.TimerStart60s();
|
||||
|
||||
// 监听事件,使用 uni.$emit 触发事件后,对应的 uni.$on 就会监听到事件触发,在回调中去执行相关的逻辑。
|
||||
uni.$on('PageJump', (info) => {
|
||||
console.log(info);
|
||||
//切换到视频播放页面
|
||||
uni.redirectTo({
|
||||
url: '/pages/video/video',
|
||||
});
|
||||
})
|
||||
// //查询自动重启APP标志
|
||||
// // const db = uniCloud.database();
|
||||
// this.timer = setInterval(() => {
|
||||
// db.collection('config').get().then((res) => {
|
||||
// const DownloadData = res.result.data[0]
|
||||
// //从数据库下载的数据
|
||||
// this.RestartApp = DownloadData.RestartApp;
|
||||
// if(this.RestartApp === 'true')
|
||||
// {
|
||||
// console.log(this.RestartApp);
|
||||
// //确保只重启一次
|
||||
// db.collection('config').where("ConfigID == 'ConfigID001'").update({
|
||||
// RestartApp:'false',
|
||||
// })
|
||||
// .then((res) => {
|
||||
// console.log(res)
|
||||
// })
|
||||
// //重新启动
|
||||
// plus.runtime.restart();
|
||||
// }
|
||||
// });
|
||||
// }, 5*60*1000);
|
||||
|
||||
},
|
||||
onShow: function() {
|
||||
console.log('App Show')
|
||||
},
|
||||
onHide: function() {
|
||||
console.log('App Hide')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/*每个页面公共css */
|
||||
</style>
|
||||
Reference in New Issue
Block a user