jeter20131220 3 سال پیش
والد
کامیت
5564225414
1فایلهای تغییر یافته به همراه9 افزوده شده و 14 حذف شده
  1. 9 14
      desktop11/goto.js

+ 9 - 14
desktop11/goto.js

@@ -359,10 +359,15 @@ function statusChangeCallback(response) {
     html = "已登入 FB,並加入 WFU BLOG DEMO 應用程式<br/>";
 
     FB.api('/me?fields=id,name,email', function (response) {
-      console.log(response);
-      html += "會員暱稱:" + response.name + "<br/>";
-      html += "會員 email:" + response.email;
-      target.innerHTML = html;
+      console.log('FB API回傳資料: ' + JSON.stringify(response));
+      if (response.id) {
+        // 設定欄位預設值
+        document.getElementById("email").value = response.email;
+        document.getElementById("name").value = response.name;
+
+        // 隱藏FB登入按鈕
+        document.getElementById("fb_login").style.display = 'none';
+    }
     });
   }
 
@@ -387,18 +392,8 @@ $("#fb_login").click(function () {
     scope: 'public_profile,email'
 
   },
-  {
-    scope: 'public_profile,name'
-
-  }
   );
-  if (response.id) {
-    document.getElementById("email").value = response.email;
-    document.getElementById("name").value = response.name;
 
-    // 隱藏FB登入按鈕
-    document.getElementById("fb_login").style.display = 'none';
-  }
 });
 
 // 點擊登出