Bladeren bron

fix(login): 初始密码登录无法使用问题

wangpx 10 maanden geleden
bovenliggende
commit
39ff0eb0a6
3 gewijzigde bestanden met toevoegingen van 79 en 6 verwijderingen
  1. 9 0
      pages.json
  2. 38 5
      pages/login.vue
  3. 32 1
      plugins/modal.js

+ 9 - 0
pages.json

@@ -95,6 +95,15 @@
 				"enablePullDownRefresh" : false
 			}
 		},
+		{
+			"path" : "pages/work/homesys/index",
+			"style" : 
+			{
+				"navigationBarTitleText" : "房屋管家",
+				"navigationStyle": "custom", // 隐藏默认导航栏(需自行实现自定义导航栏)
+				"enablePullDownRefresh" : false
+			}
+		},
 		{
 			"path": "pages/mine/edit/edit",
 			"style": {

+ 38 - 5
pages/login.vue

@@ -23,7 +23,7 @@
 
 <script setup lang="ts">
 import { ref } from 'vue'
-import { checkAttendance } from '@/api/mine.js'
+import { checkAttendance, changePWD } from '@/api/mine.js'
 import config from '@/config.js'
 import $modal from '@/plugins/modal.js'
 import $tab from '@/plugins/tab.js'
@@ -48,13 +48,46 @@ function handleLogin() {
 	} else {
 		$modal.loading("登录中,请耐心等待...")
 		// TEST: 测试登录接口
-		userStore.Login(loginForm.value).then(() => {
-			$modal.closeLoading()
-			loginSuccess()
+		userStore.Login(loginForm.value).then((res) => {
+			if (loginForm.value.password == '123456') {
+				changeOrgPWD(res.returnParams.useId)
+			} else {
+				$modal.closeLoading()
+				loginSuccess()
+			}
 		})
 	}
 }
-
+function changeOrgPWD(staffId) {
+	$modal.editable('修改初始密码', '请输入大于6位的新密码', false).then((newpassword) => {
+		if (newpassword < 99999) {
+			$modal.syncAlert('密码需大于6位').then(() => {
+				changeOrgPWD(staffId)
+			})
+			return
+		}
+		if (newpassword == '123456') {
+			$modal.syncAlert('请勿使用123456作为密码').then(() => {
+				changeOrgPWD(staffId)
+			})
+			return
+		}
+		const params = {
+			staffId,
+			oldpassword: loginForm.value.password,
+			newpassword,
+		}
+		changePWD(params).then(res => {
+			loginForm.value.password = newpassword
+			$modal.showToast(res.returnMsg);
+			if ("1" == res.returnCode) { //修改成功
+				handleLogin()
+			} else {
+				changeOrgPWD(staffId)
+			}
+		})
+	})
+}
 onLoad((options) => {
 	//判断是否要自动登录
 	if (options.type) {

+ 32 - 1
plugins/modal.js

@@ -31,6 +31,18 @@ export default {
       content: content,
       showCancel: false
     })
+  },
+	syncAlert(content, title) {
+		return new Promise((resolve, reject) => {
+			uni.showModal({
+				title: title || '系统提示',
+				content: content,
+				showCancel: false,
+				success: function(res) {
+					resolve(res.confirm)
+				}
+			})
+		})
   },
   // 确认窗体
   confirm(content, title) {
@@ -72,5 +84,24 @@ export default {
   // 关闭遮罩层
   closeLoading() {
     uni.hideLoading()
-  }
+  },
+	editable(title, placeholderText, showCancel) {
+		return new Promise((resolve, reject) => {
+		  uni.showModal({
+		    title: title || '系统提示',
+		    confirmText: '确定',
+				editable: true,
+				placeholderText,
+				showCancel,
+		    success: function(res) {
+					console.log('success', res);
+					if (res.confirm) {
+						resolve(res.content)
+					} else {
+						reject(res.confirm)
+					}
+		    }
+		  })
+		})
+	}
 }