Explorar el Código

Merge branch 'master' of http://118.178.135.110:3000/fish/tower_client

# Conflicts:
#	assets/script/game/ui/tower/TowerUI.ts
wujia hace 6 meses
padre
commit
d4fdb5cfa9

+ 45 - 45
assets/script/game/common/LoginManager.ts

@@ -21,7 +21,7 @@ const Macro = {
     cur_token: "cur_token",                 //当前用户token
 }
 
-//业务逻辑层的NetMgr
+//登录及登录后网络业务逻辑  网络业务逻辑层的NetMgr
 
 export class LoginManager {
     private _key = 'dd2edb87ea9eb7DFa32fd4IO0572ZX76d3a1fab861c1d5qishituan';
@@ -187,7 +187,9 @@ export class LoginManager {
             if (data.get_mails) {
                 MailData.setData(data.get_mails)
             }
-
+            if (data.role_bag && data.role_bag.roles) {
+                RoleData.setData(data.role_bag.roles)
+            }
             if (data.inverntory) {
                 if (data.inverntory.material) {
                     GoodsData.setAllGoods(data.inverntory.material)
@@ -310,51 +312,49 @@ export class LoginManager {
                     } else {
                         postData.back()
                     }
-                    if (resp.data.role_bag && resp.data.role_bag.roles) {
-                        RoleData.setData(resp.data.role_bag.roles)
-                    }
 
-                    if (resp.data.have_pay) {
-                        if (!resp.data.pay_notify) {
-                            this.sendPost('user', 'get_cash', (data) => {
-                                if (data.code) {
-                                    return;
-                                }
-                                if (data.ext_pay_info) {
-                                    let awardsMsg = [];
 
-                                    if (data.ext_pay_info.awards) {
-                                        for (const i in data.ext_pay_info.awards) {
-                                            awardsMsg.push(data.ext_pay_info.awards[i]);
-                                        }
-                                    }
-                                    if (awardsMsg.length > 0) {
-                                       // UserData.BackAwards(awardsMsg);
-                                    }
-                                    if (data.ext_pay_info.cash) {
-                                        awardsMsg.push(['user', 'cash', data.ext_pay_info.cash]);
-                                    }
-                                    if (awardsMsg.length > 0) {
-                                        // Framework.layer.open(ViewID.Reward, null, awardsMsg);
-                                    }
-                                }
-                                if (data.cash) {
-                                    UserData['status']['cash'] = data.cash;
-                                   // Framework.event.fireEvent(GameEvent.Property_Renew, 'cash')
-                                }
-                                if (data.month_card) {
-                                    UserData['activity']['month_card'] = data.month_card;
-                                }
-                                if (data.life_card) {
-                                    UserData['activity']['life_card'] = data.life_card;
-                                }
-                                if (data.fund) {
-                                    UserData['activity']['fund'] = data.fund;
-                                }
-                               // Framework.event.fireEvent(GameEvent.Recharge_Referesh);
-                            }, {});
-                        }
-                    }
+                    // if (resp.data.have_pay) {
+                    //     if (!resp.data.pay_notify) {
+                    //         this.sendPost('user', 'get_cash', (data) => {
+                    //             if (data.code) {
+                    //                 return;
+                    //             }
+                    //             if (data.ext_pay_info) {
+                    //                 let awardsMsg = [];
+
+                    //                 if (data.ext_pay_info.awards) {
+                    //                     for (const i in data.ext_pay_info.awards) {
+                    //                         awardsMsg.push(data.ext_pay_info.awards[i]);
+                    //                     }
+                    //                 }
+                    //                 if (awardsMsg.length > 0) {
+                    //                    // UserData.BackAwards(awardsMsg);
+                    //                 }
+                    //                 if (data.ext_pay_info.cash) {
+                    //                     awardsMsg.push(['user', 'cash', data.ext_pay_info.cash]);
+                    //                 }
+                    //                 if (awardsMsg.length > 0) {
+                    //                     // Framework.layer.open(ViewID.Reward, null, awardsMsg);
+                    //                 }
+                    //             }
+                    //             if (data.cash) {
+                    //                 UserData['status']['cash'] = data.cash;
+                    //                // Framework.event.fireEvent(GameEvent.Property_Renew, 'cash')
+                    //             }
+                    //             if (data.month_card) {
+                    //                 UserData['activity']['month_card'] = data.month_card;
+                    //             }
+                    //             if (data.life_card) {
+                    //                 UserData['activity']['life_card'] = data.life_card;
+                    //             }
+                    //             if (data.fund) {
+                    //                 UserData['activity']['fund'] = data.fund;
+                    //             }
+                    //            // Framework.event.fireEvent(GameEvent.Recharge_Referesh);
+                    //         }, {});
+                    //     }
+                    // }
                     nextPostTask && nextPostTask();
                 } else {
                     if (postData.act == 'auto_open') {

+ 8 - 4
assets/script/game/data/RoleData.ts

@@ -14,11 +14,15 @@ interface RoleServer {
 class Data {
 
     private _roles: { [id: string]: RoleServer } = {};
-    setData(data: RoleServer[]): void {
+    setData(data: {[id: string]:RoleServer}): void {
         if (data) {
-            data.forEach((v,k) => {
-                this._roles[k] = v;
-            });
+           for(const id in data) {
+                if (data.hasOwnProperty(id)) {
+                    const role = data[id];
+                    this._roles[id] = role;
+                    // console.log(`ID: ${id}, Name: ${role.name}, Level: ${role.level}`);
+                }
+           }
         }
     }
 

+ 4 - 0
assets/script/game/manager/RoleManager.ts

@@ -1,9 +1,13 @@
+import { LoginMgr } from "../common/LoginManager";
 
 
 //角色管理器
 export class RoleManager {
     //抽一个英雄
     static getNewRole(){
+        LoginMgr.sendPost('tavern', 'get', (data) => {
+            console.log(data);
+        }, {})
         return false;
     }
 }

+ 2 - 5
assets/script/game/ui/tower/TowerUI.ts

@@ -24,7 +24,7 @@ import { LoginManager, LoginMgr } from '../../common/LoginManager';
 import { MailManager } from '../../manager/MailManager';
 import { ViewID } from '../../../framework/config/LayerConf';
 import { MailData } from '../../data/MailData';
-
+import { RoleManager } from '../../manager/RoleManager';
 
 //地图比例尺 1:70
 let mapScale = 72;
@@ -1010,11 +1010,8 @@ export class TowerUI extends BaseView {
 		let target: any = event.target;
 		if (target.name == 'mask') {
 			Framework.layer.close(this);
-
 		} else if (target.name == 'hanghui_btn') {
-			LoginMgr.sendPost('tavern', 'get', (data) => {
-				console.log(data);
-			}, {})
+			RoleManager.getNewRole()
 		} else if (target.name == 'hero_btn') {
 			Framework.layer.open(ViewID.HeroList);
 		} else if (target.name == 'material_btn') {