From df481aebfb7a19eea5d6c02f93c6f5776b0fdc19 Mon Sep 17 00:00:00 2001 From: cuiqian2004 <cuiqian2004@163.com> Date: 星期五, 23 五月 2025 18:30:41 +0800 Subject: [PATCH] 界面大模式 --- pages/login/index.vue | 516 ++++++++++++++++++++++++++++++++------------------------- 1 files changed, 288 insertions(+), 228 deletions(-) diff --git a/pages/login/index.vue b/pages/login/index.vue index ec27e9d..0406e93 100644 --- a/pages/login/index.vue +++ b/pages/login/index.vue @@ -1,5 +1,5 @@ <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> @@ -8,18 +8,11 @@ <a href="javascript:;" class="SetServer" @click="inputDialogToggle">{{translateSys('set')}}</a> <a href="javascript:;" class="SetServer" @click="clickSetLanguage">{{translateSys('language')}}</a> - - <!-- <div class="mui-input-row"> - <label class="la_icon"><image class="logo_input" src="../../images/login/svr_30.png"></image></label> - <input type="text" class="mui-input" v-model="userServer" placeholder="鏈嶅姟鍣ㄥ湴鍧�> - <label class="mui-navigate-right" id="sersel"><image class="logo_icon" src="../../images/login/sel_left.png" ></image></label> - </div> --> <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"> @@ -35,7 +28,8 @@ </label> </checkbox-group> </form> - <button id='login' type="default" @tap="logind" class="btn_login">{{translateSys("start_login")}}</button> + <button id='login' :disabled="btnLoading" type="default" @tap="onClickLogin" + class="btn_login">{{translateSys("start_login")}}</button> <p style="float:right; margin: 10px 10px;color:#c8c7cc"> <span>{{translateSys('version')}}锛�/span> <span>{{version}}</span> @@ -48,7 +42,7 @@ <!-- 杈撳叆妗嗙ず渚�--> <uni-popup ref="inputDialog" type="dialog"> <uni-popup-dialog ref="inputClose" mode="input" :title="translateSys('set')" :value="userServer" - :placeholder="translate('input_server')" @confirm="dialogInputConfirm"></uni-popup-dialog> + :placeholder="translate('input_server')" @confirm="dialogInputConfirm"></uni-popup-dialog> </uni-popup> <!-- 鐗堟湰鍗囩骇寮圭獥寮� --> <uni-popup ref="promotion" type="center"> @@ -69,8 +63,23 @@ </view> </uni-popup> <!-- 鐗堟湰鍗囩骇寮圭獥缁撴潫 --> + <uni-popup ref="refClassDialog" type="dialog"> + <uni-popup-dialog mode="info" :title="$t('page.bind_classes')" @confirm="dialogClassConfirm"> + <view class="popup-class"> + <view class="popup-class-item" :style="{color:item.text == selectedClasses ? '#27A6E1' :''}" + v-for="(item,index) in classesLst" :key="index" @click="clickSelectClass(item)"> + <view class="ico"><uni-icons v-if="item.text == selectedClasses" type="checkmarkempty" + :color="item.text == selectedClasses ? '#27A6E1' :''" size="24"></uni-icons></view> + {{item.text}} + </view> + </view> + </uni-popup-dialog> + </uni-popup> </view> - + <!-- <button @click="onClickWms">鐧诲綍wms</button> + <view class="webview"> + <web-view ref="webview" src="http://115.29.185.26:5000/mobox3/#/"></web-view> + </view> --> </view> </template> @@ -83,8 +92,18 @@ showLoading, hideLoading } from "@/js/Page.js" + import { + isMobox3Web, + login, + getApkVersionInfo + } from "@/api/index.js" + import buttonClickMixin from '@/mixins/button-click.js'; + import { + dictGetInfo + } from "@/api/mobox.js" import utils from "@/js/utils.js" export default { + mixins: [buttonClickMixin], components: { cmdProgress }, @@ -99,6 +118,11 @@ downloadUrl: "", //瀹夊崜app涓嬭浇閾炬帴 percentage: 0, //涓嬭浇杩涘害 showBtns: true, + selectedClasses: "", + classesLst: [], + largeMode: false, + + } }, onShow() { @@ -133,113 +157,43 @@ }, //妫�祴鏄惁闇�鏇存柊 async check(version) { - if (!this.userServer) { - uni.showModal({ - title: this.translateSys("tip"), - content: this.translate("tip_no_web_server"), - showCancel: false, - confirmText: this.translateSys('cancel') - }); - return; - } - var ser = this.userServer.toLowerCase().split('/'); - var translateSyshis = this; - var rootUrl = 'http://' + this.userServer - if (this.userServer.includes("://")) { - rootUrl = this.userServer - } - if (ser[ser.length - 1] == 'mobox3') { //鍒ゆ柇褰撳墠缃戝潃鏄惁鏄痬obox3 - var url = rootUrl + '/Program/version.txt'; - console.log(url); - uni.request({ - url: url, // 鎸囧畾JS鏂囦欢鐨勫畬鏁磋矾寰�- method: 'GET', - success(res) { - console.log(res); - if (res && res.statusCode === 200) { - //鑾峰彇褰撳墠鐗堟湰鍙�- var VersionName = res.data; //鏇存柊鍖呭悕绉�- var versionInfo = res.data.split('_'); - var versionNum = versionInfo[2].replace(".apk", ""); //鐗堟湰缂栫爜 - var VersionCode = versionInfo[2].replace(".apk", "").replace(".", "").replace( - ".", ""); //鏈嶅姟绔増鏈彿 - // this.downloadUrl = resp.PdaUrl+"/"+VersionName; //app涓嬭浇閾炬帴 - - translateSyshis.downloadUrl = rootUrl+ "/Program/" + - VersionName; //app涓嬭浇閾炬帴this. - var isver = translateSyshis.compare(versionNum, version); - if (isver) { - translateSyshis.$refs.promotion.open(); - } else { - console.log('褰撳墠宸叉槸鏈�柊鐗堟湰') - } - } else { - // if(res.statusCode === 404){ - // uni.showModal({ - // title: "鎻愮ず", - // content: '璇锋眰澶辫触锛屾壘涓嶅埌鏇存柊鍖呯増鏈枃妗o細'+url, - // showCancel: false, - // confirmText: "鍙栨秷" - // }); - // } - } - }, - fail(err) { - // 閿欒澶勭悊閫昏緫 - uni.showModal({ - title: this.translateSys('error'), - content: this.translate('tip_get_file_fail_first') + "'" + url + "'" + - this.translate('tip_get_file_fail_last') + "\n" + err, - showCancel: false, - confirmText: this.translateSys('cancel') - }); - } - }); - } else { - var dataInfo = { - server: rootUrl - }; - this.$store.dispatch('GetApkVersionInfo', dataInfo).then(success => { - console.log(success); - if (success.code == '00000') { - let resp = success.data; - if (resp) { - // const obj = resp.data.filter(item => { - // return item.groupName == 'version' - // }) - //鑾峰彇褰撳墠鐗堟湰鍙�- const VersionName = resp.VersionName; //鏇存柊鍖呭悕绉�- const VersionCode = resp.VersionCode; //鐗堟湰缂栫爜 - const versionNum = resp.Version; //鏈嶅姟绔増鏈彿 - // this.downloadUrl = resp.PdaUrl+"/"+VersionName; //app涓嬭浇閾炬帴 - translateSyshis.downloadUrl = rootUrl+ - "/Program/" + - VersionName; //app涓嬭浇閾炬帴this. - var isver = translateSyshis.compare(versionNum, version); - if (isver) { - translateSyshis.$refs.promotion.open(); - } else { - console.log('褰撳墠宸叉槸鏈�柊鐗堟湰') - } - } - } else { - uni.showModal({ - title: this.translateSys('error'), - content: success.msg, - showCancel: false, - confirmText: this.translateSys('cancel') - }); - } - }).catch(ex => { - console.log(ex); + try { + if (!this.userServer) { uni.showModal({ - title: this.translateSys('error'), - content: ex.errMsg ? ex.errMsg : ex.message, + title: this.translateSys("tip"), + content: this.translate("tip_no_web_server"), showCancel: false, - confirmText: this.translateSys('cancel') + confirmText: this.translateSys('close') }); + return; + } + // var ser = this.userServer.toLowerCase().split('/'); + const res = await getApkVersionInfo(this.userServer) + this.downloadUrl = res.dldUrl || "" + if (this.downloadUrl) { + var isver = this.compare(res.verNum || "", version); + if (isver) { + this.$refs.promotion.open(); + } else { + console.log('褰撳墠宸叉槸鏈�柊鐗堟湰') + } + } + + } 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') }); } + + }, compare(curV, reqV) { var arr1 = curV.toString().split('.'); @@ -334,7 +288,20 @@ // actionLogin:'login' // }), inputDialogToggle() { - this.$refs.inputDialog.open() + // 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({ @@ -359,11 +326,12 @@ // }, 3000) // }, 3000) }, + rememberPwd(e) { //璁颁綇瀵嗙爜 console.log(e.target); utils.session.setValue('account', ''); utils.session.setValue('password', ''); - if (e.target.value[0] == '1') { + if (e.detail.value[0] == '1') { utils.session.setValue('account', this.userName); utils.session.setValue('password', this.userPwd); } @@ -387,95 +355,174 @@ // ((expiredays==null)?'':';expires='+exdate.toGMTString()); // }, - logind() { - if (!this.userServer) { - uni.showModal({ - title: this.translateSys('tip'), - content: this.translate('tip_no_web_server'), - showCancel: false, - confirmText: this.translateSys('cancel') - }); - return; - } - if (!this.userName) { - uni.showModal({ - title: this.translateSys('tip'), - content: this.translate('tip_no_user_account'), - showCancel: false, - confirmText: this.translateSys('cancel') - }); - return; - } - if (!this.userPwd) { - uni.showModal({ - title: this.translateSys('tip'), - content: this.translate('tip_no_user_password'), - showCancel: false, - confirmText: this.translateSys('cancel') - }); - return; - } - var rootUrl = 'http://' + this.userServer - if (this.userServer.includes("://")) { - rootUrl = this.userServer - } - //妫�煡 "鐧诲綍鐘舵�/閿佸睆鐘舵�" 缁撴潫 - var loginInfo = { - server:rootUrl, - uname: this.userName, - pwd: this.userPwd, - cname: plus.device.model, - type: "0" - }; - console.log(loginInfo); - showLoading("loading......") - //鐧诲綍 - this.$store.dispatch('login', loginInfo).then(success => { - console.log(success); - if (success.code == '00000' || success.err_code == 0) { - //鐧诲綍鎴愬姛鍚庢竻绌虹紦瀛樻暟鎹�- this.$store.commit("areaFunc", null); - this.$store.commit("classAttrList", null); - this.$store.commit("classGridStyleInfo", null); - this.$store.commit("dicValueInfo", null); - this.$store.commit("subClassAttrList", null); - this.$store.commit("subClassGridStyleInfo", null); - //璁剧疆鍏ㄥ眬鍙傛暟锛歶ser-鐢ㄦ埛淇℃伅 - utils.session.setValue('server', loginInfo.server); - utils.session.setValue('account', loginInfo.uname); - utils.session.setValue('password', loginInfo.pwd); - // this.mutatLogin({loginid:success}); - this.$store.commit('login', { - loginid: success - }); - hideLoading() - uni.navigateTo({ - url: '../index/index?args=9999999999' - }) - // uni.redirectTo({ - // url:'../index/index?args=9999999999' - // }); - - - } else { - hideLoading() - uni.showModal({ - title: this.translateSys('error'), - content: success.msg, - showCancel: false, - confirmText: this.translateSys('cancel') - }); - } - }).catch(ex => { - console.log(ex); - hideLoading() - uni.showModal({ - title: this.translateSys('error'), - content: ex.errMsg, - showCancel: false, - confirmText: this.translateSys('cancel') - }); + onClickLogin() { + this.handleButtonClick((done) => { + this.logind() + setTimeout(() => { + done(); // 閲嶇疆鐘舵� + }, 1000); }); + }, + 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') + }); + return; + } + if (!this.userName) { + uni.showModal({ + title: this.translateSys('tip'), + content: this.translate('tip_no_user_account'), + showCancel: false, + confirmText: this.translateSys('close') + }); + return; + } + if (!this.userPwd) { + uni.showModal({ + title: this.translateSys('tip'), + content: this.translate('tip_no_user_password'), + showCancel: false, + confirmText: this.translateSys('close') + }); + return; + } + var rootUrl = 'http://' + this.userServer + if (this.userServer.includes("://")) { + rootUrl = this.userServer + } + showLoading("loading......") + const res = await login(rootUrl, this.userName, this.userPwd) + //璁剧疆鍏ㄥ眬鍙傛暟锛歶ser-鐢ㄦ埛淇℃伅 + utils.session.setValue('server', rootUrl); + utils.session.setValue('account', this.userName); + utils.session.setValue('password', this.userPwd); + const app = getApp() + app.globalData.sessionId = res.session_id + app.globalData.loginUser = { + id: this.userName, + name: res.name, + pwd: this.userPwd + } + hideLoading() + const bindInfo = utils.session.getValue('bind_classes') + app.globalData.bindClasses = bindInfo?.checked || false + if (app.globalData.bindClasses) { + this.selectedClasses = bindInfo?.classes || "" + await this.loadClassesList() + if (this.classesLst.length > 0) { + this.$refs.refClassDialog.open() + + } + return + } + uni.navigateTo({ + url: '../index/index?args=9999999999' + }) + + + + } 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') + }); + } + + }, + onClickWms() { + let otherAppSchemeURL = "testapp://pages/index/index"; // 鏇挎崲涓虹洰鏍嘺pp鐨剆cheme URL + plus.runtime.openURL(otherAppSchemeURL, function(error) { + console.error('鎵撳紑搴旂敤澶辫触: ', error); + }, "uni.TeatApp"); + }, + async loadClassesList() { + try { + var $this = this; + var dataInfo = { + dict_id: "", + dict_name: "WMS_CLASSES" + }; + const res = await dictGetInfo(dataInfo) + var list = []; + (res.dict_item_list || []).forEach((item) => { + list.push({ + text: item.value ? item.value : item.name, + value: item.name, + }); + }); + + 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') + }); + this.selectedClasses = "" + } else { + if (this.selectedClasses) { + const curIndex = list.findIndex((a) => { + return a.text == this.selectedClasses + }) + if (curIndex < 0) { + this.selectedClasses = list[0].text + } + } else { + this.selectedClasses = list[0].text + } + } + this.classesLst = list + + + } 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') + }); + + this.selectedClasses = "" + this.classesLst = [] + // { + // text: "娴嬭瘯", + // value: "test" + // }, { + // text: "娴嬭瘯3", + // value: "test3" + // } + } + }, + dialogClassConfirm() { + + utils.session.setValue('bind_classes', { + checked: true, + classes: this.selectedClasses + }) + getApp().globalData.classes = this.selectedClasses + uni.navigateTo({ + url: '../index/index?args=9999999999' + }) + }, + clickSelectClass(item) { + this.selectedClasses = item.text }, translate(t) { if (typeof this.$t == "function") return this.$t(`page.${t}`) @@ -486,11 +533,14 @@ else return t; }, }, - onLoad() { + onLoad(options) { //鑾峰彇mac鍦板潃 - var url = this.$store.state.url; - var username = this.$store.state.username; - var userpwd = this.$store.state.userpwd; + + 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; @@ -517,13 +567,13 @@ } deviceId += tmp; } + getApp().globalData.deviceId = deviceId + getApp().globalData.cname = plus.device.model //78b8d67511ca - this.$store.commit("setDeviceId", deviceId); console.log('Android璁惧鐨刣eviceId:', deviceId); - plus.runtime.getProperty(plus.runtime.appid, (info) => { // console.log(info); - this.$data.version = info.version; + this.version = info.version; }); } } @@ -622,32 +672,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 { @@ -658,5 +690,33 @@ border: none; color: #fff; } + + .popup-class { + display: flex; + flex-direction: column; + width: 100%; + + .popup-class-item { + padding: 20rpx 0; + border-bottom: 1px solid #eee; + display: flex; + flex-direction: row; + + .ico { + width: 20px; + margin: 0 20rpx; + + } + } + + } } + + .uni-page-login.large-mode{ + .logo_input { + height: 54rpx; + width: 54rpx; + } + } + </style> \ No newline at end of file -- Gitblit v1.9.1