陈龙 2 mesi fa
parent
commit
ceda0d6f29

+ 7 - 6
src/Auman.PieceWage.UniApp/App.vue

@@ -8,12 +8,13 @@
             // this.data.screenHeight = info.screenHeight;
             // this.globalData.InnerAudioContext = uni.createInnerAudioContext();
             
-            let res = await login.login();
-            if (!res.success) {
-                uni.navigateTo({
-                    url: '/pages/login/index'
-                });
-            }
+            // let res = await login.login();
+            // if (!res.success) {
+            //     uni.reLaunch({
+            //         url: '/pages/login/index'
+            //     });
+            //     return false;
+            // }
         },
         onShow: function() {
             console.log('App Show');

+ 6 - 0
src/Auman.PieceWage.UniApp/README.md

@@ -1,5 +1,11 @@
 # 开发日志
 
+## 0.1.0 `2025/2/13`
+
+1. 解决无法注销登录的问题。
+2. 解决登陆后页面跳转错误的问题,默认使用 type=reLaunch&page=/pages/home/newhome。
+3. 优化 `pages\login\serverSetting.vue`。
+
 ## 0.1.0 `2025/2/10`
 
 1. 启用新首页。

+ 2 - 2
src/Auman.PieceWage.UniApp/manifest.json

@@ -2,8 +2,8 @@
     "name" : "生产流程管理",
     "appid" : "__UNI__0D07441",
     "description" : "生产流程管理",
-    "versionName" : "0.1.0",
-    "versionCode" : 11,
+    "versionName" : "0.1.1",
+    "versionCode" : 12,
     "transformPx" : false,
     /* 5+App特有相关 */
     "app-plus" : {

+ 13 - 12
src/Auman.PieceWage.UniApp/pages/home/newhome.vue

@@ -25,6 +25,19 @@
             }
         },
         async onShow() {
+            /**
+             * 自动登录
+             */
+            if (!login.logined) {
+                let lres = await login.login();
+                if (!lres.success) {
+                    uni.reLaunch({
+                        url: `/pages/login/index?page=/pages/home/newhome`
+                    });
+                }
+                return false;
+            }
+            
             // #ifdef APP
 
             let baseUrl = url.api;
@@ -68,18 +81,6 @@
             }
 
             // #endif
