cuiqian2004
6 天以前 07925905f1a596e20e980de6d42db217abb753b0
pages/login/index.vue
@@ -1,19 +1,22 @@
<template>
   <view class="uni-page-login" style="width: 100vw;height: 64vh;">
   <view class="uni-page-login " :class="largeMode?'large-mode':''" style="width: 100vw;height: 64vh;">
      <div id="headr" class="mui-bar mui-bar-nav">
         <image class="logo" src="../../images/login/mobox_log_200.png"></image>
      </div>
      <div class="mui-content">
         <form id='login-form' class="mui-input-group">
            <a href="javascript:;" class="SetServer" @click="inputDialogToggle">{{translateSys('set')}}</a>
            <a href="javascript:;" class="SetServer" @click="clickSetLanguage">{{translateSys('language')}}</a>
            <a href="javascript:;" class="set-server" @click="inputDialogToggle">{{translateSys('set')}}</a>
            <navigator class="set-language" url="./language">
               <a href="javascript:;">{{translateSys('language')}}</a>
            </navigator>
            <div class="mui-input-row">
               <label class="la_icon">
                  <image class="logo_input" src="../../images/login/person_30.png"></image>
               </label>
               <input type="text" class="mui-input" v-model="userName" :placeholder="translateSys('input_login')">
               <!-- <label class="mui-navigate-right" id="namsel"><image class="logo_icon" src="../../images/login/user-photo.png</image></label> -->
            </div>
            <div class="mui-input-row">
               <label class="la_icon">
@@ -89,7 +92,8 @@
   import cmdProgress from "@/components/cmd-progress/cmd-progress.vue"
   import {
      showModal,
      showToast,
      showInfo,
      showError,
      showLoading,
      hideLoading
   } from "@/js/Page.js"
@@ -121,6 +125,9 @@
            showBtns: true,
            selectedClasses: "",
            classesLst: [],
            largeMode: false,
         }
      },
      onShow() {
@@ -157,12 +164,9 @@
         async check(version) {
            try {
               if (!this.userServer) {
                  uni.showModal({
                     title: this.translateSys("tip"),
                     content: this.translate("tip_no_web_server"),
                     showCancel: false,
                     confirmText: this.translateSys('close')
                  });
                  showInfo(this.translate('tip_no_web_server'));
                  return;
               }
               // var ser = this.userServer.toLowerCase().split('/');
@@ -179,16 +183,8 @@
            } catch (ex) {
               // console.log(ex);
               let exStr = JSON.stringify(ex)
               if (exStr == "{}")
                  exStr = ex
               let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr
               uni.showModal({
                  title: this.translateSys("error"),
                  content: tip,
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               showError(ex, this.translateSys("error"));
            }
@@ -252,18 +248,12 @@
                  //下载成功,d.filename是文件在保存在本地的相对路径,使用下面的API可转为平台绝对路径
                  var fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename);
                  plus.runtime.openFile(d.filename); //选择软件打开文件
                  uni.showToast({
                     icon: 'none',
                     title: this.translate('update_success')
                  });
                  showInfo(this.translate('update_success'));
                  _this.$refs.promotion.close();
               } else {
                  //下载失败
                  plus.downloader.clear(); //清除下载任务
                  uni.showToast({
                     icon: 'none',
                     title: this.translate('update_fail')
                  });
                  showInfo(this.translate('update_fail'));
                  _this.showBtns = false;
               }
            })
