Browse Source

添加QQ昵称头像上报

smallqiang 6 years ago
parent
commit
65dcb20940

+ 3 - 3
assets/scene/login.fire

@@ -41,8 +41,8 @@
     },
     "_scale": {
       "__type__": "cc.Vec3",
-      "x": 0.36656671664167917,
-      "y": 0.36656671664167917,
+      "x": 0.37582884507310527,
+      "y": 0.37582884507310527,
       "z": 1
     },
     "_quat": {
@@ -1078,6 +1078,6 @@
     },
     "_updating": false,
     "_canRetry": false,
-    "_id": "37O7msDM9HpLBBvNmpzvH1"
+    "_id": "074YBuQiJOZ4WwwaLB4uF2"
   }
 ]

+ 4 - 2
assets/scripts/game/Game.js

@@ -68,8 +68,10 @@ cc.Class({
                 messageType: 6,
                 winSize: GameGlobal.winSize
             });
-        } else if (CC_QQPLAY && window.GameStatusInfo) {
-            GameStatusInfo.startMs = ((new Date()).getTime()).toString()
+        } else if (CC_QQPLAY) {
+            if (window.GameStatusInfo) {
+                GameStatusInfo.startMs = ((new Date()).getTime()).toString();
+            }
         }
 
         // 引导界面

+ 14 - 1
assets/scripts/net/Api.js

@@ -116,6 +116,11 @@ class Api {
             if (i == arrLen - 1) {
                 newUrl += '/qq';
             }
+
+            if (i == 0) {
+                continue;
+            }
+
             newUrl += '/';
             newUrl += urlArr[i];
         }
@@ -198,6 +203,14 @@ class Api {
                 if (res.statusCode === 200) {
                     let bodyStr = res.text();
                     let bodyObjct = JSON.parse(bodyStr);
+
+                    if (bodyObjct == undefined) {
+                        if (onFail != undefined) {
+                            onFail(res.statusCode, '请求失败');
+                        }
+                        return;
+                    }
+
                     console.log('url :' + url, 'res: ' + res);
                     if (bodyObjct.code === ResponseStateCode.LOGIN_INVALIDATE) {
                         GameGlobal.needLogin = true;
@@ -212,7 +225,7 @@ class Api {
                     } else {
                         if (onFail != undefined) {
                             onFail(bodyObjct.code, bodyObjct.msg);
-                            GameGlobal.commonAlert.showCommonErrorAlert('url' + url + ' login error code: ' + errCode + 'login error msg: ' + errMsg);
+                            // GameGlobal.commonAlert.showCommonErrorAlert('url' + url + ' login error code: ' + errCode + 'login error msg: ' + errMsg);
                         }
                     }
                 } else {

+ 17 - 0
assets/scripts/net/LoginApi.js

@@ -89,6 +89,23 @@ class LoginApi {
         }
         Api.httpGet(requestBody);
     }
+
+    //QQ上报昵称和头像
+    static getUpdateNickOrHead(nick, head, success, fail) {
+
+        let data = {
+            nick: nick,
+            head: head
+        };
+
+        let requestBody = {
+            url: '/auth/updateNickOrHead.do',
+            data: data,
+            success: success,
+            fail: fail,
+        };
+        Api.httpPost(requestBody);
+    }
 }
 
 module.exports = LoginApi;

+ 7 - 0
assets/scripts/rank/GameFriendRank.js

@@ -1,3 +1,4 @@
+const LoginApi = require('../net/LoginApi');
 
 cc.Class({
     extends: cc.Component,
@@ -100,6 +101,12 @@ cc.Class({
     },
 
     _setupMeData() {
+        LoginApi.getUpdateNickOrHead(this.myData.nick,this.myData.url, (res) => {
+
+        }, (error) => {
+
+        });
+
         this.meNode.active = true;
         this.meNode.getComponent('GameRankItem').initQQData(this.myData, true);
     },