144 lines
4.4 KiB
Vue
144 lines
4.4 KiB
Vue
|
|
<template>
|
|||
|
|
<view></view>
|
|||
|
|
</template>
|
|||
|
|
<script>
|
|||
|
|
import {
|
|||
|
|
info,
|
|||
|
|
personalData,
|
|||
|
|
leadInfo,
|
|||
|
|
servInfo,
|
|||
|
|
} from "@/api/all.js"
|
|||
|
|
export default {
|
|||
|
|
onLaunch() {
|
|||
|
|
// 获取小程序更新机制兼容
|
|||
|
|
if (uni.canIUse('getUpdateManager')) {
|
|||
|
|
const updateManager = uni.getUpdateManager()
|
|||
|
|
// 检查是否有新版本发布
|
|||
|
|
updateManager.onCheckForUpdate(function(res) {
|
|||
|
|
if (res.hasUpdate) {
|
|||
|
|
//小程序有新版本,则静默下载新版本,做好更新准备
|
|||
|
|
updateManager.onUpdateReady(function() {
|
|||
|
|
uni.showModal({
|
|||
|
|
title: '更新提示',
|
|||
|
|
content: '新版本已经准备好,是否重启应用?',
|
|||
|
|
success: function(res) {
|
|||
|
|
if (res.confirm) {
|
|||
|
|
//新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|||
|
|
updateManager.applyUpdate()
|
|||
|
|
} else if (res.cancel) {
|
|||
|
|
//如果需要强制更新,则给出二次弹窗,如果不需要,则这里的代码都可以删掉了
|
|||
|
|
uni.showModal({
|
|||
|
|
title: '温馨提示',
|
|||
|
|
content: '我们已经做了新的优化,请及时更新哦~',
|
|||
|
|
showCancel: false, //隐藏取消按钮,也可显示,取消会走res.cancel,然后从新开始提示
|
|||
|
|
success: function(res) {
|
|||
|
|
//第二次提示后,强制更新
|
|||
|
|
if (res.confirm) {
|
|||
|
|
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|||
|
|
updateManager.applyUpdate()
|
|||
|
|
uni.clearStorageSync()
|
|||
|
|
} else if (res.cancel) {
|
|||
|
|
//重新回到版本更新提示
|
|||
|
|
autoUpdate()
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
})
|
|||
|
|
// 新的版本下载失败
|
|||
|
|
updateManager.onUpdateFailed(function() {
|
|||
|
|
uni.showModal({
|
|||
|
|
title: '温馨提示',
|
|||
|
|
content: '新版本已经上线,请您删除当前小程序,重新搜索打开',
|
|||
|
|
})
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
} else {
|
|||
|
|
// 提示用户在最新版本的客户端上体验
|
|||
|
|
uni.showModal({
|
|||
|
|
title: '温馨提示',
|
|||
|
|
content: '当前微信版本过低,可能无法使用该功能,请升级到最新版本后重试。'
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
created() {
|
|||
|
|
if (uni.getStorageSync('token')) {
|
|||
|
|
this.getInfo()
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
onShow: function() {},
|
|||
|
|
onHide: function() {
|
|||
|
|
// this.$store.dispatch('closeWebSocket')
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
async getInfo() {
|
|||
|
|
let role = uni.getStorageSync('identity')
|
|||
|
|
let req = {};
|
|||
|
|
const data = {
|
|||
|
|
store_id: uni.getStorageSync('store_id') || '11001',
|
|||
|
|
}
|
|||
|
|
role == 1 && (req = await info(data))
|
|||
|
|
role == 2 && (req = await personalData(data))
|
|||
|
|
if (req.errcode == 0) {
|
|||
|
|
console.log(req, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
|
|||
|
|
// 未完善信息
|
|||
|
|
if (req.data.user.status == 3) {
|
|||
|
|
// this.$toast('您还没有完善信息,请先完善信息')
|
|||
|
|
// this.$go('../../subPackages/sub_workbench/workbench_upInfo/index')
|
|||
|
|
uni.navigateTo({
|
|||
|
|
url: '/pages/workbench/examine'
|
|||
|
|
})
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (role == 2 && req.data.user.status == 2) {
|
|||
|
|
let logInfo = uni.getStorageSync('logInfo') || {}
|
|||
|
|
let userInfo = {
|
|||
|
|
...logInfo,
|
|||
|
|
...(uni.getStorageSync('userInfo') || {}),
|
|||
|
|
...req.data
|
|||
|
|
}
|
|||
|
|
userInfo.status = userInfo.user && userInfo.user.status != '' ? userInfo.user.status : userInfo
|
|||
|
|
.status
|
|||
|
|
|
|||
|
|
uni.setStorageSync('identity', userInfo['role'])
|
|||
|
|
uni.removeStorageSync('logInfo')
|
|||
|
|
uni.setStorageSync('userInfo', userInfo)
|
|||
|
|
setTimeout(() => {
|
|||
|
|
console.log('mainnnnnnnnnnnnnnnnnnnnnnnn');
|
|||
|
|
role == 2 && this.$go('/pages/pharmacist/index', 3)
|
|||
|
|
}, 100)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (role == 1 && req.data.DoctorInfo.user.status == 2) {
|
|||
|
|
let logInfo = uni.getStorageSync('logInfo') || {}
|
|||
|
|
let userInfo = {
|
|||
|
|
...logInfo,
|
|||
|
|
...(uni.getStorageSync('userInfo') || {}),
|
|||
|
|
...req.data
|
|||
|
|
}
|
|||
|
|
userInfo.status = userInfo.user && userInfo.user.status != '' ? userInfo.user.status : userInfo
|
|||
|
|
.status
|
|||
|
|
|
|||
|
|
uni.setStorageSync('identity', userInfo['role'])
|
|||
|
|
uni.removeStorageSync('logInfo')
|
|||
|
|
uni.setStorageSync('userInfo', userInfo)
|
|||
|
|
setTimeout(() => {
|
|||
|
|
console.log('mainnnnnnnnnnnnnnnnnnnnnnnn');
|
|||
|
|
role == 1 && this.$go('/pages/workbench/index', 3)
|
|||
|
|
}, 100)
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
this.$toast(req.msg)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
</script>
|
|||
|
|
<style lang="scss">
|
|||
|
|
@import "uview-ui/index.scss";
|
|||
|
|
@import "common/css/app.css";
|
|||
|
|
</style>
|