From 5a7e15419e97fcd07a1a6edf3fa5958be80fe877 Mon Sep 17 00:00:00 2001 From: Ting-Jun Wang Date: Sat, 16 Jan 2021 22:34:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E7=82=BA=E8=87=AA?= =?UTF-8?q?=E8=A8=82=E7=99=BB=E5=85=A5Facebook=E6=8C=89=E9=88=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 13 ++++++++----- js/index.vue | 21 +++++++++++++++++---- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index d08ce62..206c0c9 100644 --- a/index.html +++ b/index.html @@ -20,7 +20,7 @@ - +
-
+
+
@@ -112,6 +114,7 @@
+ diff --git a/js/index.vue b/js/index.vue index a9f3dda..bf0d402 100644 --- a/js/index.vue +++ b/js/index.vue @@ -1,11 +1,12 @@ var vm = new Vue({ - el: "#table", + el: "#main", data: { 'courses': [], 'selectCourses': [], 'departments': [], 'selectDepartment': '', 'foundName': "", + "user": "", 'token': "" }, created() { @@ -47,6 +48,17 @@ var vm = new Vue({ }) }, methods: { + 'login': function(){ + FB.login(function(){ + vm.getCourseTable() + }) + }, + 'logout': function(){ + FB.logout(function(response) { + vm.user = "" + vm.token = "" + }); + }, 'getCourseTable': function(){ FB.getLoginStatus(function(response) { vm.statusChangeCallback(response); @@ -55,6 +67,9 @@ var vm = new Vue({ 'statusChangeCallback': function(response){ if(response.status == "connected"){ this.token = response.authResponse.accessToken + + FB.api('/me', function(response){vm.user = response.name}) + fetch('https://api.snsd0805.com/courseTable?token='+this.token) .then(function(response){ return response.json() @@ -94,9 +109,7 @@ var vm = new Vue({ }) }else{ - FB.login(function(response){ - vm.getCourseTable() - }) + this.login() } }, 'getTime': function(timeString){