Jelajahi Sumber

修改storage逻辑,修改密码更新,修改注册逻辑,修改用户管理模块页面布局和样式,修改用户表结构

zhangxike 6 hari lalu
induk
melakukan
b1da9017ac
11 mengubah file dengan 424 tambahan dan 362 penghapusan
  1. 7 4
      api/login.uts
  2. 5 21
      pages/login.uvue
  3. 190 187
      pages/mine/index.uvue
  4. 155 130
      pages/mine/pwd/index.uvue
  5. 7 6
      pages/register.uvue
  6. TEMPAT SAMPAH
      static/db/QT800.db
  7. 26 7
      store/index.uts
  8. 28 3
      utils/auth.uts
  9. 3 1
      utils/constant.uts
  10. 2 2
      utils/dataProcessor.uts
  11. 1 1
      utils/qcDataProcessor.uts

+ 7 - 4
api/login.uts

@@ -1,5 +1,5 @@
 import request from '@/utils/request'
-import { getToken, removeToken } from '@/utils/auth';
+import { getToken, removeToken, getCurrentUserSync } from '@/utils/auth';
 // #ifdef APP-ANDROID
 import {selectTableData, insertTableData} from '@/utils/sqlite'
 // #endif
@@ -56,6 +56,7 @@ export function login(username:string, password:string, code:string, uuid:string
 }
 export type RegForm={
 			username: string,
+			name: string,
 			password: string,
 			token: string,
 			confirmPassword: string,
@@ -74,9 +75,9 @@ export function register(data:RegForm):Promise<UTSJSONObject> {
     data
   }) */
   // #ifdef APP-ANDROID
-	let condition = 'username,password,token,role,status,createtime,updatetime'
+	let condition = 'username,name,password,role,status,createtime,updatetime'
 	let date = "strftime('%Y-%m-%d %H:%M:%S', 'now')"
-	let dataStr = `'${data.username}','${data.password}','${data.token}','user',1, ${date}, ${date}`;  
+	let dataStr = `'${data.username}','${data.name}','${data.password}','user',1, ${date}, ${date}`;  
 	console.log(dataStr)
 	const result = insertTableData('app_user', dataStr, condition);
 	console.log(result);
@@ -97,6 +98,7 @@ export function getInfo():Promise<UTSJSONObject> {
   })*/
   let data = {
     username: "admin",
+	name: "管理员"
     password: "admin123",
     code: "",
     uuid: '1',
@@ -105,7 +107,8 @@ export function getInfo():Promise<UTSJSONObject> {
   } as UTSJSONObject
       
 	// #ifdef APP-ANDROID
-	const result = selectTableData('app_user', 'token', getToken(), null, null);
+	console.log('getCurrentUserSync', getCurrentUserSync())
+	const result = selectTableData('app_user', 'username', getCurrentUserSync(), null, null);
 	console.log(result);
 	return result;
   // #endif

+ 5 - 21
pages/login.uvue

@@ -42,7 +42,7 @@
 <script lang="uts">
   import { GlobalConfig } from '../config'
   import { getCodeImg } from '@/api/login'
-  import {Login,GetInfo} from '@/store'
+  import {Login,GetInfo, SetName, SetUserName} from '@/store'
   
   type LoginForm={
   		  username: string,
@@ -62,6 +62,7 @@
         globalConfig: getApp().globalData.config as UTSJSONObject,
         loginForm: {
           username: "admin",
+          name: "管理员",
           password: "admin123",
           code: "",
           uuid: ''
@@ -97,15 +98,6 @@
         });
       },
 			
-      // getCode() {
-      //  getCodeImg().then((res:UTSJSONObject) => {
-      //    this.captchaEnabled = res['captchaEnabled'] != null ? res['captchaEnabled'] as boolean : true
-      //    if (this.captchaEnabled) {
-      //      this.codeUrl = 'data:image/gif;base64,' + res.img as string
-      //      this.loginForm.uuid = res.uuid as string
-      //    }
-       // })
-      //},
       // 登录方法
       async handleLogin() {
         if (this.loginForm.username === "") {
@@ -121,15 +113,6 @@
 		    duration: 2000 
 		  });
         } 
