2025-05-30 10:04:01 +08:00
|
|
|
|
<script>
|
2026-03-27 10:04:26 +08:00
|
|
|
|
let platform = ""
|
|
|
|
|
|
let SystemVersion = ""
|
2026-03-31 16:04:41 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {}
|
|
|
|
|
|
},
|
|
|
|
|
|
onLaunch: function() {
|
2025-05-30 11:14:38 +08:00
|
|
|
|
let that = this
|
2026-03-31 16:04:41 +08:00
|
|
|
|
// 返回的是apk包信息
|
|
|
|
|
|
// #ifdef APP-PLUS||APP
|
|
|
|
|
|
uni.getSystemInfo({
|
|
|
|
|
|
success(e) {
|
|
|
|
|
|
platform = e.platform
|
|
|
|
|
|
that.$store.commit('changePhoneInfo', {
|
|
|
|
|
|
platform: e.platform
|
|
|
|
|
|
})
|
2026-03-27 10:04:26 +08:00
|
|
|
|
}
|
2026-03-31 16:04:41 +08:00
|
|
|
|
})
|
|
|
|
|
|
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
|
2026-03-27 10:04:26 +08:00
|
|
|
|
that.$store.commit('changePhoneInfo', {
|
2026-03-31 16:04:41 +08:00
|
|
|
|
info: info
|
2025-05-30 11:14:38 +08:00
|
|
|
|
})
|
2026-03-31 16:04:41 +08:00
|
|
|
|
})
|
|
|
|
|
|
// #endif
|
|
|
|
|
|
that.handleoginversion()
|
|
|
|
|
|
console.log('App Launch')
|
2025-05-30 11:14:38 +08:00
|
|
|
|
},
|
2026-03-31 16:04:41 +08:00
|
|
|
|
onShow: function() {
|
|
|
|
|
|
uni.switchTab({
|
|
|
|
|
|
url: "/pages/index/index"
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
onHide: function() {
|
|
|
|
|
|
console.log('App Hide')
|
|
|
|
|
|
// #ifdef APP-PLUS||APP
|
|
|
|
|
|
uni.offNetworkStatusChange(function(res) {
|
|
|
|
|
|
console.log("取消网络监听")
|
2025-05-30 11:14:38 +08:00
|
|
|
|
})
|
2026-03-31 16:04:41 +08:00
|
|
|
|
// #endif
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
// 公共信息
|
|
|
|
|
|
handleoginversion() {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
that.$model.getLoginVersion({}).then(res => {
|
|
|
|
|
|
// let language = res.data.language == "zh" ? 'zh-Hans' : res.data.language
|
|
|
|
|
|
let language = "zh"
|
|
|
|
|
|
uni.setLocale(language)
|
|
|
|
|
|
that.$i18n.locale = language
|
|
|
|
|
|
that.$store.commit('changeLocale', language)
|
|
|
|
|
|
uni.setStorageSync('language', language)
|
|
|
|
|
|
that.$store.dispatch("getHomeConfig") //配置接口信息
|
|
|
|
|
|
if (res.code == 0) {
|
|
|
|
|
|
that.$tools.handleUserList()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
uni.setStorageSync('token', "")
|
|
|
|
|
|
uni.setStorageSync('aan_id', null)
|
|
|
|
|
|
// #ifdef APP-PLUS||APP
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
url: '/body/login/login',
|
|
|
|
|
|
})
|
|
|
|
|
|
}, 500);
|
|
|
|
|
|
// #endif
|
|
|
|
|
|
}
|
|
|
|
|
|
// #ifdef APP-PLUS||APP
|
|
|
|
|
|
that.$store.commit('changePhoneInfo', {
|
|
|
|
|
|
versionUrl: res.data
|
|
|
|
|
|
})
|
|
|
|
|
|
// 比对版本号
|
|
|
|
|
|
let version = that.$tools.compareVersions(SystemVersion, res.data.version)
|
|
|
|
|
|
console.log("是否登录及版本号", res, res.data.version, SystemVersion, version)
|
|
|
|
|
|
if (version == -1) { // 0版本号相通,1,:第一个版本号大于第二个版本号,-1:第一个版本号小于第二个版本号
|
|
|
|
|
|
uni.showModal({
|
|
|
|
|
|
title: '发现新版本',
|
|
|
|
|
|
content: '检查到新版本' + res.data.version + ',是否更新?',
|
|
|
|
|
|
cancelText: that.$t('btnSancellation'),
|
|
|
|
|
|
confirmText: that.$t('btnConfirm'),
|
|
|
|
|
|
success: (modalRes) => {
|
|
|
|
|
|
if (modalRes.confirm) { //确定更新
|
|
|
|
|
|
if (platform === 'android') { //安卓更新
|
|
|
|
|
|
uni.setStorageSync('VERSION', res.data.version)
|
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
|
url: "/body/me/about"
|
|
|
|
|
|
})
|
|
|
|
|
|
} else { //ios跳转
|
|
|
|
|
|
plus.runtime.launchApplication({
|
|
|
|
|
|
action: `itms-apps://itunes.apple.com/cn/app/id6654906497?mt=8`
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
that.$tools.msg("稍后可在'关于我们'内更新程序!")
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2025-05-30 11:14:38 +08:00
|
|
|
|
}
|
2026-03-31 16:04:41 +08:00
|
|
|
|
// #endif
|
|
|
|
|
|
|
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
|
// console.error('Error fetching data:', error);
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
handleTabBarItem() {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
uni.setTabBarItem({
|
|
|
|
|
|
index: 0,
|
|
|
|
|
|
text: that.$t('titleHome')
|
2025-05-30 11:14:38 +08:00
|
|
|
|
})
|
2026-03-31 16:04:41 +08:00
|
|
|
|
uni.setTabBarItem({
|
|
|
|
|
|
index: 1,
|
|
|
|
|
|
text: that.$t('titleCount')
|
2025-05-30 11:14:38 +08:00
|
|
|
|
})
|
2026-03-31 16:04:41 +08:00
|
|
|
|
uni.setTabBarItem({
|
|
|
|
|
|
index: 2,
|
|
|
|
|
|
text: that.$t('titleMe')
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2025-05-30 11:14:38 +08:00
|
|
|
|
}
|
2025-05-30 10:04:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
2025-05-30 11:14:38 +08:00
|
|
|
|
<style lang="scss">
|
2025-05-30 10:04:01 +08:00
|
|
|
|
/*每个页面公共css */
|
2025-05-30 11:14:38 +08:00
|
|
|
|
/* #ifndef APP-NVUE */
|
|
|
|
|
|
@import "/uni.scss";
|
2026-03-23 09:50:49 +08:00
|
|
|
|
@import "/scss/food.scss";
|
2025-05-30 11:14:38 +08:00
|
|
|
|
@import "/scss/common.scss";
|
|
|
|
|
|
@import "/scss/iconfont.css";
|
|
|
|
|
|
@import "/scss/iconfont-weapp-icon.css";
|
|
|
|
|
|
|
|
|
|
|
|
/* #endif*/
|
2026-03-23 09:50:49 +08:00
|
|
|
|
|
|
|
|
|
|
.content {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
background-color: #f7f7f7;
|
|
|
|
|
|
min-height: 100vh;
|
|
|
|
|
|
}
|
2025-05-30 11:14:38 +08:00
|
|
|
|
</style>
|