From a2019ade7b884799e639150021c3cdeef27eea72 Mon Sep 17 00:00:00 2001 From: Junjie <xjj@123> Date: 星期六, 09 十一月 2024 11:40:52 +0800 Subject: [PATCH] 增加工号ui修改 --- pages/LoginDemo/LoginDemo.vue | 134 +++++++++++++++++++++----------------------- 1 files changed, 63 insertions(+), 71 deletions(-) diff --git a/pages/LoginDemo/LoginDemo.vue b/pages/LoginDemo/LoginDemo.vue index 53318bc..9c0a9d4 100644 --- a/pages/LoginDemo/LoginDemo.vue +++ b/pages/LoginDemo/LoginDemo.vue @@ -19,10 +19,7 @@ <switch :checked='remberPassword' color="#FFCC33" style="zoom:.5" @change="remberChange" /> </view> </view> - <!-- <view class="button" @click="login" :loading="load.loading"> - {{load.btnText}} - </view> --> - <button class="button" @click="onLogin()" :loading="load.loading">{{load.btnText}}</button> + <button class="button" @click="login()" :loading="load.loading">{{load.btnText}}</button> </view> <!-- 璁剧疆寮圭獥鍖哄煙 --> <uni-popup ref="settings" type="dialog"> @@ -33,11 +30,11 @@ <view class="scroll-item" v-for="net in network"> <view class="item-title" style="">{{net.name}}</view> <view style="display: flex;align-items: center;"> - <input class="settings-input1" type="text" v-model="net.ip"> + <input class="settings-input1" type="text" v-model="net.ip" placeholder="璇疯緭鍏p"> <text style="font-weight: 900;">:</text> - <input class="settings-input2" type="text" v-model="net.port"> + <input class="settings-input2" type="text" v-model="net.port" placeholder="璇疯緭鍏ョ鍙�"> <text style="font-weight: 900;">/</text> - <input class="settings-input3" type="text" v-model="net.address"> + <input class="settings-input3" type="text" v-model="net.address" placeholder="璇疯緭鍏ュ湴鍧�"> </view> </view> </scroll-view> @@ -67,28 +64,17 @@ mapState } from 'vuex' //寮曞叆mapState import md5 from '../../static/js/md5.js' + import common from '../api/common/common.js' export default { data() { return { version: '', remberPassword: true, user: { - username: '1', - password: '2' + username: '', + password: '' }, - network: [{ - name: 'wms', - ip: '192.168.1.1', - port: '8080', - address: 'pswms' - }, - { - name: 'wcs', - ip: '192.168.1.1', - port: '9090', - address: 'pswcs' - } - ], + network: [{}], load: { loading: false, btnText: '鐧诲綍' @@ -112,15 +98,16 @@ } // 鎵嬫満绔増鏈彿 // #ifdef APP-PLUS - var that = this + var _this = this plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) { - that.version = wgtinfo.version + _this.version = wgtinfo.version }); // #endif }, methods: { remberChange() { - + this.remberPassword = !this.remberPassword + }, settings() { if (uni.getStorageSync('Network')) { @@ -135,55 +122,60 @@ uni.setStorageSync('Network', this.network); this.$refs.settings.close() }, - onLogin() { - let _this = this, - path = 'demo', - network = uni.getStorageSync('Network'); - if (!network) { + async login() { + // uni.reLaunch({ + // url: `/pages/project/jmAGV/home`, + // }); + // return + if (!uni.getStorageSync('Network')) { + uni.showToast({ icon: 'error', title: '璇烽厤缃綉缁滀俊鎭�' }) + return + } + if (!this.user.username ) { + uni.showToast({ icon: 'none', title: '璇疯緭鍏ヨ处鍙�' }) + return + } + if (!this.user.password ) { + uni.showToast({ icon: 'none', title: '璇疯緭鍏ュ瘑鐮�' }) + return + } + this.load.loading = true; + this.load.btnText = '鐧诲綍涓�'; + uni.setStorageSync('user', this.user); + let res = await common.onLogin(this.user) + console.log(res); + if (res.code === 200) { + setTimeout(() => { + uni.showToast({ + title: '鐧诲綍鎴愬姛' + }) + setTimeout(() => { + uni.reLaunch({ + url: `/pages/project/jmAGV/home`, + }); + }, 300) + if (!this.remberPassword) { + this.user.password = '' + } + // uni.setStorageSync('user', this.user); + }, 700) + } else if (res.code === 0) { + this.load.loading = false; + this.load.btnText = '鐧诲綍'; uni.showToast({ - icon: 'error', - title: '璇烽厤缃綉缁滀俊鎭�' + icon: 'none', + title: '杩炴帴澶辫触锛岃妫�鏌ョ綉缁�' + }) + } else { + this.load.loading = false; + this.load.btnText = '鐧诲綍'; + uni.showToast({ + icon: 'none', + title: `${this.user.username} ${res.msg}` }) } - // path = network[0].address - // path = path.substring(0, path.length - 3); - path = _this.project.name - let baseUrl = `http://${network[0].ip}:${network[0].port}/${network[0].address}` - _this.load.loading = true; - _this.load.btnText = '鐧诲綍涓�'; - uni.setStorageSync('user', _this.user); - uni.request({ - url: `${baseUrl}/login.action`, - data: { - username: _this.user.username, - password: md5.hex_md5(_this.user.password) - }, - success(res) { - res = res.data - if (res.code === 200) { - uni.setStorageSync('token', res.data.token); - _this.load.btnText = '鐧诲綍涓�'; - setTimeout(() => { - uni.showToast({ - title: '鐧诲綍鎴愬姛' - }) - setTimeout(() => { - uni.reLaunch({ - url: `/pages/home/home`, - }); - }, 300) - }, 700) - } - // uni.navigateTo({ - // url: `/pages/project/${path}/home/home`, - // fail(res) { - // console.log(`娌℃湁${path}椤圭洰,璇疯仈绯荤鐞嗗厓`); - // } - - // }) - } - }) - } + }, + // end } } </script> -- Gitblit v1.9.1