@@ -288,20 +278,18 @@
         inputDialogToggle() {
            // this.$refs.inputDialog.open()
            const $this = this
            uni.navigateTo({
               url: "./set",
               events: {
                  exitSetEvent(val) {
                     $this.userServer = val;
                     $this.query(); //版本升级
                     $this.largeMode = getApp().globalData.largeMode
                  }
               }
            })
         },
         clickSetLanguage() {
            uni.navigateTo({
               url: './language'
            });
         },
         dialogInputConfirm(val) {
@@ -361,37 +349,23 @@
         async logind() {
            try {
               if (!this.userServer) {
                  uni.showModal({
                     title: this.translateSys('tip'),
                     content: this.translate('tip_no_web_server'),
                     showCancel: false,
                     confirmText: this.translateSys('close')
                  });
                  showInfo(this.translate('tip_no_web_server'));
                  return;
               }
               if (!this.userName) {
                  uni.showModal({
                     title: this.translateSys('tip'),
                     content: this.translate('tip_no_user_account'),
                     showCancel: false,
                     confirmText: this.translateSys('close')
                  });
                  showInfo(this.translate('tip_no_user_account'))
                  return;
               }
               if (!this.userPwd) {
                  uni.showModal({
                     title: this.translateSys('tip'),
                     content: this.translate('tip_no_user_password'),
                     showCancel: false,
                     confirmText: this.translateSys('close')
                  });
                  showInfo(this.translate('tip_no_user_password'));
                  return;
               }
               var rootUrl = 'http://' + this.userServer
               if (this.userServer.includes("://")) {
                  rootUrl = this.userServer
               }
               showLoading("loading......")
               showLoading("loading...")
               const res = await login(rootUrl, this.userName, this.userPwd)
               //设置全局参数:user-用户信息
               utils.session.setValue('server', rootUrl);
@@ -424,16 +398,7 @@
            } catch (ex) {
               hideLoading()
               let exStr = JSON.stringify(ex)
               if (exStr == "{}")
                  exStr = ex
               let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr
               uni.showModal({
                  title: this.translateSys("error"),
                  content: tip,
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               showError(ex, this.translateSys("error"));
            }
         },
@@ -460,12 +425,7 @@
               });
               if (list.length == 0) {
                  uni.showModal({
                     title: this.translate("get_classes_fail"),
                     content: this.translate("page.please_login_after_admin_add_classes"),
                     showCancel: false,
                     confirmText: this.translateSys('close')
                  });
                  showInfo(this.translate("page.please_login_after_admin_add_classes"));
                  this.selectedClasses = ""
               } else {
                  if (this.selectedClasses) {
@@ -483,17 +443,8 @@
            } catch (ex) {
               let exStr = JSON.stringify(ex)
               if (exStr == "{}")
                  exStr = ex
               let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr
               uni.showModal({
                  title: this.translate("get_classes_fail"),
                  content: tip,
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               showError(ex, this.translateSys("error"));
               this.selectedClasses = ""
               this.classesLst = []
               // {
@@ -519,6 +470,7 @@
         clickSelectClass(item) {
            this.selectedClasses = item.text
         },
         translate(t) {
            if (typeof this.$t == "function") return this.$t(`page.${t}`)
            else return t;
@@ -534,7 +486,8 @@
         var url = utils.session.getValue('server');
         var username = utils.session.getValue('account');
         var userpwd = utils.session.getValue('password');
         this.largeMode = utils.session.getValue('large_mode') ? true : false
         getApp().globalData.largeMode = this.largeMode
         var ischecked = false;
         if (!this.userServer)
            this.userServer = url;
@@ -589,7 +542,8 @@
      background-repeat: no-repeat !important; */
      }
      .SetServer {
      .set-language,
      .set-server {
         float: left;
         margin-left: 20rpx;
      }
@@ -666,32 +620,14 @@
      .mui-input-row input {
         font-family: 'Helvetica Neue', Helvetica, sans-serif;
         font-size: 15px;
         width: 480rpx;
         /* float: right; */
         margin-bottom: 0;
         padding-left: 20rpx;
         /* padding-right: 10rpx; */
         /* line-height: 30rpx; */
         height: 85rpx;
         /* padding: 7px 40px 7px 0px; */
         -webkit-user-select: text;
         /* border: 0; */
         /* border-radius: 0; */
         box-shadow: none;
         outline: 0;
         background: 0 0;
         -webkit-appearance: none;
      }
      .mui-input-group label.mui-navigate-right {
         font-size: 25px;
         float: right;
         padding: 0;
         width: 80rpx;
         margin-right: 5rpx;
         margin-top: -88rpx;
         display: inline-block;
      }
      button.btn_login {
@@ -723,4 +659,11 @@
      }
   }
   .uni-page-login.large-mode {
      .logo_input {
         height: 54rpx;
         width: 54rpx;
      }
   }
</style>