From 480cb1afdd425d80cbffa79850a958ab2503a4ad Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期三, 06 十二月 2023 17:03:10 +0800
Subject: [PATCH] 1.个人计件工资产量2.生产分析  页面初始化

---
 pages/login/index.vue |   64 ++++++++++++++++++-------------
 1 files changed, 37 insertions(+), 27 deletions(-)

diff --git a/pages/login/index.vue b/pages/login/index.vue
index 11526d0..da82793 100644
--- a/pages/login/index.vue
+++ b/pages/login/index.vue
@@ -55,11 +55,14 @@
 		LoginSave,
 		ForcedOffline,
 	} from '../../config/api.js';
+	import {
+		decode
+	} from 'jsonwebtoken';
 	export default {
 		data() {
 			return {
 				// #ifdef H5
-				usercode: '999',
+				usercode: '9999',
 				// #endif
 
 				// #ifdef APP-PLUS
@@ -69,10 +72,7 @@
 				userpassword: '123',
 				isView: false, //瀵嗙爜鏄惁鍙
 
-
-
 				isDisabledSubmitButton: false, //鎻愪氦鎸夐挳鏄惁澶勪簬鍔犺浇涓�
-
 
 				isShowCancelButton: false,
 				isShow: false,
@@ -107,36 +107,46 @@
 				LoginSave({
 					params: data
 				}).then(result => {
-					console.log(result.data)
 					if (result.code === '200') {
 						uni.setStorageSync("Token", result.data)
-
-						// uni.setStorageSync("usercode", result.data.usercode)
-						// uni.setStorageSync("username", result.data.username)
-
+						const jwt = decode(result.data)
+						uni.setStorageSync("usercode", jwt.usercode)
+						uni.setStorageSync("username", jwt.username)
+						uni.setStorageSync("storg_code", jwt.storg_code)
+						uni.setStorageSync("storg_name", jwt.storg_name)
 						uni.redirectTo({
 							//鍏抽棴褰撳墠椤甸潰锛岃烦杞埌搴旂敤鍐呯殑鏌愪釜椤甸潰銆�
 							url: '../xtsy/index'
 						});
 						// uni.$u.toast(result.Message)
-					} else if (result.code === '302') {
-						const data2 = {
-							// token: uni.getStorageSync('Token'),
-							token: result.data,
-							rid: ''
-						}
-						ForcedOffline('', {
-							params: data2
-						}).then(res2 => {
-							if (res2.code === '200') {
-								console.log('鎴愬姛浜嗭紒')
-								uni.redirectTo({
-									//鍏抽棴褰撳墠椤甸潰锛岃烦杞埌搴旂敤鍐呯殑鏌愪釜椤甸潰銆�
-									url: '../xtsy/index'
-								});
-							}
-						})
-					} else {
+					} 
+					
+					// else if (result.code === '302') {
+					// 	const data2 = {
+					// 		// token: uni.getStorageSync('Token'),
+					// 		token: result.data,
+					// 		rid: ''
+					// 	}
+					// 	const jwt = decode(result.data)
+					// 	console.log(jwt, 2)
+					// 	uni.setStorageSync("usercode", jwt.usercode)
+					// 	uni.setStorageSync("username", jwt.username)
+					// 	uni.setStorageSync("storg_code", jwt.storg_code)
+					// 	uni.setStorageSync("storg_name", jwt.storg_name)
+
+					// 	ForcedOffline('', {
+					// 		params: data2
+					// 	}).then(res2 => {
+					// 		if (res2.code === '200') {
+					// 			uni.redirectTo({
+					// 				//鍏抽棴褰撳墠椤甸潰锛岃烦杞埌搴旂敤鍐呯殑鏌愪釜椤甸潰銆�
+					// 				url: '../xtsy/index'
+					// 			});
+					// 		}
+					// 	})
+					// }
+					 
+					 else {
 						this.isDisabledSubmitButton = false
 					}
 				})

--
Gitblit v1.9.3