| | |
| | | <switch :checked='remberPassword' color="#FFCC33" style="zoom:.5" @change="remberChange" /> |
| | | </view> |
| | | </view> |
| | | <button class="button" @click="login()" :loading="load.loading">{{load.btnText}}</button> |
| | | <button class="button" @click="onLogin()" :loading="load.loading">{{load.btnText}}</button> |
| | | </view> |
| | | <!-- 设置弹窗区域 --> |
| | | <uni-popup ref="settings" type="dialog"> |
| | |
| | | <!-- 标题 --> |
| | | <view class="title">网 络 配 置</view> |
| | | <scroll-view scroll-y="true" class="settings-scroll"> |
| | | <view class="scroll-item" v-for="net in network"> |
| | | <view class="item-title" style="">{{net.name}}</view> |
| | | <view class="scroll-item"> |
| | | <view class="item-title" style="">{{network.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="network.ip"> |
| | | <text style="font-weight: 900;">:</text> |
| | | <input class="settings-input2" type="text" v-model="net.port"> |
| | | <input class="settings-input2" type="text" v-model="network.port"> |
| | | <text style="font-weight: 900;">/</text> |
| | | <input class="settings-input3" type="text" v-model="net.address"> |
| | | <input class="settings-input3" type="text" v-model="network.address"> |
| | | </view> |
| | | </view> |
| | | </scroll-view> |
| | |
| | | |
| | | <script> |
| | | // import { data } from 'jquery' |
| | | import { |
| | | mapState |
| | | } from 'vuex' //引入mapState |
| | | import { mapState } from 'vuex' //引入mapState |
| | | import store from '@/store/index.js'; |
| | | import md5 from '../../static/js/md5.js' |
| | | import common from '../api/common/common.js' |
| | | import login from '../api/login/login.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: { |
| | | name: 'wms', |
| | | ip: '192.168.1.1', |
| | | port: '8080', |
| | | address: 'pswms' |
| | | }, |
| | | load: { |
| | | loading: false, |
| | | btnText: '登录' |
| | |
| | | } |
| | | }, |
| | | computed: mapState({ |
| | | project: state => state.project |
| | | project: state => state.project, |
| | | |
| | | }), |
| | | onShow() { |
| | | |
| | | }, |
| | | mounted() { |
| | | uni.getSystemInfo({ |
| | | success(res) { |
| | | // console.log(res); |
| | | } |
| | | }) |
| | | if (uni.getStorageSync('user')) { |
| | | this.user = uni.getStorageSync('user') |
| | | } |
| | | // 从 state 获取网络信息 |
| | | // 从 state 获取账号信息 |
| | | console.log(store.state); |
| | | this.user = store.state.userInfo |
| | | this.network = store.state.network |
| | | // 手机端版本号 |
| | | // #ifdef APP-PLUS |
| | | var _this = this |
| | |
| | | methods: { |
| | | remberChange() { |
| | | this.remberPassword = !this.remberPassword |
| | | |
| | | }, |
| | | settings() { |
| | | if (uni.getStorageSync('Network')) { |
| | | this.network = uni.getStorageSync('Network') |
| | | } |
| | | this.$refs.settings.open() |
| | | |
| | | }, |
| | | cancel() { |
| | | this.$refs.settings.close() |
| | | }, |
| | | confirm() { |
| | | uni.setStorageSync('Network', this.network); |
| | | let baseUrl = `http://${this.network.ip}:${this.network.port}/${this.network.address}` |
| | | this.$store.commit("setNetwork", this.network); |
| | | this.$store.commit("setBaseUrl", baseUrl); |
| | | this.$refs.settings.close() |
| | | }, |
| | | async login() { |
| | | if (!uni.getStorageSync('Network')) { |
| | | uni.showToast({ icon: 'error', title: '请配置网络信息' }) |
| | | return |
| | | } |
| | | async onLogin() { |
| | | // 验证ip信息 |
| | | // 验证账号信息 |
| | | if (!this.user.username ) { |
| | | uni.showToast({ icon: 'none', title: '请输入账号' }) |
| | | return |
| | |
| | | } |
| | | this.load.loading = true; |
| | | this.load.btnText = '登录中'; |
| | | let res = await common.onLogin(this.user) |
| | | let res = await login.onLogin(this.user) |
| | | if (res.code === 200) { |
| | | setTimeout(() => { |
| | | uni.showToast({ |
| | |
| | | if (!this.remberPassword) { |
| | | this.user.password = '' |
| | | } |
| | | uni.setStorageSync('user', this.user); |
| | | // uni.setStorageSync('user', this.user); |
| | | this.$store.commit("setUserInfo", this.user); |
| | | }, 700) |
| | | } else if (res.code === 0) { |
| | | this.load.loading = false; |
| | | this.load.btnText = '登录'; |
| | | uni.showToast({ |
| | | icon: 'none', |
| | | title: '连接失败,请检查网络' |
| | | title: '连接失败,请检查设备网络/IP地址是否正确!' |
| | | }) |
| | | } else { |
| | | this.load.loading = false; |
| | |
| | | }) |
| | | } |
| | | }, |
| | | // end |
| | | } |
| | | } |
| | | </script> |