2024-05-02 15:59:36 +08:00
|
|
|
|
<script>
|
2024-08-30 18:03:10 +08:00
|
|
|
|
let platform = ""
|
2024-05-02 15:59:36 +08:00
|
|
|
|
export default {
|
2024-06-13 18:03:50 +08:00
|
|
|
|
data() {
|
2024-09-12 11:20:52 +08:00
|
|
|
|
return {
|
|
|
|
|
|
Status: false
|
|
|
|
|
|
}
|
2024-06-13 18:03:50 +08:00
|
|
|
|
},
|
2024-05-02 15:59:36 +08:00
|
|
|
|
onLaunch: function() {
|
2024-08-30 18:03:10 +08:00
|
|
|
|
let that = this
|
|
|
|
|
|
// 返回的是apk包信息
|
2024-10-11 10:04:19 +08:00
|
|
|
|
// #ifdef APP-PLUS
|
2024-08-30 18:03:10 +08:00
|
|
|
|
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({
|
2024-10-11 10:04:19 +08:00
|
|
|
|
url: '/pageTwo/login/login'
|
2024-08-30 18:03:10 +08:00
|
|
|
|
})
|
|
|
|
|
|
console.log("有网络连接", res.isConnected)
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
that.checkForUpdates()
|
2024-10-11 10:04:19 +08:00
|
|
|
|
// #endif
|
|
|
|
|
|
that.handleoginversion()
|
2024-06-13 18:03:50 +08:00
|
|
|
|
console.log('App Launch')
|
2024-05-02 15:59:36 +08:00
|
|
|
|
},
|
|
|
|
|
|
onShow: function() {
|
2024-06-13 18:03:50 +08:00
|
|
|
|
console.log('App Show')
|
2024-05-02 15:59:36 +08:00
|
|
|
|
},
|
|
|
|
|
|
onHide: function() {
|
2024-06-13 18:03:50 +08:00
|
|
|
|
console.log('App Hide')
|
2024-10-11 10:04:19 +08:00
|
|
|
|
// #ifdef APP-PLUS
|
2024-08-30 18:03:10 +08:00
|
|
|
|
uni.offNetworkStatusChange(function(res) {
|
|
|
|
|
|
console.log("取消网络监听")
|
|
|
|
|
|
})
|
2024-10-11 10:04:19 +08:00
|
|
|
|
// #endif
|
2024-06-13 18:03:50 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
// 版本信息监测
|
|
|
|
|
|
checkForUpdates() {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
plus.runtime.getProperty(plus.runtime.appid, function(info) {
|
|
|
|
|
|
uni.setStorageSync('VERSION', info.version)
|
2024-07-22 14:13:19 +08:00
|
|
|
|
that.$store.commit('changePhoneInfo', {
|
|
|
|
|
|
info: info
|
|
|
|
|
|
})
|
2024-08-30 18:03:10 +08:00
|
|
|
|
console.log("当前应用版本号", info)
|
|
|
|
|
|
that.handleoginversion(info)
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 版本信息
|
|
|
|
|
|
handleoginversion(info) {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
that.$model.getloginversion({}).then(res => {
|
2024-10-11 10:04:19 +08:00
|
|
|
|
that.handleCancelUpdate(res.code)
|
|
|
|
|
|
|
|
|
|
|
|
// #ifdef APP-PLUS
|
|
|
|
|
|
let currentVersion = info.version;
|
2024-08-30 18:03:10 +08:00
|
|
|
|
let latestVersion = res.data.version
|
|
|
|
|
|
that.$store.commit('changePhoneInfo', {
|
|
|
|
|
|
versionUrl: res.data
|
|
|
|
|
|
})
|
|
|
|
|
|
// 比对版本号
|
2024-09-12 11:20:52 +08:00
|
|
|
|
let version = that.$tools.compareVersions(currentVersion, latestVersion)
|
|
|
|
|
|
if (version == -1) { // 0版本号相通,1,:第一个版本号大于第二个版本号,-1:第一个版本号小于第二个版本号
|
2024-08-30 18:03:10 +08:00
|
|
|
|
uni.showModal({
|
|
|
|
|
|
title: '发现新版本',
|
|
|
|
|
|
content: '检查到新版本' + res.data.version + ',是否更新?',
|
|
|
|
|
|
success: (modalRes) => {
|
2024-09-03 09:52:19 +08:00
|
|
|
|
if (modalRes.confirm) { //确定更新
|
|
|
|
|
|
if (platform === 'android') { //安卓更新
|
2024-08-30 18:03:10 +08:00
|
|
|
|
uni.setStorageSync('VERSION', res.data.version)
|
|
|
|
|
|
let showLoading = plus.nativeUI.showWaiting('正在下载')
|
|
|
|
|
|
const dtask = uni.downloadFile({
|
2024-09-03 09:52:19 +08:00
|
|
|
|
url: res.data.url,
|
2024-08-30 18:03:10 +08:00
|
|
|
|
success: (downloadRes) => {
|
2024-09-03 09:52:19 +08:00
|
|
|
|
if (downloadRes.statusCode === 200) {
|
|
|
|
|
|
plus.nativeUI.closeWaiting()
|
|
|
|
|
|
plus.runtime.install(downloadRes
|
2024-08-30 18:03:10 +08:00
|
|
|
|
.tempFilePath, {
|
2024-09-03 09:52:19 +08:00
|
|
|
|
force: true
|
2024-08-30 18:03:10 +08:00
|
|
|
|
},
|
|
|
|
|
|
function() {
|
2024-09-03 09:52:19 +08:00
|
|
|
|
plus.runtime.restart();
|
2024-08-30 18:03:10 +08:00
|
|
|
|
console.log(
|
|
|
|
|
|
'install success...'
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
function(e) {
|
|
|
|
|
|
console.error(
|
2024-09-03 09:52:19 +08:00
|
|
|
|
'install fail...');
|
2024-08-30 18:03:10 +08:00
|
|
|
|
});
|
2024-08-14 17:39:09 +08:00
|
|
|
|
}
|
2024-08-30 18:03:10 +08:00
|
|
|
|
},
|
|
|
|
|
|
fail: () => {
|
|
|
|
|
|
uni.showToast({
|
2024-09-03 09:52:19 +08:00
|
|
|
|
title: '更新失败',
|
2024-08-30 18:03:10 +08:00
|
|
|
|
icon: 'none'
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
dtask.onProgressUpdate((res) => {
|
2024-09-03 09:52:19 +08:00
|
|
|
|
showLoading.setTitle(" 正在下载" + res.progress +
|
2024-09-12 11:20:52 +08:00
|
|
|
|
"% ");
|
2024-09-03 09:52:19 +08:00
|
|
|
|
console.log('下载进度' + res.progress + '%');
|
2024-08-30 18:03:10 +08:00
|
|
|
|
});
|
2024-09-03 09:52:19 +08:00
|
|
|
|
} else { //ios跳转
|
|
|
|
|
|
plus.runtime.launchApplication({
|
|
|
|
|
|
action: `itms-apps://itunes.apple.com/cn/app/id6654906497?mt=8`
|
2024-08-30 18:03:10 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2024-09-12 11:20:52 +08:00
|
|
|
|
// that.$tools.msg("稍后可在'关于我们'内更新程序!")
|
2024-06-13 18:03:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-30 18:03:10 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-10-11 10:04:19 +08:00
|
|
|
|
// #endif
|
2024-06-13 18:03:50 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
2024-09-03 09:52:19 +08:00
|
|
|
|
// 取消更新
|
|
|
|
|
|
handleCancelUpdate(code) {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
if (code == 0) {
|
2024-10-11 10:04:19 +08:00
|
|
|
|
// that.handleUserList()
|
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
url: "/pages/home/home?type=1"
|
|
|
|
|
|
})
|
2024-09-03 09:52:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
uni.reLaunch({
|
2024-10-11 10:04:19 +08:00
|
|
|
|
url: '/pageTwo/login/login'
|
2024-09-03 09:52:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
}, 500);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2024-06-13 18:03:50 +08:00
|
|
|
|
// 成员列表
|
|
|
|
|
|
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', {
|
2024-10-11 10:04:19 +08:00
|
|
|
|
aud_id: uni.getStorageSync('userid') ? uni.getStorageSync(
|
|
|
|
|
|
'userid') : res.data[
|
2024-06-13 18:03:50 +08:00
|
|
|
|
0].id
|
|
|
|
|
|
})
|
|
|
|
|
|
that.$store.dispatch("getCardList", {
|
2024-10-11 10:04:19 +08:00
|
|
|
|
aud_id: uni.getStorageSync('userid') ? uni.getStorageSync(
|
|
|
|
|
|
'userid') : res.data[
|
2024-06-13 18:03:50 +08:00
|
|
|
|
0].id
|
|
|
|
|
|
})
|
2024-10-11 10:04:19 +08:00
|
|
|
|
that.handleLabelList(res.data[0].id)
|
2024-09-26 09:18:27 +08:00
|
|
|
|
that.handlePublicRecord(res.data[0].id)
|
2024-06-13 18:03:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
}).catch(err => {})
|
|
|
|
|
|
},
|
2024-09-26 09:18:27 +08:00
|
|
|
|
// 公共卡片列表
|
|
|
|
|
|
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)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2024-05-02 15:59:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
|
/*每个页面公共css */
|
2024-05-29 16:35:45 +08:00
|
|
|
|
/* #ifndef APP-NVUE */
|
|
|
|
|
|
@import "/uni.scss";
|
2024-08-22 09:48:00 +08:00
|
|
|
|
@import "/scss/common.scss";
|
|
|
|
|
|
@import "/scss/iconfont.css";
|
|
|
|
|
|
@import "/scss/iconfont-weapp-icon.css";
|
2024-05-02 15:59:36 +08:00
|
|
|
|
|
2024-05-29 16:35:45 +08:00
|
|
|
|
/* #endif*/
|
2024-05-02 15:59:36 +08:00
|
|
|
|
</style>
|