Kaynağa Gözat

修改uniapp登录接口

zhoupeng 2 yıl önce
ebeveyn
işleme
8a5e00b095

+ 1 - 1
chaunyi_opc/opc_da/src/main/resources/static/app/index.html

@@ -2,4 +2,4 @@
 				.supports('top: constant(a)'))
 			document.write(
 				'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
-				(coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=./static/index.63b34199.css><link rel=stylesheet href=./static/luckysheet/dist/plugins/plugins.css><link rel=stylesheet href=./static/luckysheet/dist/plugins/css/pluginsCss.css><link rel=stylesheet href=./static/luckysheet/dist/css/luckysheet.css><link rel=stylesheet href=./static/luckysheet/dist/assets/iconfont/iconfont.css><script src=./static/luckysheet/dist/luckysheet.umd.js></script><script src=./static/luckysheet/dist/plugins/js/plugin.js></script></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=./static/js/chunk-vendors.35954aaa.js></script><script src=./static/js/index.47e87224.js></script></body></html>
+				(coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=./static/index.63b34199.css><link rel=stylesheet href=./static/luckysheet/dist/plugins/plugins.css><link rel=stylesheet href=./static/luckysheet/dist/plugins/css/pluginsCss.css><link rel=stylesheet href=./static/luckysheet/dist/css/luckysheet.css><link rel=stylesheet href=./static/luckysheet/dist/assets/iconfont/iconfont.css><script src=./static/luckysheet/dist/luckysheet.umd.js></script><script src=./static/luckysheet/dist/plugins/js/plugin.js></script></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=./static/js/chunk-vendors.35954aaa.js></script><script src=./static/js/index.4858c863.js></script></body></html>

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
chaunyi_opc/opc_da/src/main/resources/static/app/static/js/index.4858c863.js


Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
chaunyi_opc/opc_da/src/main/resources/static/app/static/js/pages-login-index.d1dfc2d5.js


+ 22 - 7
reado-app/pages/login/index.vue

@@ -29,7 +29,7 @@
 					</u-form-item>
 					<!-- #endif -->
 					<view class="form-btn">
-						<u-button type="primary" text="登录" @click="login"></u-button>
+						<u-button type="primary" text="登录" @click="getHttpPublicKey"></u-button>
 					</view>
 				</u--form>
 			</view>
@@ -50,7 +50,8 @@
 				loginForm: {
 					userName: null,
 					password: null,
-					verifyCode: null
+					verifyCode: null,
+					publicKey: null
 				},
 				//表单验证
 				rules: {
@@ -79,7 +80,8 @@
 			this.loginForm = {
 				userName: null,
 				password: null,
-				verifyCode: null
+				verifyCode: null,
+				publicKey: null
 			}
 		},
 		computed: {
@@ -89,7 +91,8 @@
 		},
 		methods: {
 			//登录按钮
-			login() {
+			login(publicKey) {
+				this.loginForm.publicKey = publicKey
 				this.$refs.loginForm.validate().then(res => {
 					this.$store.dispatch('user/login', this.loginForm).then(res => {
 						if (res.data.code === 200) {
@@ -98,8 +101,8 @@
 							})
 						} else {
 							this.$refs.uToast.show({
-								message:res.data.msg,
-								duration:1000
+								message: res.data.msg,
+								duration: 1000
 							})
 							this.getCodeImage()
 							this.loginForm.verifyCode = null
@@ -109,6 +112,18 @@
 					uni.$u.toast(errors[0].message)
 				})
 			},
+			getHttpPublicKey() {
+				this.$store.dispatch('user/getPubKey').then(res => {
+					if (res.data.code === 200) {
+						this.login(res.data.data);
+					} else {
+						this.$refs.uToast.show({
+							message: res.data.msg ? res.data.msg : "请重新刷新获取公钥",
+							duration: 1000
+						})
+					}
+				})
+			},
 			//获取验证码接口
 			getCodeImage() {
 				this.$store.dispatch('user/getCodeImage')
@@ -150,4 +165,4 @@
 		position: absolute;
 		right: 0
 	}
-</style>
+</style>

+ 9 - 6
reado-app/store/modules/user.js

@@ -18,7 +18,7 @@ const user = {
 		// 用户ID
 		userId: getUid(),
 		// 用户名
-		userName:null,
+		userName: null,
 		// 验证码
 		codeUrl: null,
 		// 验证码登录参数
@@ -77,8 +77,8 @@ const user = {
 			return new Promise((resolve, reject) => {
 				uni.$http.get('/user/getPublicKey').then(res => {
 					if (res.data.code === 200) {
-						const key=res.data.data.replace('\r\n','')
-						commit('SET_PUBKEY',key)
+						const key = res.data.data.replace('\r\n', '')
+						commit('SET_PUBKEY', key)
 						setPubKey(key)
 						resolve(res)
 					}
@@ -91,7 +91,7 @@ const user = {
 			commit,
 			state
 		}, data) {
-			const pwd = encrypt(data.password)
+			const pwd = encrypt(data.password, data.publicKey)
 			const obj = {
 				userName: data.userName,
 				password: pwd,
@@ -102,7 +102,10 @@ const user = {
 				uni.$http.post('/user/phoneUserLogin', obj).then(res => {
 					if (res.data.code === 200) {
 						const token = res.data.data.token
-						const {userId,userName} = res.data.data.user
+						const {
+							userId,
+							userName
+						} = res.data.data.user
 						commit('SET_TOKEN', token)
 						setToken(token)
 						commit('SET_USER_ID', userId)
@@ -147,4 +150,4 @@ export default {
 	state,
 	mutations,
 	actions
-}
+}

+ 3 - 8
reado-app/utils/jsencrypt.js

@@ -1,13 +1,8 @@
 import JSEncrypt from '@/node_modules/jsencrypt/bin/jsencrypt.js'
-import {
-	getPubKey
-} from '@/utils/auth.js'
 
-//获取公钥
-const publickey = getPubKey()
 
-export function encrypt(txt) {
-	if(!publickey){
+export function encrypt(txt, publickey) {
+	if (!publickey) {
 		return "";
 	}
 	const encryptor = new JSEncrypt()
@@ -15,4 +10,4 @@ export function encrypt(txt) {
 	encryptor.setPublicKey(publickey)
 	// 对数据进行加密
 	return encryptor.encrypt(txt.toString())
-}
+}

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor