panxingxin 5 rokov pred
rodič
commit
24b64a8d45

+ 2 - 2
src/app/app.component.ts

@@ -176,7 +176,7 @@ export class AppComponent {
     });
     this.events.subscribe('update:refuse', () => {
       navigator['app'].exitApp();
-      this.storage.clear()
+      this.userData.clear()
     });
   }
   async logout() {
@@ -221,7 +221,7 @@ export class AppComponent {
           text: '退出',
           handler: () => {
             navigator['app'].exitApp();
-            this.storage.clear()
+            this.userData.clear()
           }
         }
       ]

+ 13 - 0
src/app/login/login.page.ts

@@ -41,7 +41,19 @@ export class LoginPage extends BaseUI {
   }
   loginInfo = { account: '', password: '' };
   errorMessage: any;
+
+  ionViewDidEnter() {
+    this.storage.get("loginInfo").then((value)=>{
+      this.loginInfo.account = value.loginName
+      this.loginInfo.password = value.password
+    })
+  }
+
   async login(form: NgForm) {
+    this.storage.set('loginInfo', {
+      loginName: this.loginInfo.account,
+      password: this.loginInfo.password
+    })
     const user = this.encryption({
       data: this.loginInfo,
       key: 'pigxpigxpigxpigx',
@@ -52,6 +64,7 @@ export class LoginPage extends BaseUI {
       this.userData.login(user.account, user.password);
     }
   }
+  
   /**
  *加密处理
  */

+ 66 - 57
src/providers/user-data.ts

@@ -136,6 +136,7 @@ export class UserData {
           role: 'cancel',
           cssClass: 'secondary',
           handler: () => {
+            this.clear()
             this.router.navigateByUrl('/login');
             return this.storage.remove(this.HAS_LOGGED_IN).then(async () => {
             }).then(() => {
@@ -148,7 +149,6 @@ export class UserData {
       ]
     });
     await alert.present();
-    return this.storage.clear();
   }
 
   // 开单号扫描
@@ -589,7 +589,7 @@ export class UserData {
   }
 
   // 获取入库单列表
-  async geteEnterStoreList(code:string,size:number): Promise<any> {
+  async geteEnterStoreList(code: string, size: number): Promise<any> {
     const token = await this.getToken();
     const loading = await this.loadingCtrl.create();
     await loading.present();
@@ -600,7 +600,7 @@ export class UserData {
         headers)).pipe(
           finalize(() => loading.dismiss())
         ).subscribe(async data => {
-          if (JSON.parse(data.data).code===1) {
+          if (JSON.parse(data.data).code === 1) {
             const toast = await this.toastCtrl.create({
               message: JSON.parse(data.data).msg,
               duration: 1000,
@@ -622,39 +622,39 @@ export class UserData {
     });
   }
 
-    // 获取入库单详情
-    async geteEnterStoreDetail(entergoodsid:string): Promise<any> {
-      const token = await this.getToken();
-      const loading = await this.loadingCtrl.create();
-      await loading.present();
-      this.nativeHttp.setDataSerializer('json');
-      const headers = { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json;charset=UTF-8' };
-      return new Promise((resolve, reject) => {
-        from(this.nativeHttp.get(`${environment.APP_SERVE_URL}/inventory/enterStore/mobile/${entergoodsid}`, {},
-          headers)).pipe(
-            finalize(() => loading.dismiss())
-          ).subscribe(async data => {
-            if (JSON.parse(data.data).code===1) {
-              const toast = await this.toastCtrl.create({
-                message: JSON.parse(data.data).msg,
-                duration: 1000,
-                position: 'top'
-              });
-              await toast.present();
-              resolve([]);
-            }
-            resolve(JSON.parse(data.data));
-          }, async err => {
-            console.log(err);
+  // 获取入库单详情
+  async geteEnterStoreDetail(entergoodsid: string): Promise<any> {
+    const token = await this.getToken();
+    const loading = await this.loadingCtrl.create();
+    await loading.present();
+    this.nativeHttp.setDataSerializer('json');
+    const headers = { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json;charset=UTF-8' };
+    return new Promise((resolve, reject) => {
+      from(this.nativeHttp.get(`${environment.APP_SERVE_URL}/inventory/enterStore/mobile/${entergoodsid}`, {},
+        headers)).pipe(
+          finalize(() => loading.dismiss())
+        ).subscribe(async data => {
+          if (JSON.parse(data.data).code === 1) {
             const toast = await this.toastCtrl.create({
-              message: '获取失败',
+              message: JSON.parse(data.data).msg,
               duration: 1000,
               position: 'top'
             });
             await toast.present();
+            resolve([]);
+          }
+          resolve(JSON.parse(data.data));
+        }, async err => {
+          console.log(err);
+          const toast = await this.toastCtrl.create({
+            message: '获取失败',
+            duration: 1000,
+            position: 'top'
           });
-      });
-    }
+          await toast.present();
+        });
+    });
+  }
 
   // 获取入库详情
   async getStoreDetail(sscId: number, pId: number): Promise<any> {
@@ -1057,39 +1057,39 @@ export class UserData {
     });
   }
 
-    // 查询样品
-    async getStoreSampleByCode(code: string): Promise<any> {
-      const token = await this.getToken();
-      const loading = await this.loadingCtrl.create();
-      await loading.present();
-      this.nativeHttp.setDataSerializer('json');
-      const headers = { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json;charset=UTF-8' };
-      return new Promise((resolve, reject) => {
-        from(this.nativeHttp.get(`${environment.APP_SERVE_URL}/inventory/shelf/mobile/code`, {code:code},
-          headers)).pipe(
-            finalize(() => loading.dismiss())
-          ).subscribe(async data => {
-            if (JSON.parse(data.data).code == 1) {
-              const toast = await this.toastCtrl.create({
-                message: JSON.parse(data.data).msg,
-                duration: 1000,
-                position: 'top'
-              });
-              await toast.present();
-              resolve([]);
-            }
-            resolve(JSON.parse(data.data));
-          }, async err => {
-            console.log(err);
+  // 查询样品
+  async getStoreSampleByCode(code: string): Promise<any> {
+    const token = await this.getToken();
+    const loading = await this.loadingCtrl.create();
+    await loading.present();
+    this.nativeHttp.setDataSerializer('json');
+    const headers = { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json;charset=UTF-8' };
+    return new Promise((resolve, reject) => {
+      from(this.nativeHttp.get(`${environment.APP_SERVE_URL}/inventory/shelf/mobile/code`, { code: code },
+        headers)).pipe(
+          finalize(() => loading.dismiss())
+        ).subscribe(async data => {
+          if (JSON.parse(data.data).code == 1) {
             const toast = await this.toastCtrl.create({
-              message: '查询失败',
+              message: JSON.parse(data.data).msg,
               duration: 1000,
               position: 'top'
             });
             await toast.present();
+            resolve([]);
+          }
+          resolve(JSON.parse(data.data));
+        }, async err => {
+          console.log(err);
+          const toast = await this.toastCtrl.create({
+            message: '查询失败',
+            duration: 1000,
+            position: 'top'
           });
-      });
-    }
+          await toast.present();
+        });
+    });
+  }
 
   // 获取待备货列表
   async getWarehouseManagePendingList(current: number, size: number): Promise<any> {
@@ -1421,6 +1421,15 @@ export class UserData {
     });
   }
 
+  clear(): Promise<any> {
+    return this.storage.get('loginInfo').then((value) => {
+      let loginName = value.loginName
+      let password = value.password
+      this.storage.clear()
+      this.storage.set('loginInfo', { loginName: loginName, password: password })
+    })
+  }
+
   isLoggedIn(): Promise<boolean> {
     return this.storage.get(this.HAS_LOGGED_IN).then((value) => {
       return value === true;