Junjie
2024-11-09 a2019ade7b884799e639150021c3cdeef27eea72
pages/LoginDemo/LoginDemo.vue
@@ -30,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="请输入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="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>
@@ -71,22 +71,10 @@
            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: '登录'
@@ -135,6 +123,10 @@
            this.$refs.settings.close()
         },
         async login() {
            // uni.reLaunch({
            //    url: `/pages/project/jmAGV/home`,
            // });
            // return
            if (!uni.getStorageSync('Network')) {
               uni.showToast({ icon: 'error', title: '请配置网络信息' }) 
               return
@@ -149,7 +141,9 @@
            }
            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({
@@ -157,13 +151,13 @@
                  })
                  setTimeout(() => {
                     uni.reLaunch({
                        url: `/pages/home/home`,
                        url: `/pages/project/jmAGV/home`,
                     });
                  }, 300)
                  if (!this.remberPassword) {
                     this.user.password = ''
                  }
                  uni.setStorageSync('user', this.user);
                  // uni.setStorageSync('user', this.user);
               }, 700)
            } else if (res.code === 0) {
               this.load.loading = false;