Browse Source

增加mac地址验证

sophieChenyx 6 years ago
parent
commit
abb72fee3a
1 changed files with 21 additions and 8 deletions
  1. 21 8
      src/util/API/APIClient.js

+ 21 - 8
src/util/API/APIClient.js

@@ -97,12 +97,15 @@ class APIClient {
 
 	// 根据课程获取课列表
 	static getLessonList(courseId, callback) {
-		let macUrl = '';
-		WinBoxAPI.getMacUrl( (res) => {
-			macUrl = res;
-		} )
-		let params = APIClient.addCacheParam({});
-		AJAXHelper.get(`/course/${courseId}/lessons`, { params, mac: macUrl}, callback);
+    APIClient.getUserMacUrl( ( mac ) => {
+      let params = APIClient.addCacheParam({});
+      params.mac = mac;
+      console.log('params',params)
+      AJAXHelper.get(`/course/${courseId}/lessons`, params , callback);
+    });
+    // let params = APIClient.addCacheParam({});
+    // console.log('params',params)
+    // AJAXHelper.get(`/course/${courseId}/lessons`, { params }, callback);
 	}
 
 	// 获取课程详情
@@ -181,10 +184,20 @@ class APIClient {
 	  AJAXHelper.post('/callback/event', params, callback);
 	}
 
+	// 获取用户的mac地址
+	static getUserMacUrl(callback) {
+		let mac = '';
+		WinBoxAPI.getMacUrl((isTrue, res) => {
+			mac = res.data;
+			callback( mac );
+		})
+	}
+
 	// 获取用户的下载记录
 	static getUserDownloadList(callback) {
-    let params = { mac: WinBoxAPI.getMacUrl()}
-		AJAXHelper.get('/callback/download/list', { params }, callback);
+		APIClient.getUserMacUrl( ( mac ) => {
+      AJAXHelper.get('/callback/download/list', { mac: mac }, callback);
+		});
 	}
 
 }