kitchendDevice/App.vue

117 lines
2.7 KiB
Vue

<script>
let platform = ""
let SystemVersion = ""
export default {
onLaunch: function() {
let that = this
// #ifdef APP-PLUS
uni.getSystemInfo({
success(e) {
platform = e.platform
that.$store.commit('changePhoneInfo', {
platform: e.platform
})
}
})
if (platform === 'ios') { // ios首次安装没有网络
uni.onNetworkStatusChange(function(res) {
if (res.isConnected == true) {
that.handleoginversion()
}
});
}
plus.runtime.getProperty(plus.runtime.appid, function(info) {
uni.setStorageSync('VERSION', info.version)
SystemVersion = info.version
that.$store.commit('changePhoneInfo', {
info: info
})
})
// #endif
that.handleoginversion()
// that.$store.dispatch("getHomeConfig")
},
onHide: function() {
// #ifdef APP-PLUS
uni.offNetworkStatusChange(function(res) {
console.log("取消网络监听")
})
// #endif
},
onShow: function() {
let that = this
that.handleTabBarItem()
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
},
methods: {
// 版本信息
handleoginversion() {
let that = this
that.$model.getloginversion({}).then(res => {
let language = res.data.language == "zh" ? 'zh-Hans' : res.data.language
console.log("res.data", res.data.language, language, res)
uni.setLocale(language)
that.$i18n.locale = language
that.$store.commit('changeLocale', res.data.language)
uni.setStorageSync('language', res.data.language)
that.$store.dispatch("getHomeConfig")
if (res.code == 0) {
that.$store.dispatch("getUserInfo")
} else {
uni.setStorageSync('token', null)
uni.setStorageSync('aan_id', null)
setTimeout(() => {
uni.reLaunch({
url: '/pageTwo/login/login',
})
}, 500);
}
// #ifdef APP-PLUS||APP
that.$store.commit('changePhoneInfo', {
versionUrl: res.data
})
// 比对版本号
that.$tools.compareVersions(SystemVersion, res.data.version)
// #endif
})
},
handleTabBarItem() {
let that = this
uni.setTabBarItem({
index: 0,
text: that.$t('titleHome')
})
uni.setTabBarItem({
index: 1,
text: that.$t('titleCount')
})
uni.setTabBarItem({
index: 2,
text: that.$t('titleMe')
})
}
}
}
</script>
<style lang="scss">
/*每个页面公共css */
/* #ifndef APP-NVUE */
@import "/assets/common.scss";
@import "/assets/iconfont.css";
@import "/assets/iconfont-weapp-icon.css";
/* #endif*/
/*每个页面公共css */
.content {
display: flex;
flex-direction: column;
align-items: center;
/* justify-content: center; */
background-color: #f7f7f7;
min-height: 100vh;
}
</style>