From 3f12c3518966a01f951094762ed93787acb52635 Mon Sep 17 00:00:00 2001 From: Ting-Jun Wang Date: Sat, 16 Jan 2021 19:59:20 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20change=20api=20method=20&=20Vue?= =?UTF-8?q?=E4=B8=AD=E4=BD=BF=E7=94=A8facebook=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api.py | 2 +- index.html | 43 +------------------------------------------ js/index.vue | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 43 deletions(-) diff --git a/api.py b/api.py index f977f7f..455179c 100644 --- a/api.py +++ b/api.py @@ -17,7 +17,7 @@ def facebookAuth(token): else: return False, None, None -@app.route('/courseTable', methods=["POST"]) +@app.route('/courseTable', methods=["GET"]) def get(): # 若 access code 通過 facebook 驗證 status, uid, name = facebookAuth(request.values['token']) diff --git a/index.html b/index.html index 97e9a71..c41a714 100644 --- a/index.html +++ b/index.html @@ -18,47 +18,6 @@ - - -
- - - - @@ -77,7 +36,7 @@
diff --git a/js/index.vue b/js/index.vue index 7dc7eee..5d7a6eb 100644 --- a/js/index.vue +++ b/js/index.vue @@ -7,6 +7,27 @@ var vm = new Vue({ 'selectDepartment': '', 'foundName': "", }, + created() { + window.fbAsyncInit = function() { + FB.init({ + appId : '', + cookie : true, + xfbml : true, + version : 'v9.0' + }); + + FB.AppEvents.logPageView(); + vm.checkLogin() + }; + + (function(d, s, id){ + var js, fjs = d.getElementsByTagName(s)[0]; + if (d.getElementById(id)) {return;} + js = d.createElement(s); js.id = id; + js.src = "https://connect.facebook.net/en_US/sdk.js"; + fjs.parentNode.insertBefore(js, fjs); + }(document, 'script', 'facebook-jssdk')); + }, mounted() { axios .get("./output.json") @@ -25,6 +46,18 @@ var vm = new Vue({ }) }, methods: { + 'checkLogin': function(){ + console.log("check login") + FB.getLoginStatus(function(response) { + vm.statusChangeCallback(response); + }); + }, + 'statusChangeCallback': function(response){ + console.log(response) + if(response.status == "connected"){ + + } + }, 'getTime': function(timeString){ ans = [] number = ""