This commit is contained in:
2023-03-31 17:42:39 +08:00
parent f5af987589
commit 097981fcc5
5 changed files with 267 additions and 66 deletions

View File

@@ -21,9 +21,10 @@
<view class="submit"> <view class="submit">
<button class="primary-button" :disabled="disabled" @click="toLogin">&nbsp;&nbsp;</button> <button class="primary-button" :disabled="disabled" @click="toLogin">&nbsp;&nbsp;</button>
</view> </view>
<view class="scanBox" @tap="checkMpaasScan"> <view class="scanBox">
<view class="iconfont scan_icon"></view> <!-- <view class="iconfont scan_icon"></view> -->
<text class="san_text">扫码登录</text> <!-- <text class="san_text">扫码登录</text> -->
<text class="san_text" @tap="isUpdate">升级版本</text>
</view> </view>
</view> </view>
<view class="login_card"> <view class="login_card">
@@ -43,14 +44,20 @@
</view> </view>
</view> </view>
</view> </view>
<view v-if="version !== ''" class="version-name">v{{version}}</view>
<Up-grade v-if="grade === true" @closeUpdate="closeUpdate" :androidUrl="androidUrl"></up-grade>
</view> </view>
</template> </template>
<script> <script>
import { RSAencrypt } from '@/utils/jsencrypt.js' import { RSAencrypt } from '@/utils/jsencrypt.js'
import {handLogin} from '@/utils/getData2.js' import {handLogin, pdaUpdate} from '@/utils/getData2.js'
import permision from "@/utils/permission.js" import permision from "@/utils/permission.js"
import UpGrade from './upgrade.vue'
export default { export default {
components: {
UpGrade
},
data() { data() {
return { return {
loginname: '', loginname: '',
@@ -63,7 +70,11 @@
disabled: false, disabled: false,
jobnum: '', jobnum: '',
qrcode: '', qrcode: '',
logintype: '' logintype: '',
version: '',
versionCode: '',
grade: false,
androidUrl: ''
}; };
}, },
computed: { computed: {
@@ -140,70 +151,21 @@
this.disabled = false this.disabled = false
} }
}, },
async toScan() { isUpdate () {
// #ifdef APP-PLUS this._pdaUpdate()
let status = await this.checkPermission(); },
if (status !== 1) { async _pdaUpdate () {
return; let res = await pdaUpdate()
} if (res.versionName === this.version) {
// #endif uni.showToast({
uni.scanCode({ title: '当前为最新版本',
success: (res) => { icon: 'none'
console.log(res.result) })
},
fail: (err) => {
// uni.showToast({
// title: '出错',
// icon: 'none'
// })
}
});
}
// #ifdef APP-PLUS
,
async checkPermission(code) {
let status = permision.isIOS ? await permision.requestIOS('camera') :
await permision.requestAndroid('android.permission.CAMERA');
if (status === null || status === 1) {
status = 1;
} else { } else {
uni.showModal({ this.grade = true
content: "需要相机权限", this.androidUrl = res.url
confirmText: "设置",
success: function(res) {
if (res.confirm) {
permision.gotoAppSetting();
}
}
})
} }
return status;
} }
// #endif
// #ifdef APP-PLUS
,
async checkMpaasScan () {
var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
mpaasScanModule.mpaasScan({
// 扫码识别类型参数可多选qrCode、barCode不设置默认识别所有
'scanType': ['qrCode','barCode'],
// 是否隐藏相册默认false不隐藏
'hideAlbum': false
},
(ret) => {
uni.showModal({
title: "弹窗标题",
// 返回值中resp_code 表示返回结果值10用户取消11其他错误1000成功
// 返回值中resp_message 表示返回结果信息
// 返回值中resp_result 表示扫码结果,只有成功才会有返回
content: JSON.stringify(ret),
showCancel: false,
confirmText: "确定"
})
})
}
// #endif
} }
} }
</script> </script>
@@ -277,4 +239,9 @@
_font(16px,24px,#D7592F,,center) _font(16px,24px,#D7592F,,center)
.drift .drift
transition left .3s linear transition left .3s linear
.version-name
width 100%
position: absolute
bottom: 15px
_font(15px, 30px, #999,,center)
</style> </style>

229
pages/login/upgrade.vue Normal file
View File

@@ -0,0 +1,229 @@
<template>
<view class="mask flex-center">
<view class="content-update botton-radius">
<view class="content-top">
<text class="content-top-text">发现新版本</text>
<image class="content-top" style="top: 0;" width="100%" height="100%" src="../../static/images/bg_top.png">
</image>
</view>
<view class="content-header"></view>
<view class="content-body">
<view class="title">
<text>海亮缓存线又有新版本了升级到最新版本享受更丰富稳定快速的功能和体验</text>
</view>
<view class="footer flex-center">
<template>
<template v-if="!downloadSuccess">
<view class="progress-box flex-column" v-if="downloading">
<progress class="progress" border-radius="35" :percent="downLoadPercent" activeColor="#3DA7FF" show-info stroke-width="10" />
<view style="width:100%;font-size: 14px;display: flex;justify-content: space-around;">
<text>安装包下载中请稍后</text>
<text>({{downloadedSize}}/{{packageFileSize}}M)</text>
</view>
</view>
<button v-else class="content-button" style="border: none;color: #fff;" plain @click="updateApp">立即升级</button>
</template>
</template>
</view>
</view>
<image v-if="is_mandatory" class="close-img" src="../../static/images/app_update_close.png" @click.stop="closeUpdate"></image>
</view>
</view>
</template>
<script>
export default {
data () {
return {
downloadSuccess: false,
downloading: false,
downLoadPercent: 0,
downloadedSize: 0,
packageFileSize: 0,
is_mandatory: true
}
},
props: {
androidUrl: String
},
methods: {
updateApp() {
this.is_mandatory = false
this.downloading = true
this.doUpData(this.androidUrl);
},
doUpData(Url) {
const downloadTask = uni.downloadFile({
url: Url,
success: downloadResult => {
if (downloadResult.statusCode == 200) {
this.downloadSuccess = true;
plus.runtime.install(
//安装软件
downloadResult.tempFilePath,
{
force: true
},
function(res) {
plus.runtime.restart();
}
);
}
},
complete: () => {
this.downloading = false;
this.downLoadPercent = 0
this.downloadedSize = 0
this.packageFileSize = 0
}
});
// 下载进度
downloadTask.onProgressUpdate(res => {
this.downLoadPercent = res.progress;
this.downloadedSize = (res.totalBytesWritten / Math.pow(1024, 2)).toFixed(2);
this.packageFileSize = (res.totalBytesExpectedToWrite / Math.pow(1024, 2)).toFixed(2);
});
},
closeUpdate () {
this.$emit('closeUpdate')
}
}
}
</script>
<style>
page {
background: transparent;
}
.flex-center {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center;
}
.mask {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, .65);
}
.botton-radius {
border-bottom-left-radius: 15px;
border-bottom-right-radius: 15px;
}
.content-update {
position: relative;
top: 0;
width: 300px;
background-color: #fff;
box-sizing: border-box;
padding: 0 20px;
font-family: Source Han Sans CN;
}
.text {
/* #ifndef APP-NVUE */
display: block;
/* #endif */
line-height: 200px;
text-align: center;
color: #FFFFFF;
}
.content-top {
position: absolute;
top: -97.5px;
left: 0;
width: 300px;
height: 135px;
}
.content-top-text {
font-size: 22px;
font-weight: bold;
color: #F8F8FA;
position: absolute;
top: 60px;
left: 25px;
z-index: 1;
}
.content-header {
height: 40px;
}
.title {
font-size: 16px;
font-weight: bold;
color: #3DA7FF;
line-height: 20px;
color: #333;
}
.footer {
height: 75px;
display: flex;
align-items: center;
justify-content: space-around;
}
.box-des-scroll {
box-sizing: border-box;
padding: 0 20px;
height: 25px;
text-align: left;
}
.box-des {
font-size: 13px;
color: #000000;
line-height: 50px;
}
.progress-box {
width: 100%;
}
.progress {
width: 90%;
height: 20px;
border-radius: 13px;
}
.close-img {
width: 35px;
height: 35px;
z-index: 1000;
position: absolute;
bottom: -60px;
left: calc(50% - 35px / 2);
}
.content-button {
text-align: center;
flex: 1;
font-size: 15px;
font-weight: 400;
color: #FFFFFF;
border-radius: 20px;
margin: 0 10px;
height: 40px;
line-height: 40px;
background: linear-gradient(to right, #1785ff, #3DA7FF);
}
.flex-column {
display: flex;
flex-direction: column;
align-items: center;
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

BIN
static/images/bg_top.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -9,6 +9,11 @@ export const handLogin = (user, password) => request({
} }
}) })
// 版本更新测试
export const pdaUpdate = () => request({
url:'api/pda/update'
})
/** 扫码异常 */ /** 扫码异常 */
// 1.1缓存线下拉框 // 1.1缓存线下拉框
export const getCacheLine = (area) => request({ export const getCacheLine = (area) => request({