-
-            /**
-             * 自动登录
-             */
-            if (!login.logined) {
-                let lres = await login.login();
-                if (!lres.success) {
-                    uni.navigateTo({
-                        url: '/pages/login/index'
-                    });
-                }
-            }
         },
         methods: {
             /**

+ 14 - 3
src/Auman.PieceWage.UniApp/pages/login/index.vue

@@ -48,10 +48,11 @@
             if (extend.isObject(opts)) {
                 switch (opts.type) {
                     case 'switchTab':
+                    case 'navigate':
                         this.backType = opts.type;
                         break;
                     default:
-                        this.backType = 'navigateBack';
+                        this.backType = 'reLaunch';
                         break;
                 }
                 if (extend.isNonEmptyString(opts.page)) {
@@ -81,6 +82,11 @@
                 let res = await login.login(data);
                 uni.hideLoading();
                 if (res.success) {
+                    // 登录成功
+                    login.setRemember({
+                        username: this.username,
+                        password: this.password
+                    });
                     this.back();
                 } else {
                     message.error({
@@ -90,16 +96,21 @@
             },
 
             back() {
-                let url = extend.isNonEmptyString(this.prevPage) ? this.prevPage : '/pages/home/index';
+                let url = extend.isNonEmptyString(this.prevPage) ? this.prevPage : '/pages/home/newhome';
                 switch (this.backType) {
                     case 'switchTab':
                         uni.switchTab({
                             url: url
                         });
                         break;
-                    default:
+                    case 'navigate':
                         uni.navigateBack();
                         break;
+                    default:
+                        uni.reLaunch({
+                            url: url
+                        });
+                        break;
                 }
             },
 

+ 11 - 5
src/Auman.PieceWage.UniApp/pages/login/serverSetting.vue

@@ -1,9 +1,15 @@
 <template>
     <view class="flex direction-column padding gap">
-        <uni-easyinput placeholder="认证地址" v-model="authUrl" :disabled="disabledInput"
-            @input="inputChange"></uni-easyinput>
-        <uni-easyinput placeholder="接口地址" v-model="apiUrl" :disabled="disabledInput"
-            @input="inputChange"></uni-easyinput>
+        <view class="flex items-center">
+            <view class="shrink-0">接口:</view>
+            <uni-easyinput class="grow-1" placeholder="认证地址" v-model="authUrl" :disabled="disabledInput"
+                @input="inputChange"></uni-easyinput>
+        </view>
+        <view class="flex items-center">
+            <view class="shrink-0">认证:</view>
+            <uni-easyinput placeholder="接口地址" v-model="apiUrl" :disabled="disabledInput"
+                @input="inputChange"></uni-easyinput>
+        </view>
         <radio-group @change="radioChange">
             <label class="label" v-for="(item, index) in list" :key="item.id">
                 <view>
@@ -171,7 +177,7 @@
                 background-color: #e4fffc;
             }
         }
-        
+
         .url-item+.url-item {
             padding-top: 12upx;
         }

+ 11 - 17
src/Auman.PieceWage.UniApp/pages/my/index.vue

@@ -55,9 +55,7 @@
             if (!login.logined) {
                 let lres = await login.login();
                 if (!lres.success) {
-                    uni.navigateTo({
-                        url: '/pages/login/index'
-                    });
+                    this.openLogin();
                 }
             } else {
                 this.isLogin = true;
@@ -83,24 +81,20 @@
                 });
             },
 
-            logOff() {
+            async logOff() {
                 let _this = this;
-                uni.showModal({
-                    content: '要注销登录吗?',
-                    success(r) {
-                        if (r.confirm) {
-                            token.clear();
-                            user.clear();
-                            user.clearLoginInfo();
-                            _this.login();
-                        }
-                    }
+                let res = await message.alert({
+                    content: '要注销登录吗?'
                 });
+                if (res) {
+                    login.logoff();
+                    this.openLogin();
+                }
             },
 
-            login() {
-                uni.navigateTo({
-                    url: '/pages/login/index?type=switchTab&page=/pages/my/index'
+            openLogin() {
+                uni.reLaunch({
+                    url: `/pages/login/index?page=/pages/my/index`
                 });
             },
 

+ 2 - 2
src/Auman.PieceWage.UniApp/unpackage/dist/build/app-plus/app-config-service.js

@@ -1,8 +1,8 @@
 
   ;(function(){
   let u=void 0,isReady=false,onReadyCallbacks=[],isServiceReady=false,onServiceReadyCallbacks=[];
-  const __uniConfig = {"pages":[],"globalStyle":{"backgroundColor":"#F8F8F8","navigationBar":{"backgroundColor":"#F8F8F8","titleText":"uni-app","type":"default","titleColor":"#000000"},"isNVue":false},"nvue":{"compiler":"uni-app","styleCompiler":"uni-app","flex-direction":"column"},"renderer":"auto","appname":"生产流程管理","splashscreen":{"alwaysShowBeforeRender":true,"autoclose":true},"compilerVersion":"4.45","entryPagePath":"pages/home/index","entryPageQuery":"","realEntryPagePath":"","networkTimeout":{"request":60000,"connectSocket":60000,"uploadFile":60000,"downloadFile":60000},"tabBar":{"position":"bottom","color":"#666666","selectedColor":"#2185d0","borderStyle":"black","blurEffect":"none","fontSize":"10px","iconWidth":"24px","spacing":"3px","height":"50px","list":[{"pagePath":"pages/home/index","text":"首页","iconPath":"/static/tabbar/house.png","selectedIconPath":"/static/tabbar/house_active.png"},{"pagePath":"pages/dispatch/dispatch","text":"派工","iconPath":"/static/tabbar/chart-bar.png","selectedIconPath":"/static/tabbar/chart-bar_active.png"},{"pagePath":"pages/work-order/work-order","text":"报工","iconPath":"/static/tabbar/calendar-check.png","selectedIconPath":"/static/tabbar/calendar-check_active.png"},{"pagePath":"pages/my/index","text":"我","iconPath":"/static/tabbar/user.png","selectedIconPath":"/static/tabbar/user_active.png"}],"selectedIndex":0,"shown":true},"locales":{},"darkmode":false,"themeConfig":{}};
-  const __uniRoutes = [{"path":"pages/home/index","meta":{"isQuit":true,"isEntry":true,"isTabBar":true,"tabBarIndex":0,"navigationBar":{"style":"custom","type":"default"},"isNVue":false}},{"path":"pages/my/index","meta":{"isQuit":true,"isTabBar":true,"tabBarIndex":3,"navigationBar":{"titleText":"我的","type":"default"},"isNVue":false}},{"path":"pages/login/index","meta":{"navigationBar":{"style":"custom","type":"default"},"isNVue":false}},{"path":"pages/login/serverSetting","meta":{"navigationBar":{"titleText":"服务器设置","type":"default"},"isNVue":false}},{"path":"pages/my/protocol","meta":{"navigationBar":{"titleText":"服务协议和隐私政策","type":"default"},"isNVue":false}},{"path":"pages/dispatch/dispatch","meta":{"isQuit":true,"isTabBar":true,"tabBarIndex":1,"enablePullDownRefresh":false,"navigationBar":{"titleText":"派工","type":"default"},"isNVue":false}},{"path":"pages/work-order/work-order","meta":{"isQuit":true,"isTabBar":true,"tabBarIndex":2,"enablePullDownRefresh":false,"navigationBar":{"titleText":"报工","type":"default"},"isNVue":false}},{"path":"pages/workingTeam/select","meta":{"navigationBar":{"titleText":"选择工作组","type":"default"},"isNVue":false}}].map(uniRoute=>(uniRoute.meta.route=uniRoute.path,__uniConfig.pages.push(uniRoute.path),uniRoute.path='/'+uniRoute.path,uniRoute));
+  const __uniConfig = {"pages":[],"globalStyle":{"backgroundColor":"#F8F8F8","navigationBar":{"backgroundColor":"#F8F8F8","titleText":"uni-app","type":"default","titleColor":"#000000"},"isNVue":false},"nvue":{"compiler":"uni-app","styleCompiler":"uni-app","flex-direction":"column"},"renderer":"auto","appname":"生产流程管理","splashscreen":{"alwaysShowBeforeRender":true,"autoclose":true},"compilerVersion":"4.45","entryPagePath":"pages/home/newhome","entryPageQuery":"","realEntryPagePath":"","networkTimeout":{"request":60000,"connectSocket":60000,"uploadFile":60000,"downloadFile":60000},"tabBar":{"position":"bottom","color":"#666666","selectedColor":"#2185d0","borderStyle":"black","blurEffect":"none","fontSize":"10px","iconWidth":"24px","spacing":"3px","height":"50px","list":[{"pagePath":"pages/home/newhome","text":"首页","iconPath":"/static/tabbar/house.png","selectedIconPath":"/static/tabbar/house_active.png"},{"pagePath":"pages/dispatch/dispatch","text":"派工","iconPath":"/static/tabbar/chart-bar.png","selectedIconPath":"/static/tabbar/chart-bar_active.png"},{"pagePath":"pages/work-order/work-order","text":"报工","iconPath":"/static/tabbar/calendar-check.png","selectedIconPath":"/static/tabbar/calendar-check_active.png"},{"pagePath":"pages/my/index","text":"我","iconPath":"/static/tabbar/user.png","selectedIconPath":"/static/tabbar/user_active.png"}],"selectedIndex":0,"shown":true},"locales":{},"darkmode":false,"themeConfig":{}};
+  const __uniRoutes = [{"path":"pages/home/newhome","meta":{"isQuit":true,"isEntry":true,"isTabBar":true,"tabBarIndex":0,"navigationBar":{"titleText":"欧曼生产流程管理","type":"default"},"isNVue":false}},{"path":"pages/home/index","meta":{"navigationBar":{"style":"custom","type":"default"},"isNVue":false}},{"path":"pages/my/index","meta":{"isQuit":true,"isTabBar":true,"tabBarIndex":3,"navigationBar":{"titleText":"我的","type":"default"},"isNVue":false}},{"path":"pages/login/index","meta":{"navigationBar":{"style":"custom","type":"default"},"isNVue":false}},{"path":"pages/login/serverSetting","meta":{"navigationBar":{"titleText":"服务器设置","type":"default"},"isNVue":false}},{"path":"pages/my/protocol","meta":{"navigationBar":{"titleText":"服务协议和隐私政策","type":"default"},"isNVue":false}},{"path":"pages/dispatch/dispatch","meta":{"isQuit":true,"isTabBar":true,"tabBarIndex":1,"enablePullDownRefresh":false,"navigationBar":{"titleText":"派工","type":"default"},"isNVue":false}},{"path":"pages/work-order/work-order","meta":{"isQuit":true,"isTabBar":true,"tabBarIndex":2,"enablePullDownRefresh":false,"navigationBar":{"titleText":"报工","type":"default"},"isNVue":false}},{"path":"pages/workingTeam/select","meta":{"navigationBar":{"titleText":"选择工作组","type":"default"},"isNVue":false}}].map(uniRoute=>(uniRoute.meta.route=uniRoute.path,__uniConfig.pages.push(uniRoute.path),uniRoute.path='/'+uniRoute.path,uniRoute));
   __uniConfig.styles=[];//styles
   __uniConfig.onReady=function(callback){if(__uniConfig.ready){callback()}else{onReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"ready",{get:function(){return isReady},set:function(val){isReady=val;if(!isReady){return}const callbacks=onReadyCallbacks.slice(0);onReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
   __uniConfig.onServiceReady=function(callback){if(__uniConfig.serviceReady){callback()}else{onServiceReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"serviceReady",{get:function(){return isServiceReady},set:function(val){isServiceReady=val;if(!isServiceReady){return}const callbacks=onServiceReadyCallbacks.slice(0);onServiceReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});

File diff suppressed because it is too large
+ 0 - 0
src/Auman.PieceWage.UniApp/unpackage/dist/build/app-plus/app-service.js


File diff suppressed because it is too large
+ 0 - 0
src/Auman.PieceWage.UniApp/unpackage/dist/build/app-plus/app.css


+ 3 - 3
src/Auman.PieceWage.UniApp/unpackage/dist/build/app-plus/manifest.json

@@ -7,8 +7,8 @@
   "id": "__UNI__0D07441",
   "name": "生产流程管理",
   "version": {
-    "name": "0.0.10",
-    "code": 10
+    "name": "0.1.1",
+    "code": 12
   },
   "description": "生产流程管理",
   "developer": {
@@ -162,7 +162,7 @@
       "height": "50px",
       "list": [
         {
-          "pagePath": "pages/home/index",
+          "pagePath": "pages/home/newhome",
           "text": "首页",
           "iconPath": "/static/tabbar/house.png",
           "selectedIconPath": "/static/tabbar/house_active.png"

+ 1 - 0
src/Auman.PieceWage.UniApp/unpackage/dist/build/app-plus/pages/home/newhome.css

@@ -0,0 +1 @@
+.status-bar-height{height:var(--status-bar-height)}uni-button{margin-left:0;margin-right:0}.card{position:relative;display:flex;background-color:#fff;border:.03125rem solid #dfdfdf;align-items:center;justify-content:center;box-shadow:0 0 .9375rem rgba(0,0,0,.08);border-radius:.625rem;overflow:hidden}

File diff suppressed because it is too large
+ 0 - 0
src/Auman.PieceWage.UniApp/unpackage/dist/build/app-plus/pages/login/serverSetting.css


+ 21 - 6
src/Auman.PieceWage.UniApp/utils/login.js

@@ -22,6 +22,17 @@ class Login {
         return user.getRemember();
     }
 
+    /**
+     * 设置登录信息
+     * @param {object} info 登录信息
+     * @param {string} info.username 登录账号
+     * @param {string} info.password 登录密码
+     * @returns {boolean} 设置成功标记
+     */
+    setRemember(info) {
+        return user.setRemember(info);
+    }
+
     /**
      * 登录
      * @param {object} data 登录参数
@@ -48,12 +59,6 @@ class Login {
 
             if (userRes.success) {
                 result.success = true;
-
-                // 登录成功
-                user.setRemember({
-                    username: this.username,
-                    password: this.password
-                });
             } else {
                 result.message = userRes.message;
             }
@@ -63,9 +68,19 @@ class Login {
         if (!result.success) {
             token.clear();
             user.clear();
+            user.clearLoginInfo();
         }
         return result;
     }
+
+    /**
+     * 注销登录
+     */
+    logoff() {
+        token.clear();
+        user.clear();
+        user.clearLoginInfo();
+    }
 }
 
 export default new Login();

