<template>
|
<view class="loginP">
|
<view class="logo">
|
<image src="@/static/image/login/logo-qq.jpg" mode=""></image>
|
</view>
|
<view class="mainTitle">
|
<h3>智能化立体库系统</h3>
|
<h2>系统登录</h2>
|
</view>
|
<view class="user-pwd">
|
<view class="userP">
|
<i class="iconfont icon-yonghutouxiang"></i>
|
<view class="inputC">
|
<u-input v-model="phone" type="text" placeholder="用户名/手机号" />
|
</view>
|
</view>
|
<view class="pwdP">
|
<i class="iconfont icon-mima"></i>
|
<view class="inputC">
|
<u-input v-model="pwd" type="password" placeholder="密码" />
|
</view>
|
</view>
|
</view>
|
<view class="loginBtnP" style="padding: 2rem 0 1rem 0;">
|
<view class="loginBtn" @click="goHome">
|
系统登录
|
</view>
|
</view>
|
<view class="forgot-register">
|
<view class="forgot">
|
<!-- 设置接口地址 -->
|
</view>
|
<view class="register" @click="update">
|
更新APP
|
</view>
|
</view>
|
<view class="" style="position: fixed;left:12px;bottom: 5px;width: 100%;text-align: center;">
|
应用版本号 {{wgtVer}}
|
</view>
|
<u-toast ref="uToast" />
|
</view>
|
</template>
|
<script lang='js'>
|
import {
|
login
|
} from '../../api/login.js'
|
import {
|
SearchOne
|
} from '../../api/upDate.js'
|
export default {
|
data() {
|
return {
|
phone: "",
|
pwd: "",
|
wgtVer: '',
|
version: '',
|
data: null,
|
isandroid: ''
|
}
|
},
|
created() {
|
this.plusReady()
|
},
|
methods: {
|
//自动更新
|
update() {
|
this.plusReady();
|
this.AndroidCheckUpdate();
|
},
|
// 获取当前版本号
|
plusReady() {
|
var that = this;
|
// 获取本地应用资源版本号
|
try{
|
plus.runtime.getProperty(plus.runtime.appid, function(inf) {
|
that.data = inf
|
that.wgtVer = inf.version; //获取当前版本号
|
that.version = plus.runtime.version;
|
});
|
}catch(e){
|
//TODO handle the exception
|
}
|
},
|
// 自动更新
|
AndroidCheckUpdate() {
|
var that2 = this;
|
let params = {
|
Url: '',
|
Version: ''
|
}
|
SearchOne(params).then((res) => {
|
if (res.Version != that2.version) {
|
// if (plus.networkinfo.getCurrentType() != 3) {
|
// uni.showToast({
|
// title: '有新的版本发布,检测到您目前非Wifi连接,为节约您的流量,程序已停止自动更新,将在您连接WIFI之后重新检测更新。',
|
// mask: false,
|
// duration: 5000,
|
// icon: "none"
|
// });
|
// return;
|
// }
|
// uni.showToast({
|
// title: '有新的版本发布,检测到您目前为Wifi连接,程序已启动自动更新。新版本下载完成后将自动弹出安装程序。',
|
// mask: false,
|
// duration: 5000,
|
// icon: "none"
|
// });
|
//res.data.androidurl 是apk的下载链接
|
var url = this.$myHOST + '/Home/GetDownLoad?name=' + res
|
.Url; //文件名称可以在上传时进行保存,下载时取出,当文件名称中存在单双引号时,要做好处理,否则会报错
|
var name = 'qingqi.apk';
|
// plus.runtime.openURL(this.$myHOST + '/Home/GetDownLoad?name=' + res.Url, function(res) {console.log(res);});
|
var dtask = plus.downloader.createDownload(url, {}, function(d, status) {
|
//d为下载的文件对象
|
// if (res.statusCode == 200) {
|
//选择软件打开文件
|
plus.runtime.install(d.filename, {}, {}, function(e) {
|
console.log(e)
|
})
|
// } else {
|
// //下载失败
|
// plus.downloader.clear(); //清除下载任务
|
// }
|
})
|
// dtask.start(); //执行下载
|
try {
|
dtask.start(); // 开启下载的任务
|
var prg = 0;
|
var showLoading = plus.nativeUI.showWaiting("正在下载"); //创建一个showWaiting对象
|
|
dtask.addEventListener('statechanged', function(task, status) {
|
|
// 给下载任务设置一个监听 并根据状态 做操作
|
switch (task.state) {
|
case 1:
|
showLoading.setTitle("正在下载");
|
break;
|
case 2:
|
showLoading.setTitle("已连接到服务器");
|
break;
|
case 3:
|
prg = parseInt((parseFloat(task.downloadedSize) / parseFloat(task
|
.totalSize)) *
|
100);
|
showLoading.setTitle(" 正在下载" + JSON.stringify(task.downloadedSize));
|
break;
|
case 4:
|
plus.nativeUI.closeWaiting();
|
//下载完成
|
break;
|
}
|
});
|
} catch (err) {
|
console.log('错误信息', err)
|
plus.nativeUI.closeWaiting();
|
}
|
} else {
|
uni.showToast({
|
title: '已经是最新版',
|
mask: false,
|
duration: 1500,
|
icon: "none"
|
});
|
}
|
})
|
|
},
|
// 点击登录按钮
|
goHome() {
|
uni.clearStorageSync()
|
let params = {
|
userName: this.phone,
|
password: this.pwd
|
}
|
login(params).then((res) => {
|
if (res.code == 0) {
|
uni.setStorageSync('admin', this.phone);
|
uni.setStorageSync('pwd', this.pwd);
|
uni.setStorageSync('roleName', res.data[0].roleName);
|
uni.switchTab({
|
//存储好后跳转页面
|
url: "../Home/index",
|
});
|
} else {
|
// this.$u.toast(res.data.msg)
|
this.$u.toast('请输入正确的账号密码')
|
}
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.logo {
|
text-align: center;
|
|
image {
|
width: 75px;
|
height: 70px;
|
margin: 0 auto -25px;
|
}
|
}
|
|
.btn {
|
border: 1px solid #717171;
|
padding: 5px 7px;
|
border-radius: 5px;
|
color: #717171;
|
}
|
|
.iconfont {
|
color: #ccc;
|
}
|
|
.loginP {
|
padding: 2rem;
|
margin-top: 20px;
|
}
|
|
.mainTitle {
|
color: #717171;
|
text-align: center;
|
font-size: 1.1rem;
|
padding: 2rem 2rem 0 2rem;
|
}
|
|
.classesifyP {
|
text-align: center;
|
display: flex;
|
justify-content: center;
|
}
|
|
.classesify {
|
width: 11rem;
|
height: 2.1875rem;
|
border: 1px solid #02af74;
|
display: flex;
|
align-items: center;
|
border-radius: 100px;
|
}
|
|
.classesify-puc {
|
width: 50%;
|
font-size: 0.6rem;
|
border-bottom-left-radius: 100px;
|
border-top-left-radius: 100px;
|
height: 100%;
|
line-height: 100%;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
background-color: #02af74;
|
}
|
|
.classesify-pucs {
|
width: 50%;
|
font-size: 0.6rem;
|
border-bottom-left-radius: 100px;
|
border-top-left-radius: 100px;
|
height: 100%;
|
line-height: 100%;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
background-color: white;
|
}
|
|
.classesify-bus {
|
width: 50%;
|
}
|
|
.classesify-buss {
|
width: 50%;
|
font-size: 0.6rem;
|
border-bottom-right-radius: 100px;
|
border-top-right-radius: 100px;
|
height: 100%;
|
line-height: 100%;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
background-color: #02af74;
|
}
|
|
.userP {
|
display: flex;
|
align-items: center;
|
margin: 4rem 0rem 1rem 0rem;
|
padding: 0.3125rem 0rem;
|
border-bottom: 1px solid #dfdfdf;
|
}
|
|
.pwdP {
|
display: flex;
|
align-items: center;
|
margin: 2rem 0rem 1rem 0rem;
|
padding: 0.3125rem 0rem;
|
border-bottom: 1px solid #dfdfdf;
|
}
|
|
.inputC {
|
width: 100%;
|
padding-left: 1rem;
|
}
|
|
.rightIcon {
|
margin: 0 auto;
|
}
|
|
.loginBtnP {
|
width: 100%;
|
display: flex;
|
justify-content: center;
|
}
|
|
.loginBtn {
|
width: 14rem;
|
padding: 0.5rem;
|
background-color: #7abbff;
|
border-radius: 0.5rem;
|
color: white;
|
text-align: center;
|
font-size: 1.1rem;
|
}
|
|
.forgot-register {
|
padding: 1rem 0rem;
|
display: flex;
|
justify-content: space-between;
|
color: #747474;
|
margin-top: 15px;
|
}
|
|
.user-pwd {
|
margin-bottom: 2rem;
|
margin-top: -20px;
|
}
|
</style>
|