-		/*
-		  else if (this.loginForm.code === "" && this.captchaEnabled) {
-		  uni.showToast({
-		    title: '请输入验证码',
-		    icon: 'error', 
-		    duration: 2000 
-		  });
-        }
-		 */
 		else {
 		  uni.showLoading({
 		    title: '登录中,请耐心等待...'
@@ -144,8 +127,9 @@
           this.loginSuccess()
         }).catch((e) => {
 		  uni.hideLoading();
+		  console.log(e)
 		  uni.showToast({
-		    title: '登录失败',
+		    title: e as string,
 		    icon: 'error', 
 		    duration: 2000 
 		  });	
@@ -157,7 +141,7 @@
       // 登录成功后,处理函数
       loginSuccess() {
         // 设置用户信息		
-        GetInfo().then(() => {
+        GetInfo().then((res:UTSJSONObject) => {
 		  uni.reLaunch({
 		    url: '/pages/work/index'
 		  });

+ 190 - 187
pages/mine/index.uvue

@@ -1,219 +1,222 @@
 <template>
-  <view class=" mine-container" :style="{height: `${windowHeight}px`}">
-    <!--顶部个人信息栏-->
-    <view class=" header-section">
-      <view class=" flex padding justify-between uni-row">
-        <view class=" flex align-center uni-row">
-          <view v-if="avatar==null" class="cu-avatar xl round bg-white">
-            <view class="text-gray icon"></view>
-          </view>
-          <image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round" mode="widthFix">
-          </image>
-          <view v-if="name == null" @click="handleToLogin" class=" login-tip">
-            点击登录
-          </view>
-          <view v-if="name" @click="handleToInfo" class=" user-info">
-            <view class=" u_title">
-              用户名:{{ name }}
-            </view>
-          </view>
-        </view>
-        <view @click="handleToInfo" class=" flex align-center uni-row">
-          <text>个人信息</text>
-          <view class=""></view>
-        </view>
-      </view>
-    </view>
-
-    <view class=" content-section">
-      <view class=" mine-actions grid col-4  uni-row">
-        
-      </view>
-
-      <view class=" menu-list">
-        <view class=" list-cell list-cell-arrow" @click="handleToEditInfo">
-          <view class=" menu-item-box uni-row">
-            <view class=" menu-icon"></view>
-            <view class="font-14">编辑资料</view>
-          </view>
-        </view>
-        <view class=" list-cell list-cell-arrow" @click="handleHelp">
-          <view class=" menu-item-box uni-row">
-            <view class="menu-icon"></view>
-            <view class="font-14">常见问题</view>
-          </view>
-        </view>
-        <view class=" list-cell list-cell-arrow" @click="handleAbout">
-          <view class=" menu-item-box uni-row">
-            <view class=" menu-icon"></view>
-            <view class="font-14">关于我们</view>
-          </view>
-        </view>
-        <view class=" list-cell list-cell-arrow" @click="handleToSetting">
-          <view class=" menu-item-box uni-row">
-            <view class="menu-icon"></view>
-            <view class="font-14">应用设置</view>
-          </view>
-        </view>
-      </view>
-
+<!-- #ifdef APP -->
+ <scroll-view style="flex:1">
+ <!-- #endif -->
+  <view class="my-page">
+
+    <!-- 标题栏 -->
+	<view class=" uni-section">
+		<view class=" uni-section-header">
+		<view class=" uni-section-header__decoration line"/>	
+			<view class=" uni-section-header__content">
+			  <text style="font-size:14px;color:#333" class="distraction">用户管理</text>
+			</view>
+		</view>
+	</view>
+	<!-- 宫格 -->
+    <view class="grid-body">
+	  <view class="grid uni-row">
+          <view class="grid-item" v-for="(item: Item, index: number) in items" :key="index" @click="enterItem(item)" >
+	          <!-- 您的网格项内容 -->
+	          <uni-icons class="my-icon" :type="item.iconType" size="40" :color="item.colorClass" ></uni-icons>
+	          <text class="text">{{ item.text }}</text> 
+	        </view>
+	      </view>
     </view>
   </view>
+  <!-- #ifdef APP -->
+    </scroll-view>
+  <!-- #endif -->
 </template>
 
-<script lang="uts">  
-  import {state,LogOut} from '@/store'
+<script lang="uts">
+  import {state} from '@/store'; 	
+  type ImageItem={
+  	 image:string
+  }
+  type Item={
+  	  colorClass:string,
+  	  iconType:string,
+  	  path:string,		   
+  	  text:string
+  }	
   export default {
-    data() {
-		const globalData = getApp().globalData
-		const config = globalData.config != null ? globalData.config as UTSJSONObject : null;
-		const appInfo:UTSJSONObject|null = config?.get('appInfo') as UTSJSONObject;
+    data() { 
+	   let basic = [
+		     ,{colorClass: 'green', iconType: "wallet-filled", text: "用户信息",path:"/pages/mine/pwd/index" }
+		] as Item[];
+		let isAdmin = state.roles.includes('admin') ? true : false;
+		let adminItem =  {colorClass: 'blue', iconType: "personadd-filled", text: "注册用户",path:"/pages/register" }as Item;
+		let items = isAdmin ? basic.concat(adminItem) : basic;
+		
       return {
-        name: state.name as string,
-        version: appInfo?.get('version') as string | ''
-      }
-    },
-    computed: {
-      avatar() {
-        return state.avatar as string
-      },
-      windowHeight() {
-        return (uni.getSystemInfoSync().windowHeight - 50 ) as number
+		items: items as Item[],
+        current: 0 as number,
+        swiperDotIndex: 0 as number,
+        data: [{
+            image: '/static/images/banner/banner01.png'
+          },
+        ] as ImageItem[]
       }
     },
     methods: {
-      handleToInfo() {
-        uni.navigateTo({
-          url: '/pages/mine/info/index'
-        });
-      },
-      handleToEditInfo() {
-        uni.navigateTo({
-          url: '/pages/mine/info/edit'
-        });
+      clickBannerItem(item:ImageItem) {
+        console.info(item)
       },
-      handleToSetting() {
-        uni.navigateTo({
-          url: '/pages/mine/setting/index'
-        });
+      changeSwiper(e:UniSwiperChangeEvent) {
+        this.current = e.detail.current
       },
-      handleToLogin() {
-        uni.reLaunch({
-          url: '/pages/login'
-        });
-      },
-      handleToAvatar() {
-		// 上传头像待优化
-        // uni.navigateTo({
-        //   url: '/pages/mine/avatar/index'
-        // });
-		uni.showToast({
-		  title: '模块建设中~',
-		  icon: 'none'
-		});
-      },
-      handleLogout() {
-        uni.showModal({
-          title: '提示',
-          content: '确定注销并退出系统吗?',
-          success: (res) => {
-            if (res.confirm) {
-              LogOut().then(() => {
-                uni.reLaunch({
-                  url: '/pages/index'
-                });
-              });
-            }
-          }
-        });
-      },
-      handleHelp() {
-        uni.navigateTo({
-          url: '/pages/mine/help/index'
-        });
-      },
-      handleAbout() {
-        uni.navigateTo({
-          url: '/pages/mine/about/index'
-        });
-      },
-      handleJiaoLiuQun() {
-        uni.showToast({
-          title: 'QQ群:①133713780、②146013835',
-          icon: 'none'
-        });
-      },
-      handleBuilding() {
-        uni.showToast({
-          title: '模块建设中~',
-          icon: 'none'
-        });
+      enterItem(e:Item) {
+		  if (e.path != null && e.path != "") {
+		  	uni.navigateTo({
+		  		url: e.path as string
+		  	});
+		  } else {
+		  uni.showToast({
+		        title: '模块建设中~',
+		        icon: 'none'
+		      });
+		}	  
       }
     }
   }
 </script>
 
 <style lang="scss">
+  /* #ifndef APP-NVUE */
   .my-page {
-    background-color: #f5f6f7;
-	width: 100%;
-	height: 100%;
-  }
-
-  .mine-container {
-    width: 100%;
+    display: flex;
+    flex-direction: column;
+    box-sizing: border-box;
+    background-color: #fff;
+	/* #ifndef APP-ANDROID */
+	min-height: 100%;
+	/* #endif */
     height: 100%;
+  }
 
+	/* #ifndef APP-ANDROID */
+	  view {
+		font-size: 14px;
+		line-height: inherit;
+	  }
+	/* #endif */
+  /* #endif */
+
+  .text {
+    text-align: center;
+    font-size: 26rpx;
+    margin-top: 10rpx;
+  }
 
-    .header-section {
-      padding: 15px 15px 45px 15px;
-      background-color: #3c96f3;
-      color: white;
+ 
+  .swiper {
+    height: 300rpx;
+  }
 
-      .login-tip {
-        font-size: 18px;
-        margin-left: 10px;
-      }
+  .swiper-box {
+    height: 150px;
+  }
 
-      .cu-avatar {
-        border: 2px solid #eaeaea;
+  .swiper-item {
+    /* #ifndef APP-NVUE */
+    display: flex;
+    /* #endif */
+    flex-direction: column;
+    justify-content: center;
+    align-items: center;
+    color: #fff;
+    height: 300rpx;
+    line-height: 300rpx;
+  }
 
-        .icon {
-          font-size: 40px;
-        }
+  @media screen and (min-width: 500px) {
+    .my-image {
+      width: 100%;
+    }
+  }
+  .grid-body {
+	/* #ifndef APP-NVUE */  
+  	 display: flex;
+	/* #endif */
+  	flex-wrap: wrap;
+  	justify-content: space-between;
+  	margin-top: 40rpx;
+  }
+  
+  .grid-item {
+    width: 32%;
+    padding: 18px 15px;
+	margin-bottom: 40rpx;
+	border-radius: 20rpx;
+	box-shadow: 0 8rpx 20rpx rgba(24, 144, 255, 0.15);
+	display: flex;
+	flex-direction: column;
+	.my-icon{
+		text-align: center;
+		border-radius: 20rpx;
+	}
+  }
+  .purple {color:#6366f1;}
+  .blue {color:#2563eb; }
+  .orange {color:#d97706;}
+  .green {color:#059669;}
+  .yellow {color:yellow;}
+  
+  $uni-primary: #2979ff !default;
+  
+  .uni-section {
+  	background-color: #fff;
+  .uni-section-header {
+    position: relative;
+    /* #ifndef APP-NVUE */
+    display: flex;
+    /* #endif */
+    flex-direction: row;
+    align-items: center;
+    padding: 12px 10px;
+    font-weight: normal;
+  
+    &__decoration{
+      margin-right: 6px;
+      background-color: $uni-primary;
+      &.line {
+        width: 4px;
+        height: 12px;
+        border-radius: 10px;
       }
-
-      .user-info {
-        margin-left: 15px;
-
-        .u_title {
-          font-size: 18px;
-          line-height: 30px;
-        }
+  
+      &.circle {
+        width: 8px;
+        height: 8px;
+        border-top-right-radius: 50px;
+        border-top-left-radius: 50px;
+        border-bottom-left-radius: 50px;
+        border-bottom-right-radius: 50px;
+      }
+  
+      &.square {
+        width: 8px;
+        height: 8px;
       }
     }
-
-    .content-section {
-      position: relative;
-      top: -50px;
-
-      .mine-actions {
-        margin: 15px 15px;
-        padding: 20px 0px;
-        border-radius: 8px;
-        background-color: white;
-
-        .action-item {
-          .icon {
-            font-size: 28px;
-          }
-
-          .text {
-            font-size: 13px;
-            margin: 8px 0px;
-          }
-        }
+  
+    &__content {
+      /* #ifndef APP-NVUE */
+      display: flex;
+      /* #endif */
+      flex-direction: column;
+      flex: 1;
+      color: #333;
+  
+      .distraction {
+        flex-direction: row;
+        align-items: center;
+      }
+      &-sub {
+        margin-top: 2px;
       }
     }
   }
+  }
 </style>

+ 155 - 130
pages/mine/pwd/index.uvue

@@ -1,140 +1,165 @@
 <template>
-  <view class=" pwd-retrieve-container my-page">
-	<form>
-			 <view class="uni-form-item uni-row">
-			   <view class="title">旧密码</view>
-			   <input :class="'uni-input '+oldPassword"
-			   name="oldPassword" 
-			   :password="true"
-			   :value="user.oldPassword" 
-			   placeholder="请输入旧密码" 
-			   @focus="inputFocus('oldPassword')"
-			   @blur="inputBlur('oldPassword')"
-			    @input="inputOld"
-			   />
-			 </view>
-			 <view class="uni-form-item uni-row">
-			   <view class="title">新密码</view>
-			   <input :class="'uni-input '+newPassword"
-				name="newPassword" 
-				:password="true"
-				 :value="user.newPassword"
-				  placeholder="请输入新密码"
-				  @focus="inputFocus('newPassword')"
-				  @blur="inputBlur('newPassword')"
-				  @input="inputNew"
-				 />
-			 </view>
-			 <view class="uni-form-item uni-row">
-			   <view class="title">确认密码</view>
-			   <input :class="'uni-input '+confirmPassword"
-				name="confirmPassword"  
-				:password="true"
-				:value="user.confirmPassword"
-				 placeholder="请确认新密码"
-				 @focus="inputFocus('confirmPassword')"
-				 @blur="inputBlur('confirmPassword')"
-				  @input="inputConfirm"
-				/>
-			 </view>
-			 <button type="primary" @click="submit">提交</button>
-	</form>
-  </view>
+	<view class=" pwd-retrieve-container my-page">
+		<form>
+			<view class="uni-form-item uni-row">
+				<view class="title">旧密码</view>
+				<input :class="'uni-input '+oldPassword" name="oldPassword" :password="true" :value="user.oldPassword"
+					placeholder="请输入旧密码" @focus="inputFocus('oldPassword')" @blur="inputBlur('oldPassword')"
+					@input="inputOld" />
+			</view>
+			<view class="uni-form-item uni-row">
+				<view class="title">新密码</view>
+				<input :class="'uni-input '+newPassword" name="newPassword" :password="true" :value="user.newPassword"
+					placeholder="请输入新密码" @focus="inputFocus('newPassword')" @blur="inputBlur('newPassword')"
+					@input="inputNew" />
+			</view>
+			<view class="uni-form-item uni-row">
+				<view class="title">确认密码</view>
+				<input :class="'uni-input '+confirmPassword" name="confirmPassword" :password="true"
+					:value="user.confirmPassword" placeholder="请确认新密码" @focus="inputFocus('confirmPassword')"
+					@blur="inputBlur('confirmPassword')" @input="inputConfirm" />
+			</view>
+			<button type="primary" @click="submit">提交</button>
+		</form>
+	</view>
 </template>
 
 <script lang="uts">
-  import { updateUserPwd } from "@/api/system/user"
+	import { updateUserPwd } from "@/api/system/user"
+	import { updateData, getList } from '@/api/work';
+	import { getCurrentUserSync, getCurrentUserNameSync } from '@/utils/auth.uts'
+	
+	type User = {
+		oldPassword : string | null,
+		newPassword : string | null,
+		confirmPassword : string | null
+	}
 
-  type User={
-    oldPassword: string|null,
-    newPassword: string|null,
-    confirmPassword:string|null
-  }
-
-  export default {
-    data() {
-      return {
-		  oldPassword:'',
-		  newPassword:'',
-		  confirmPassword:'',
-        user: {
-          oldPassword: null,
-          newPassword: null,
-          confirmPassword: null
-        } as User,
-      }
-    },
-    
-    methods: {
-		inputFocus(tag:string){
-			this.$data[tag]="my-focus"
-		},
-		inputBlur(tag:string){
-			this.$data[tag]="my-blur"
-		},
-		inputOld(event:UniInputEvent){
-			this.user.oldPassword=event.detail.value
-		},
-		inputNew(event:UniInputEvent){
-			this.user.newPassword=event.detail.value
+	export default {
+		data() {
+			return {
+				oldPassword: '',
+				newPassword: '',
+				confirmPassword: '',
+				user: {
+					oldPassword: null,
+					newPassword: null,
+					confirmPassword: null
+				} as User,
+			}
 		},
-		inputConfirm(event:UniInputEvent){
-			this.user.confirmPassword=event.detail.value
-		},
-      submit() {
-		  if(this.user.oldPassword == null){
-		  	uni.showToast({
-		  		title:"旧密码不能为空",
-		  		icon:"error"
-		  	})
-		  	return 
-		  }
-		  if(this.user.newPassword == null){
-		  	uni.showToast({
-		  		title:"新密码不能为空",
-		  		icon:"error"
-		  	})
-		  	return 
-		  }else if(this.user.newPassword != null && (this.user.newPassword.length < 6 || this.user.newPassword.length > 20)){
-		  	uni.showToast({
-		  		title:"长度在6到20个字符",
-		  		icon:"error"
-		  	})
-		  	return
-		  }
-		  if(this.user.confirmPassword==null){
-		  	uni.showToast({
-		  		title:"确认密码不能为空",
-		  		icon:"error"
-		  	})
-		  	return 
-		  }else if(this.user.confirmPassword != this.user.newPassword){
-		  	uni.showToast({
-		  		title:"两次输入的密码不一致",
-		  		icon:"error"
-		  	})
-		  	return
-		  }
-          updateUserPwd(this.user.oldPassword as string, this.user.newPassword as string).then(response => {
-            uni.showToast({
-                  title: '修改成功',
-                  icon: 'success'
-            });
-          })
-      }
-    }
-  }
+
+		methods: {
+			inputFocus(tag : string) {
+				this.$data[tag] = "my-focus"
+			},
+			inputBlur(tag : string) {
+				this.$data[tag] = "my-blur"
+			},
+			inputOld(event : UniInputEvent) {
+				this.user.oldPassword = event.detail.value
+			},
+			inputNew(event : UniInputEvent) {
+				this.user.newPassword = event.detail.value
+			},
+			inputConfirm(event : UniInputEvent) {
+				this.user.confirmPassword = event.detail.value
+			},
+			submit() {
+				if (this.user.oldPassword == null) {
+					uni.showToast({
+						title: "旧密码不能为空",
+						icon: "error"
+					})
+					return
+				}
+				if (this.user.newPassword == null) {
+					uni.showToast({
+						title: "新密码不能为空",
+						icon: "error"
+					})
+					return
+				} else if (this.user.newPassword != null && (this.user.newPassword.length < 6 || this.user.newPassword.length > 20)) {
+					uni.showToast({
+						title: "长度在6到20个字符",
+						icon: "error"
+					})
+					return
+				}
+				if (this.user.oldPassword == this.user.newPassword) {
+					uni.showToast({
+						title: "新旧密码不能相同",
+						icon: "error"
+					})
+					return
+				}
+				if (this.user.confirmPassword == null) {
+					uni.showToast({
+						title: "确认密码不能为空",
+						icon: "error"
+					})
+					return
+				} else if (this.user.confirmPassword != this.user.newPassword) {
+					uni.showToast({
+						title: "两次输入的密码不一致",
+						icon: "error"
+					})
+					return
+				}
+
+				let username = '';
+				let oldPassword = '';
+				getList('app_user', 'username', getCurrentUserNameSync(), null, null, null).then((res : UTSJSONObject) => {
+					let userList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>();
+					console.log(userList);
+					if (userList != null && userList.length > 0) {
+						let user = userList[0];
+						username = user.getString('username') ?? '';
+						oldPassword = user.getString('password') ?? '';
+					}
+					// 添加逻辑判断:验证原密码是否匹配
+					if (oldPassword == this.user.oldPassword) {
+						let updatedData = "password='" + this.user.confirmPassword + "' ";
+						updateData('app_user', updatedData, 'username', username).then((res : UTSJSONObject) => {
+							let data = res?.['data'] as boolean ?? false;
+							if (data != null && data == true) {
+								uni.showToast({
+									title: "更新成功!",
+								});
+								setTimeout(() => {
+								
+								}, 1500)
+								uni.reLaunch({
+								  url: '/pages/mine/index'
+								});
+							} else {
+								uni.showToast({
+									title: "更新失败,请稍后重试!",
+									icon: "error"
+								});
+							}
+						});
+					} else {
+						uni.showToast({
+							title: "更新失败,原密码不匹配!",
+							icon: "error"
+						});
+					}
+				});
+			}
+		}
+	}
 </script>
 
 <style lang="scss">
-  .my-page {
-    background-color: #ffffff;
-	width: 100%;
-	height: 100%;
-  }
+	.my-page {
+		background-color: #ffffff;
+		width: 100%;
+		height: 100%;
+	}
 
-  .pwd-retrieve-container {
-    padding-top: 36rpx;
-    padding: 15px;
-  }
-</style>
+	.pwd-retrieve-container {
+		padding-top: 36rpx;
+		padding: 15px;
+	}
+</style>

+ 7 - 6
pages/register.uvue

@@ -11,6 +11,10 @@
         <view class=" iconfont icon-user icon"></view>
         <input v-model="registerForm.username" class="input" type="text" placeholder="请输入账号" maxlength="30" />
       </view>
+	  <view class=" input-item flex align-center uni-row">
+	    <view class=" iconfont icon-user icon"></view>
+	    <input v-model="registerForm.name" class="input" type="text" placeholder="请输入用户姓名" maxlength="30" />
+	  </view>
       <view class=" input-item flex align-center uni-row">
         <view class=" iconfont icon-password icon"></view>
         <input v-model="registerForm.password" type="password" class="input" placeholder="请输入密码" maxlength="20" />
@@ -19,10 +23,6 @@
         <view class=" iconfont icon-password icon"></view>
         <input v-model="registerForm.confirmPassword" type="password" class="input" placeholder="请输入重复密码" maxlength="20" />
       </view>
-	  <view class=" input-item flex align-center uni-row">
-	    <view class=" iconfont icon"></view>
-	    <input v-model="registerForm.token" type="input" class="input" placeholder="请输入token" maxlength="20" />
-	  </view>
 	  <!--
       <view class=" input-item flex align-center" style="width: 60%;margin: 0px;" v-if="captchaEnabled">
         <view class=" iconfont icon-code icon"></view>
@@ -55,6 +55,7 @@ import { getCodeImg, register, RegForm} from '@/api/login'
         globalConfig: getApp().globalData.config as UTSJSONObject,
         registerForm: {
           username: "",
+		  name: "",
           password: "",
 		  token: "",
           confirmPassword: "",
@@ -105,9 +106,9 @@ import { getCodeImg, register, RegForm} from '@/api/login'
             title: '两次输入的密码不一致',
             icon: 'error'
           });
-        } else if (this.registerForm.token == "") {
+        } else if (this.registerForm.name == "") {
           uni.showToast({
-            title: '请输入您的token',
+            title: '请输入您的用户姓名',
             icon: 'error'
           });
         }

TEMPAT SAMPAH
static/db/QT800.db


+ 26 - 7
store/index.uts

@@ -2,12 +2,13 @@ import {globalConfig} from '@/config';
 import storage from '@/utils/storage';
 import {constant} from '@/utils/constant';
 import { login, logout, getInfo } from '@/api/login';
-import { getToken, setToken, removeToken } from '@/utils/auth';
+import { getToken, setToken, removeToken, setCurrentUserSync, setCurrentUserNameSync } from '@/utils/auth';
 import profileImg from '@/static/images/profile.jpg';
 
 type State = {
   token: string,
   name: string,
+  username: string,
   avatar: string,
   roles: string[],
   permissions: string[],
@@ -19,6 +20,9 @@ console.log('Token value:', tokenValue);
 const nameValue = storage.get(constant.name)??'' as string;
 console.log('Name value:', nameValue);
 
+const usernameValue = storage.get(constant.username)??'' as string;
+console.log('UserName value:', usernameValue);
+
 const avatarValue = storage.get(constant.avatar)??'' as string;
 console.log('Avatar value:', avatarValue);
 
@@ -31,6 +35,7 @@ console.log('Permissions value:', permissionsValue);
 export const state = reactive({
   token: tokenValue,
   name: nameValue as string,
+  username: usernameValue as string,
   avatar: avatarValue as string,
   roles: rolesValue as string[],
   permissions: permissionsValue as string[]
@@ -41,9 +46,14 @@ export const SetToken=(token: string)=>{
 	setToken(token)
 }
 
-export const SetName=(name: string)=>{
+export const SetCurrentUser=(username: string)=>{
+	state.username = username;
+	setCurrentUserNameSync(username)
+}
+
+export const SetUserName=(name: string)=>{
 	state.name = name;
-	storage.set(constant.name, name);
+	setCurrentUserSync(name)
 }
 
 export const cleanAll=()=>{
@@ -72,17 +82,18 @@ export const Login=(userInfo:UTSJSONObject):Promise<void>=> {
     const uuid:string = userInfo.getString("uuid") as string;
 			
 	return new Promise((resolve, reject) => {
-		
 	  login(username, password, code, uuid).then((res:UTSJSONObject) => {
 	    //SetToken(res.getString("token") as string);
-		console.log(res)
 		let msg = res.getString("errMsg")
 		let data = res.getArray("data") as UTSJSONObject[]
 		if(msg == 'ok' && data.length>0){
 			SetToken(data[0].getString("token") as string)
+			SetUserName(data[0].getString("name") as string)
+			SetUserName(username)
+			SetCurrentUser(username)
 			resolve()
 		}else{
-			reject('登录失败')
+			reject('登录失败,账户或密码不匹配!')
 		}	    
 	  })
 	})
@@ -92,8 +103,10 @@ export const Login=(userInfo:UTSJSONObject):Promise<void>=> {
 export const GetInfo=():Promise<UTSJSONObject>=> {
   return new Promise((resolve, reject) => {
 	getInfo().then((res:UTSJSONObject) => {
+	console.log(res)	
 	  let avatar:string=profileImg as string
 	  let username:string="" as string
+	  let name:string="" as string
 	  let roles=[] as string[]
 	  const resMap=res.toMap() as Map<string,any>
 	   if(resMap.has("data")){
@@ -108,6 +121,9 @@ export const GetInfo=():Promise<UTSJSONObject>=> {
 			if(userMap.has("username")&&user.getString("username")!=null&&user.getString("username")!=""){
 				username= user.getString("username") as string
 			}
+			if(userMap.has("name")&&user.getString("name")!=null&&user.getString("name")!=""){
+				name= user.getString("name") as string
+			}
 			if(userMap.has("role") &&user.getString("role")!=null&&user.getString("role")!=""){
 				roles.push(user.getString("role") as string)
 			}
@@ -125,7 +141,8 @@ export const GetInfo=():Promise<UTSJSONObject>=> {
 		   }
 	   }
 	   SetRoles?.(roles)
-	   SetName?.(username);
+	   SetUserName?.(name);
+	   SetCurrentUser?.(username);
 	   SetAvatar?.(avatar);
 	   resolve(res)
 	})
@@ -139,6 +156,8 @@ export const GetInfo=():Promise<UTSJSONObject>=> {
 	  logout(state.token).then(() => {
 	    SetToken('');
 		SetRoles([]);
+		SetCurrentUser('');
+		SetUserName('');
 		SetPermissions([]);   
 		removeToken();
 		cleanAll();

+ 28 - 3
utils/auth.uts

@@ -2,6 +2,7 @@ import storage from '@/utils/storage';
 import {constant} from '@/utils/constant';
 import {globalConfig} from '@/config'
 const TokenKey = 'App-Token'
+const APITokenKey = 'Api-Token'
 
 export function getToken():string {
   return uni.getStorageSync(TokenKey) as string | ''
@@ -11,12 +12,36 @@ export function setToken(token:string):void {
   return uni.setStorageSync(TokenKey, token)
 }
 
+export function getApiToken():string {
+  return uni.getStorageSync(APITokenKey) as string | ''
+}
+
+export function setApiToken(token:string):void {
+  return uni.setStorageSync(APITokenKey, token)
+}
+
 export function removeToken():void {
   return uni.removeStorageSync(TokenKey)
 }
 
-export function getCurrentUser():string {
-	return storage.getString(constant.name) as string | '';
+export function removeApiToken():void {
+  return uni.removeStorageSync(APITokenKey)
+}
+
+export function getCurrentUserSync():string {
+  return uni.getStorageSync(constant.name) as string | ''
+}
+
+export function setCurrentUserSync(name:string):void {
+  return uni.setStorageSync(constant.name, name)
+}
+
+export function getCurrentUserNameSync():string {
+	return uni.getStorageSync(constant.username) as string | '';
+}
+
+export function setCurrentUserNameSync(username:string):void {
+  return uni.setStorageSync(constant.username, username)
 }
 
 export function getTokenFromApi():Promise<string> {
@@ -30,7 +55,7 @@ export function getTokenFromApi():Promise<string> {
 			success: (res) => {
 				let tokenObj = res?.['data'] as UTSJSONObject ?? {} as UTSJSONObject
 				console.log(tokenObj?.['token']);
-				storage.set("ApiToken", tokenObj?.['token'])
+				setApiToken(tokenObj?.['token']as string)
 				resolve(tokenObj?.['token'] as string);
 			},
 			fail: (err) => {

+ 3 - 1
utils/constant.uts

@@ -3,12 +3,14 @@ export type Constant= {
   name: string;
   roles: string;
   permissions: string;
+  username: string;
 }
 
 export  const constant = {
   avatar: 'vue_avatar',
   name: 'vue_name',
   roles: 'vue_roles',
-  permissions: 'vue_permissions'
+  permissions: 'vue_permissions',
+  username: 'username'
 } as Constant;
  

+ 2 - 2
utils/dataProcessor.uts

@@ -1,4 +1,4 @@
-import { getCurrentUser, getTokenFromApi } from './auth'
+import { getCurrentUserSync, getTokenFromApi } from '@/utils/auth.uts'
 import { saveMediaInfo, saveMediaRecord, getLatestRecord, removeInfoAndRecord, getList, updateData, addLog } from '@/api/work'
 import { globalConfig } from '@/config'
 
@@ -359,7 +359,7 @@ export const downloadDataFromAPI = async (productCode : string, callback ?: () =
 								}
 							});
 							
-							addLog({ module: null, dataid: 0, content: '下载声像记录', status: 1, params: productCode, createuser: getCurrentUser()??'' })
+							addLog({ module: null, dataid: 0, content: '下载声像记录', status: 1, params: productCode, createuser: getCurrentUserSync()??'' })
 							resolve(true);
 						} else {
 							uni.hideLoading();

+ 1 - 1
utils/qcDataProcessor.uts

@@ -781,7 +781,7 @@ export const uploadDataToAPI = async (gxpk : string, callback ?: () => void) : P
 						'token': apiToken
 					},
 					data: {
-						request: requestTask
+						checkresult: requestTask
 					},
 					success: (res) => resolve(res?.['data'] as UTSJSONObject ?? {} as UTSJSONObject),
 					fail: (err) => reject(err)