+ 11 - 6
src/Auman.PieceWage.UniApp/utils/token.js

@@ -27,7 +27,7 @@ const tokenUrlKey = 'token_url';
 /**
  * Token
  */
-export default {
+class Token {
     /**
      * 判断 Token 是否生效
      * @returns {boolean} 存在标记
@@ -42,7 +42,7 @@ export default {
             return false;
         }
         return true;
-    },
+    }
 
     /**
      * 设置 Token
@@ -62,7 +62,7 @@ export default {
         }
         extend.addStorage(tokenKey, param.token);
         extend.addStorage(tokenTimeoutKey, timeout);
-    },
+    }
 
     /**
      * 获取 Token
@@ -70,7 +70,7 @@ export default {
     get() {
         this.has();
         return extend.readStorage(tokenKey);
-    },
+    }
 
     /**
      * 清除 Token
@@ -79,7 +79,7 @@ export default {
         extend.removeStorage(tokenKey);
         extend.removeStorage(tokenTimeoutKey);
         user.clear();
-    },
+    }
 
     /**
      * 通过服务器获取Token
@@ -124,4 +124,9 @@ export default {
         }
         return res;
     }
-};
+}
+
+/**
+ * Token
+ */
+export default new Token();

+ 18 - 13
src/Auman.PieceWage.UniApp/utils/user.js

@@ -25,7 +25,7 @@ const userUrlKey = 'user_url';
 /**
  * 用户类
  */
-export default {
+class User {
     /**
      * 从服务器获取
      * @param {object} opts 参数
@@ -53,7 +53,7 @@ export default {
             });
         }
         return res;
-    },
+    }
 
     /**
      * 获取用户对象
@@ -61,7 +61,7 @@ export default {
     get() {
         let user = extend.readStorage(resultKey);
         return user;
-    },
+    }
 
     /**
      * 设置用户对象
@@ -74,7 +74,7 @@ export default {
             return true;
         }
         return false;
-    },
+    }
 
     /**
      * 获取登录信息
@@ -82,7 +82,7 @@ export default {
     getLoginInfo() {
         let info = extend.readStorage(infoKey);
         return info;
-    },
+    }
 
     /**
      * 获取登录信息
@@ -90,7 +90,7 @@ export default {
     getRemember() {
         let info = extend.readStorage(rememberKey);
         return info;
-    },
+    }
     
     /**
      * 获取用户信息地址
@@ -98,7 +98,7 @@ export default {
     getUserUrl(){
         let url = extend.readStorage(userUrlKey);
         return url;
-    },
+    }
 
     /**
      * 设置登录信息
@@ -113,7 +113,7 @@ export default {
             return true;
         }
         return false;
-    },
+    }
 
     /**
      * 设置登录信息
@@ -128,7 +128,7 @@ export default {
             return true;
         }
         return false;
-    },
+    }
 
     /**
      * 设置用户信息地址
@@ -141,21 +141,21 @@ export default {
             return true;
         }
         return false;
-    },
+    }
 
     /**
      * 清除用户信息缓存
      */
     clear() {
         extend.removeStorage(resultKey);
-    },
+    }
 
     /**
      * 清除登录信息缓存
      */
     clearLoginInfo() {
         extend.removeStorage(infoKey);
-    },
+    }
 
     /**
      * 清除登录信息缓存
@@ -163,4 +163,9 @@ export default {
     clearRemember() {
         extend.removeStorage(rememberKey);
     }
-}
+}
+
+/**
+ * 用户类
+ */
+export default new User();

Some files were not shown because too many files changed in this diff