Browse Source

Signed-off-by: liuboyan <632697560@qq.com>
拦截器

liuboyan 4 years ago
parent
commit
3227f5ddd9
1 changed files with 3 additions and 2 deletions
  1. 3 2
      utils/request.js

+ 3 - 2
utils/request.js

@@ -4,7 +4,8 @@ const request = (url, data, method = 'GET') => {
 			'Content-Type': 'application/json',
 		}
 		const res = uni.getStorageSync('storage_key');
-		const token = res.token
+		// const token = res.token
+		const token = 'eyJ0eXAiOiJKc29uV2ViVG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJuYW1lIjoiTEJZIiwidG9rZW5fdHlwZSI6InRva2VuIiwidXNlcmlkIjoiMTMxNDc2OTM4MjQ5NjI3MjM4NCIsImFjY291bnQiOiJvQm56ODRoR3g3QTh2VVBqakNLWEJnQUhLb29nIiwiZXhwIjoxNjAyMzM5NDc3LCJuYmYiOjE2MDIzMTA2Nzd9.TyrNEt6F_tY36xtiLULCiExV2LaS7n_TUO-fb578Ae4'
 		if (token) {
 			header['token'] = 'Bearer ' + token
 		}
@@ -16,7 +17,7 @@ const request = (url, data, method = 'GET') => {
 			success: res => {
 				if (res.statusCode == 200) {
 					let data = res.data
-					if (data.code == 0) {
+					if (data.code == 0 || data.code == 200) {
 						resolve(res.data)
 					} else {
 						reject(res)