213 lines
5.6 KiB
Vue
213 lines
5.6 KiB
Vue
<script>
|
||
let platform = ""
|
||
export default {
|
||
data() {
|
||
return {
|
||
Status: false
|
||
}
|
||
},
|
||
onLaunch: function() {
|
||
let that = this
|
||
// 返回的是apk包信息
|
||
// #ifdef APP-PLUS
|
||
uni.getSystemInfo({
|
||
success(e) {
|
||
platform = e.platform
|
||
that.$store.commit('changePhoneInfo', {
|
||
platform: e.platform
|
||
})
|
||
console.log("getSystemInfo", e.platform)
|
||
}
|
||
})
|
||
// ios首次安装没有网络
|
||
if (platform === 'ios') {
|
||
uni.onNetworkStatusChange(function(res) {
|
||
if (res.isConnected == true) {
|
||
uni.reLaunch({
|
||
url: '/pageTwo/login/login'
|
||
})
|
||
console.log("有网络连接", res.isConnected)
|
||
}
|
||
});
|
||
}
|
||
that.checkForUpdates()
|
||
// #endif
|
||
that.handleoginversion()
|
||
console.log('App Launch')
|
||
},
|
||
onShow: function() {
|
||
console.log('App Show')
|
||
},
|
||
onHide: function() {
|
||
console.log('App Hide')
|
||
// #ifdef APP-PLUS
|
||
uni.offNetworkStatusChange(function(res) {
|
||
console.log("取消网络监听")
|
||
})
|
||
// #endif
|
||
},
|
||
methods: {
|
||
// 版本信息监测
|
||
checkForUpdates() {
|
||
let that = this
|
||
plus.runtime.getProperty(plus.runtime.appid, function(info) {
|
||
uni.setStorageSync('VERSION', info.version)
|
||
that.$store.commit('changePhoneInfo', {
|
||
info: info
|
||
})
|
||
console.log("当前应用版本号", info)
|
||
that.handleoginversion(info)
|
||
})
|
||
},
|
||
// 版本信息
|
||
handleoginversion(info) {
|
||
let that = this
|
||
that.$model.getloginversion({}).then(res => {
|
||
that.handleCancelUpdate(res.code)
|
||
|
||
// #ifdef APP-PLUS
|
||
let currentVersion = info.version;
|
||
let latestVersion = res.data.version
|
||
that.$store.commit('changePhoneInfo', {
|
||
versionUrl: res.data
|
||
})
|
||
// 比对版本号
|
||
let version = that.$tools.compareVersions(currentVersion, latestVersion)
|
||
if (version == -1) { // 0版本号相通,1,:第一个版本号大于第二个版本号,-1:第一个版本号小于第二个版本号
|
||
uni.showModal({
|
||
title: '发现新版本',
|
||
content: '检查到新版本' + res.data.version + ',是否更新?',
|
||
success: (modalRes) => {
|
||
if (modalRes.confirm) { //确定更新
|
||
if (platform === 'android') { //安卓更新
|
||
uni.setStorageSync('VERSION', res.data.version)
|
||
let showLoading = plus.nativeUI.showWaiting('正在下载')
|
||
const dtask = uni.downloadFile({
|
||
url: res.data.url,
|
||
success: (downloadRes) => {
|
||
if (downloadRes.statusCode === 200) {
|
||
plus.nativeUI.closeWaiting()
|
||
plus.runtime.install(downloadRes
|
||
.tempFilePath, {
|
||
force: true
|
||
},
|
||
function() {
|
||
plus.runtime.restart();
|
||
console.log(
|
||
'install success...'
|
||
);
|
||
},
|
||
function(e) {
|
||
console.error(
|
||
'install fail...');
|
||
});
|
||
}
|
||
},
|
||
fail: () => {
|
||
uni.showToast({
|
||
title: '更新失败',
|
||
icon: 'none'
|
||
});
|
||
}
|
||
});
|
||
dtask.onProgressUpdate((res) => {
|
||
showLoading.setTitle(" 正在下载" + res.progress +
|
||
"% ");
|
||
console.log('下载进度' + res.progress + '%');
|
||
});
|
||
} else { //ios跳转
|
||
plus.runtime.launchApplication({
|
||
action: `itms-apps://itunes.apple.com/cn/app/id6654906497?mt=8`
|
||
})
|
||
}
|
||
} else {
|
||
// that.$tools.msg("稍后可在'关于我们'内更新程序!")
|
||
}
|
||
}
|
||
});
|
||
}
|
||
// #endif
|
||
})
|
||
},
|
||
// 取消更新
|
||
handleCancelUpdate(code) {
|
||
let that = this
|
||
if (code == 0) {
|
||
// that.handleUserList()
|
||
uni.reLaunch({
|
||
url: "/pages/home/home?type=1"
|
||
})
|
||
} else {
|
||
setTimeout(() => {
|
||
uni.reLaunch({
|
||
url: '/pageTwo/login/login'
|
||
})
|
||
}, 500);
|
||
}
|
||
},
|
||
// 成员列表
|
||
handleUserList() {
|
||
let that = this
|
||
that.$model.getUserList({
|
||
type: 2
|
||
}).then(res => {
|
||
console.log("用户列表", res)
|
||
if (res.code != 0) {
|
||
that.$tools.msg(res.msg)
|
||
return
|
||
}
|
||
that.$store.commit('changeFamilay', res.data)
|
||
if (res.data.length) {
|
||
that.$store.dispatch('getUserInfo', {
|
||
aud_id: uni.getStorageSync('userid') ? uni.getStorageSync(
|
||
'userid') : res.data[
|
||
0].id
|
||
})
|
||
that.$store.dispatch("getCardList", {
|
||
aud_id: uni.getStorageSync('userid') ? uni.getStorageSync(
|
||
'userid') : res.data[
|
||
0].id
|
||
})
|
||
that.handleLabelList(res.data[0].id)
|
||
that.handlePublicRecord(res.data[0].id)
|
||
}
|
||
}).catch(err => {})
|
||
},
|
||
// 公共卡片列表
|
||
handleLabelList(id) {
|
||
let that = this
|
||
that.$model.getLabelList({
|
||
aud_id: uni.getStorageSync('userid') ? uni.getStorageSync('userid') : id
|
||
}).then(res => {
|
||
console.log("公共卡片项目", res)
|
||
if (res.code == 0) {
|
||
that.$store.commit('changeLabelList', res.data)
|
||
}
|
||
})
|
||
},
|
||
// 公共手动记录内容
|
||
handlePublicRecord(id) {
|
||
let that = this
|
||
that.$model.getPublicRecord({
|
||
aud_id: uni.getStorageSync('userid') ? uni.getStorageSync('userid') : id
|
||
}).then(res => {
|
||
console.log("公共手动记录", res)
|
||
if (res.code == 0) {
|
||
that.$store.commit('changePublicRecord', res.data)
|
||
}
|
||
})
|
||
},
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss">
|
||
/*每个页面公共css */
|
||
/* #ifndef APP-NVUE */
|
||
@import "/uni.scss";
|
||
@import "/scss/common.scss";
|
||
@import "/scss/iconfont.css";
|
||
@import "/scss/iconfont-weapp-icon.css";
|
||
|
||
/* #endif*/
|
||
</style> |