191 lines
4.8 KiB
Vue
Raw Normal View History

2025-03-10 13:49:13 +08:00
<template>
2025-03-11 09:45:29 +08:00
<view class="main-view">
<u-navbar
title="MWMS"
@leftClick="navigateBack"
safeAreaInsetTop
fixed
placeholder
></u-navbar>
<view>
<u-avatar />
<text>个人信息</text>
<u-cell-group >
<u-cell icon="account" title="用户id" > <view slot="value">{{ userid }}</view></u-cell>
<u-cell icon="tags" title="用户名称"><view slot="value"> {{ username }}</view></u-cell>
<u-cell icon="home" title="工厂名称" ><view slot="value">{{ sitename }}</view></u-cell>
<u-cell icon="share" title="当前版本" ><view slot="value">{{ appversion }}</view></u-cell>
<u-cell icon="list-dot" title="当前环境" ><view slot="value">{{ backendUrl }}</view></u-cell>
</u-cell-group>
</view>
<u-button type="error" @click="handlerLogout" customStyle="margin-top: 50rpx">退出登录</u-button>
<u-button style="margin-top: 20rpx;" type="primary" @click="updateCheck" customStyle="margin-top: 10rpx">检查更新</u-button>
<u-gap height="70"></u-gap>
</view>
2025-03-10 13:49:13 +08:00
</template>
<script>
2025-03-11 09:45:29 +08:00
import store from '../../store/index.js';
import _app from '../../common/app_info.js';
import _config from '../../common/api.js';
import { MatchVersion } from '../../utils/utils.js';
import { installWgt, downWgt } from '../../common/CheckUpdate.js';
2025-03-10 13:49:13 +08:00
2025-03-11 09:45:29 +08:00
export default {
data() {
return {
background: {
backgroundImage: 'linear-gradient(45deg, rgb(28, 187, 180), rgb(141, 198, 63))'
},
// userid: store.state.userid,
appversion: _app.version // 从 app_info.js 获取版本号
};
},
computed: {
userid() {
return store.state.userid;
},
username() {
return store.state.username;
},
sitename() {
return store.state.sitename;
},
backendUrl () {
return store.state.backendUrl;
}
},
mounted() {
// 如果需要从本地存储获取版本号,可以保留以下代码
// let that = this;
// uni.getStorage({
// key: 'appversion',
// success(res) {
// that.appversion = res.data;
// }
// });
},
methods: {
handlerLogout() {
uni.removeStorageSync('menulist');
uni.removeStorageSync('token');
debugger
console.log('退出登录')
console.log(store.state)
uni.redirectTo({
url: '/pages/login/index'
});
},
updateCheck() {
let appVersion = '';
plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
appVersion = wgtinfo.version; // 获取APP的版本号(包括热更新后的)
});
let downloadUrl = this.$URL.serverURL + '/version/downloadwgt'; // 下载wgt更新包的地址
let checkVerUrl = this.$URL.serverURL + '/version/appnewestversion'; // 检查版本号的url地址
2025-03-10 13:49:13 +08:00
2025-03-11 09:45:29 +08:00
uni.request({
url: checkVerUrl, // 检查更新的服务器地址
method: 'GET',
success: (res) => {
let serverVersion = res.data.resultObj[0]['DESCRIPTION'];
console.log('服务器版本:', serverVersion); // 打印服务器上的版本
if (appVersion == '' || appVersion == null || appVersion == undefined) {
appVersion = plus.runtime.version;
console.log('初始版本号:', appVersion);
}
if (appVersion != serverVersion) {
console.log('走这里');
uni.showModal({
title: '检测到新版本',
content: '当前版本:' + appVersion + '\r\n' + '最新版本:' + serverVersion + '\r\n请立即更新',
success: function(cof) {
if (cof.confirm) {
console.log(downloadUrl);
downWgt(downloadUrl, serverVersion); // 下载wgt更新包
} else if (cof.cancel) {
console.log('用户点击取消' + appVersion);
}
}
});
}
}
});
}
}
};
</script>
2025-03-10 13:49:13 +08:00
2025-03-11 09:45:29 +08:00
<style lang="scss" scoped>
.main-view {
margin: 15rpx;
}
2025-03-10 13:49:13 +08:00
2025-03-11 09:45:29 +08:00
.cell-page {
padding-bottom: 20px;
}
2025-03-10 13:49:13 +08:00
2025-03-11 09:45:29 +08:00
.cell-box {
&__title {
font-size: 14px;
color: rgb(143, 156, 162);
margin: 20px 0px 0px 15px;
}
2025-03-10 13:49:13 +08:00
2025-03-11 09:45:29 +08:00
&__block {
// background-color: #fff;
margin-top: 20px;
2025-03-10 13:49:13 +08:00
}
}
2025-03-11 09:45:29 +08:00
.u-page {
padding: 0;
&__item {
&__title {
color: $u-tips-color;
background-color: $u-bg-color;
padding: 15px;
font-size: 15px;
&__slot-title {
color: $u-primary;
font-size: 14px;
}
}
}
2025-03-10 13:49:13 +08:00
}
2025-03-11 09:45:29 +08:00
.u-slot-title {
@include flex;
flex-direction: row;
align-items: center;
}
.u-cell-text {
font-size: 15px;
line-height: 22px;
color: #303133;
margin-right: 5px;
}
.u-slot-value {
line-height: 17px;
text-align: center;
font-size: 10px;
padding: 0 5px;
height: 17px;
color: #FFFFFF;
border-radius: 100px;
background-color: #f56c6c;
}
</style>