123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <template>
- <view style="height:calc(100vh - 96px)">
- <view style="padding: 20rpx;">
- <view
- style="width: 100%;height: 20vh;border-radius: 10rpx;box-shadow: 0 0px 20px #b1b1b1;background-color: #fff;">
- <view style="display: flex;padding: 60rpx 40rpx 0;">
- <u-avatar src="/static/logo.png"></u-avatar>
- <view style="margin-left: 40rpx;;">
- <view style="font-size: 34rpx;font-weight: bold">
- {{userInfo.nickName}}
- </view>
- <view style="font-size: 30rpx;margin-top: 10rpx;">
- {{userInfo.dept.deptName}}
- </view>
- </view>
- </view>
- </view>
- </view>
- <view style="margin-top: 40rpx;background-color: #fff;">
- <u-cell-group>
- <u-cell icon="reload" title="检查更新" :value="version" isLink :iconStyle="{color:'#409EFF'}"
- @click="needUpdateApp(true)"></u-cell>
- <!-- <view style="height: 40rpx;background-color: #f5f5f5;"></view> -->
- <u-cell icon="arrow-rightward" title="退出登录" isLink :iconStyle="{color:'#409EFF'}" @click="out"></u-cell>
- </u-cell-group>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- userInfo: uni.getStorageSync('userInfo'),
- version: null
- }
- },
- onLoad() {
- this.needUpdateApp(false)
- },
- methods: {
- out() {
- uni.showModal({
- title: "提示",
- content: "是否要退出",
- success(res) {
- if (res.confirm) {
- uni.clearStorageSync()
- uni.reLaunch({
- url: "/pages/login/login"
- })
- }
- }
- })
- },
- //升级
- needUpdateApp(i) {
- var _this = this;
- console.log(getApp().globalData.updateUrl)
- plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
- if (i == true) {
- uni.showLoading({
- title: "检查中...",
- mask: true
- })
- uni.$u.http.post('/app/version/advance/' + wgtinfo.versionCode).then(res => {
- if (res.code == 200) {
- if (res.data != undefined) {
- uni.hideLoading()
- uni.showModal({
- title: "提示",
- content: "有新版本是否进行更新",
- success(qwe) {
- if (qwe.confirm) {
- _this.upgradeApp(getApp().globalData.updateUrl +
- res.data.url)
- }
- }
- })
- } else {
- uni.hideLoading()
- uni.showToast({
- title: "当前为最新版本",
- icon: "none"
- })
- }
- }
- }).catch(res => {
- uni.hideLoading()
- })
- } else {
- _this.version = wgtinfo.version
- }
- })
- },
- upgradeApp(url) {
- uni.showLoading({
- title: '更新中……'
- });
- uni.downloadFile({
- url: url,
- success: downloadResult => {
- if (downloadResult.statusCode === 200) {
- try {
- var filePath = downloadResult.tempFilePath;
- var ext = filePath.substring(
- filePath.lastIndexOf('.') + 1
- );
- plus.runtime.install(
- downloadResult.tempFilePath, {},
- function() {
- uni.hideLoading()
- plus.runtime.restart();
- },
- function(e) {
- uni.hideLoading()
- uni.showToast({
- title: "更新失败",
- icon: "none"
- })
- }
- );
- } catch (e) {
- uni.hideLoading()
- }
- } else {
- uni.hideLoading()
- uni.showToast({
- title: "下载失败",
- icon: 'none'
- })
- }
- },
- fail: res => {
- uni.hideLoading()
- uni.showToast({
- title: "下载失败",
- icon: 'none'
- })
- }
- });
- }
- }
- }
- </script>
- <style>
- </style>
|