| | |
| | | <!-- <image class="title-img" src="/images/earth.svg" alt=" 图片" /> --> |
| | | |
| | | </view> |
| | | <text class="title">请登录</text> |
| | | <text class="title">{{translate('start_login')}}</text> |
| | | <view class="login-form"> |
| | | <view class="login-form-item line"> |
| | | <text class="label">用户名</text> |
| | | <text class="label">{{translate('account')}}</text> |
| | | <input class="input" :focus="formData.accountFocus" comfirm-type="done" type="text" |
| | | v-model="form.account" placeholder="手机号码" /> |
| | | v-model="form.account" :placeholder="translate('input_login')" /> |
| | | </view> |
| | | |
| | | <view class="login-form-item line"> |
| | | <text class="label">密码</text> |
| | | <text class="label">{{translate('password')}}</text> |
| | | <input class="input" :focus="formData.passwordFocus" :password="hidePassContent" |
| | | comfirm-type="done" v-model="form.password" placeholder="登录密码" /> |
| | | comfirm-type="done" v-model="form.password" :placeholder="translate('input_password')" /> |
| | | <uni-icons :type="hidePassContent?'eye-slash':'eye'" size="28" |
| | | @click="clickHidePassContent"></uni-icons> |
| | | </view> |
| | |
| | | <checkbox-group @change="handleSavePwdChange"> |
| | | <label> |
| | | <checkbox value="1" :checked="savePsw" /> |
| | | <text>记住密码</text> |
| | | <text>{{translate('remember_password')}}</text> |
| | | </label> |
| | | </checkbox-group> |
| | | |
| | |
| | | <!-- <a @click="clickForgotPassword">忘记密码</a> --> |
| | | </view> |
| | | <view class="button-group"> |
| | | <a-button :disabled="disabledOk" type="primary" class="button" @click="clickLogin">登录</a-button> |
| | | <a-button :disabled="disabledOk" type="primary" class="button" |
| | | @click="clickLogin">{{translate('login')}}</a-button> |
| | | <!-- <a-button class="button" type="ghost" @click="clickNewAccount">创建账号</a-button> --> |
| | | </view> |
| | | </view> |
| | |
| | | </view> |
| | | </view> |
| | | <view class="bottom"> |
| | | <a class="language" @click="clickLanguage">{{translate("language")}}</a> |
| | | <view class="version"> |
| | | 版本:{{version}} |
| | | {{translate("version")}}:{{version.date}}_{{version.ver}} |
| | | </view> |
| | | </view> |
| | | <!-- 版本升级弹窗开始 --> |
| | | <uni-popup ref="promotion" type="center"> |
| | | <view class="promotion" style="width: 700rpx;padding:20rpx 40rpx; background: white;font-size: 36rpx;"> |
| | | |
| | | <view class="operates"> |
| | | <view v-if="showUpdateBtns" style="text-align: center;padding:20rpx;font-weight: 700;"> |
| | | {{translate('ask_update') }} |
| | | </view> |
| | | <view style="text-align: center;padding-top:20rpx;"> |
| | | {{carUpdateFlag ? translate('tip_car_update') : translate('tip_app_update') }}:{{newVersion.date}}_{{newVersion.ver}} |
| | | </view> |
| | | <view v-if="newVersion.info" style="padding:20rpx;font-weight: 600;"> |
| | | {{translate("version_info")}}:{{newVersion.info}} |
| | | </view> |
| | | |
| | | <template v-if="showUpdateBtns"> |
| | | <text @click="onCancel" |
| | | style="margin-top:30rpx; display: inline-block;color: #7cd0f8;width: 50%; text-align: center;">{{translate('cancel')}}</text> |
| | | <text @click="onUpdate" |
| | | style="margin-top:30rpx;display: inline-block;color: #7cd0f8;width: 50%; text-align: center;">{{translate('confirm')}}</text> |
| | | </template> |
| | | </view> |
| | | <view class="operates" v-if=" !showUpdateBtns"> |
| | | <cmdProgress :percent="percentage" stroke-color="linear-gradient(to right, #ef32d9, #89fffd)"> |
| | | </cmdProgress> |
| | | </view> |
| | | </view> |
| | | </uni-popup> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import cmdProgress from "@/components/cmd-progress/index.vue" |
| | | import { |
| | | session, |
| | | showToast, |
| | | showModal |
| | | showModal, |
| | | showError |
| | | } from "@/comm/utils.js" |
| | | import TaskInit from "@/comm/extend.js" |
| | | import { |
| | | Button |
| | | } from 'antd-mobile-vue-next' |
| | | import { |
| | | getAppVersion, |
| | | getServerVersion, |
| | | downloadUpdatePackage |
| | | } from "@/api/version.js" |
| | | |
| | | |
| | | |
| | | export default { |
| | | name: "PagesLogin", |
| | | components: { |
| | | 'a-button': Button |
| | | 'a-button': Button, |
| | | cmdProgress |
| | | }, |
| | | data() { |
| | | |
| | |
| | | }, |
| | | hidePassContent: true, |
| | | savePsw: false, |
| | | version: "1.0.0", |
| | | version: { |
| | | date: "", |
| | | ver: "" |
| | | }, |
| | | newVersion: { |
| | | date: "", |
| | | ver: "", |
| | | info:"" |
| | | }, |
| | | carUpdateFlag: false, |
| | | vesironFileName: "", //安卓app下载链接 |
| | | percentage: 0, //下载进度 |
| | | showUpdateBtns: true, |
| | | } |
| | | }, |
| | | computed: { |
| | |
| | | return false |
| | | } |
| | | }, |
| | | onLoad() { |
| | | onLoad(option) { |
| | | const _this = this |
| | | uni.setNavigationBarTitle({ |
| | | title: this.translate('login') |
| | | }) |
| | | |
| | | uni.getSystemInfo({ |
| | | success(e) { |
| | |
| | | |
| | | }) |
| | | const info = session.getValue("login_info") |
| | | console.log(info) |
| | | |
| | | this.setData({ |
| | | form: { |
| | | account: info?.id || '', |
| | |
| | | // #ifdef APP-PLUS |
| | | plus.runtime.getProperty(plus.runtime.appid, (info) => { |
| | | // console.log(info); |
| | | this.version = info.version; |
| | | const verStr = info.version || ""; |
| | | const arVer = verStr.split("_") |
| | | if (arVer.length > 1) { |
| | | _this.version = { |
| | | date: arVer[0], |
| | | ver: arVer[1] |
| | | } |
| | | } else if (arVer.length == 1) { |
| | | _this.version = { |
| | | date: "", |
| | | ver: arVer[0] |
| | | } |
| | | } |
| | | if (!option.flag) |
| | | _this.checkAppVersion(_this.version) |
| | | |
| | | }); |
| | | //#endif |
| | | |
| | |
| | | }); |
| | | }); |
| | | }, |
| | | |
| | | clickLanguage() { |
| | | uni.navigateTo({ |
| | | url: "/pages/my/language" |
| | | }) |
| | | |
| | | }, |
| | | clickHidePassContent() { |
| | | this.hidePassContent = !this.hidePassContent |
| | | }, |
| | |
| | | } |
| | | |
| | | }, |
| | | clickLogin() { |
| | | onUpdate() { |
| | | this.showUpdateBtns = false; |
| | | |
| | | |
| | | this.updateAPP(this.vesironFileName, this.newVersion) |
| | | }, |
| | | onCancel() { |
| | | this.$refs.promotion.close(); |
| | | if (!this.carUpdateFlag) { |
| | | setTimeout(() => { |
| | | this.checkServerVersion() |
| | | }, 500) |
| | | } |
| | | |
| | | }, |
| | | updateAPP(fileName, verInfo) { |
| | | let _this = this; |
| | | let sys = uni.getSystemInfoSync().platform //检查系统 |
| | | |
| | | downloadUpdatePackage(fileName, (path) => { |
| | | if (_this.carUpdateFlag) { |
| | | var pathArr = fileName.split(".") |
| | | const fileExt = pathArr.pop() |
| | | const fileName2 = `EasyGO_${verInfo.date}_${verInfo.ver}.${fileExt}` |
| | | TaskInit.fileUtils.clearSavedFiles("car_version") |
| | | TaskInit.fileUtils.moveToLocal(path, "car_version", fileName2).then(( |
| | | res) => { |
| | | console.log("保存成功:", res) |
| | | showToast(this.translate('download_success')); |
| | | }).catch((err) => { |
| | | console.log("保存失败:", err) |
| | | showToast(_this.translate("failed_save_file")) |
| | | }) |
| | | } else { |
| | | plus.runtime.openFile(path); //选择软件打开文件 |
| | | showToast(this.translate('update_success')); |
| | | } |
| | | _this.$refs.promotion.close(); |
| | | |
| | | }, (res) => { |
| | | console.log('下载进度' + res.progress); |
| | | _this.percentage = res.progress |
| | | if (_this.percentage == 100) { |
| | | _this.$refs.promotion.close(); |
| | | } |
| | | }, (err) => { |
| | | _this.$refs.promotion.close(); |
| | | showToast(`${_this.translate('update_fail') },${err}`); |
| | | }) |
| | | |
| | | }, |
| | | async checkAppVersion(version) { |
| | | try { |
| | | const listVer = await getAppVersion() || [] |
| | | const appVer = listVer[0] || {} |
| | | this.vesironFileName = appVer.file_name || "" |
| | | if (this.vesironFileName) { |
| | | var isver = this.compareVersion({ |
| | | date: appVer.file_time, |
| | | ver: appVer.version |
| | | }, version); |
| | | |
| | | if (isver) { |
| | | this.carUpdateFlag = false |
| | | this.newVersion = { |
| | | date: appVer.file_time, |
| | | ver: appVer.version, |
| | | info: appVer.info, |
| | | } |
| | | this.$refs.promotion.open(); |
| | | } else { |
| | | this.checkServerVersion() |
| | | } |
| | | } else { |
| | | this.checkServerVersion() |
| | | } |
| | | } catch (ex) { |
| | | console.log(ex) |
| | | } |
| | | |
| | | }, |
| | | getVersionFromFileName(fileName) { |
| | | if (!fileName.trim()) { |
| | | return { |
| | | date: "", |
| | | ver: "" |
| | | } |
| | | } |
| | | let versionInfos = fileName.trim().split('_'); |
| | | let date = versionInfos[1] |
| | | let version2 = versionInfos[2] |
| | | let versionInfos2 = version2.split('.'); |
| | | versionInfos2.pop() |
| | | return { |
| | | date, |
| | | ver: versionInfos2.join(".") |
| | | } |
| | | }, |
| | | compareVersion(curV, reqV) { |
| | | |
| | | if (curV.date == reqV.date) { |
| | | return curV.ver > reqV.ver |
| | | } |
| | | return curV.date > reqV.date |
| | | }, |
| | | async checkServerVersion() { |
| | | try { |
| | | const listVer = await getServerVersion() || [] |
| | | const svrVer = listVer[0] || {} |
| | | this.vesironFileName = svrVer.file_name || "" |
| | | if (this.vesironFileName) { |
| | | var oldVerName = "" |
| | | var fileList = [] |
| | | try { |
| | | fileList = await TaskInit.fileUtils.listSavedFiles('car_version') |
| | | } catch (ex) { |
| | | console.log(ex) |
| | | } |
| | | fileList.forEach((ele) => { |
| | | if (oldVerName) { |
| | | if (oldVerName < ele.name) { |
| | | oldVerName = ele.name |
| | | } |
| | | } else { |
| | | oldVerName = ele.name |
| | | } |
| | | }) |
| | | console.log(oldVerName) |
| | | if (oldVerName) { |
| | | const oldVer = this.getVersionFromFileName(oldVerName) |
| | | const isVer = this.compareVersion({ |
| | | date: svrVer.file_time, |
| | | ver: svrVer.version |
| | | }, oldVer); |
| | | if (isVer || !oldVer) { |
| | | this.carUpdateFlag = true |
| | | this.newVersion = { |
| | | date: svrVer.file_time, |
| | | ver: svrVer.version, |
| | | info: svrVer.info, |
| | | } |
| | | this.$refs.promotion.open(); |
| | | } |
| | | } else { |
| | | this.carUpdateFlag = true |
| | | this.newVersion = { |
| | | date: svrVer.file_time, |
| | | ver: svrVer.version, |
| | | info: svrVer.info, |
| | | } |
| | | this.$refs.promotion.open(); |
| | | } |
| | | |
| | | } |
| | | } catch (ex) { |
| | | |
| | | console.log(ex) |
| | | } |
| | | |
| | | }, |
| | | |
| | | async clickLogin() { |
| | | |
| | | try { |
| | | let account = this.form.account.trim() |
| | | if (!account) { |
| | | showToast("请输入手机号") |
| | | showToast(this.translate("input_login")) |
| | | return |
| | | } |
| | | let password = this.form.password.trim() |
| | | if (!password) { |
| | | showToast("请输入密码") |
| | | showToast(this.translate("input_password")) |
| | | return |
| | | } |
| | | if (account != "sa") { |
| | | showToast("手机号不存在") |
| | | showToast(this.translate("account_not_exist")) |
| | | return |
| | | } |
| | | if (password != "0000") { |
| | | showToast("密码错误") |
| | | showToast(this.translate("password_error")) |
| | | return |
| | | } |
| | | if (this.savePsw) { |
| | |
| | | // uni.navigateTo({ |
| | | // url: `/pages/index/connect?ip=192.168.1.2&sid=HH&password=HH888888` |
| | | // }) |
| | | } catch (ex) { |
| | | showError(ex) |
| | | } |
| | | }, |
| | | clickNewAccount() { |
| | | uni.navigateTo({ |
| | |
| | | uni.navigateTo({ |
| | | url: "/pages/login/forgot-password" |
| | | }) |
| | | } |
| | | } |
| | | }, |
| | | translate(t) { |
| | | if (typeof this.$t == "function") return this.$t(`page.${t}`) |
| | | else return t; |
| | | }, |
| | | }, |
| | | |
| | | } |
| | | </script> |
| | | |
| | |
| | | color: #888; |
| | | flex-direction: row; |
| | | display: flex; |
| | | } |
| | | |
| | | .language { |
| | | float: left; |
| | | display: flex; |
| | | text-decoration: underline; |
| | | /* 下划线 */ |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | .line{ |
| | | border-bottom: 2rpx solid #ddd; |
| | | } |