Files
fc/dev/project/library/imports/84/84030079-6efc-456e-9538-c2b7c9fbc364.js
T

374 lines
10 KiB
JavaScript
Raw Normal View History

2026-05-24 10:21:26 +08:00
"use strict";
cc._RF.push(module, '84030B5bvxFbpU4wrfJ+8Nk', 'home.mod');
// Scripts/mod/home/home.mod.js
"use strict";
/******************************************************************
*
* 家园模块
*
******************************************************************/
var HomeDefine = require("home.define");
var BridgeController = require("bridge.controller");
var RoleController = require("role_controller");
var HomeModel = cc.Class({
"extends": BridgeController,
// 初始化配置数据
initConfig: function initConfig() {},
// 注册监听事件
registerEvents: function registerEvents() {},
// 注册协议接受事件
registerProtocals: function registerProtocals() {
// 家园
this.RegisterProtocal(26031, this.handle26031.bind(this)); // 家园信息
this.RegisterProtocal(26032, this.handle26032.bind(this)); // 访客信息
this.RegisterProtocal(26033, this.handle26033.bind(this)); // 更新推送
this.RegisterProtocal(26034, this.handle26034.bind(this)); // 奖励领取
this.RegisterProtocal(26035, this.handle26035.bind(this)); // 家园改名
this.RegisterProtocal(26036, this.handle26036.bind(this)); // 家园拜访
this.RegisterProtocal(26037, this.handle26037.bind(this)); // 修改主题
this.RegisterProtocal(26038, this.handle26038.bind(this)); // 访客提示
// 亲密度
this.RegisterProtocal(29300, this.handle29300.bind(this)); // 亲密度信息
this.RegisterProtocal(29301, this.handle29301.bind(this)); // 亲密度推送
this.RegisterProtocal(29306, this.handle29306.bind(this)); // 密谈信息
this.RegisterProtocal(29302, this.handle29302.bind(this)); // 密谈信息
this.RegisterProtocal(29303, this.handle29303.bind(this)); // 领取奖励
this.RegisterProtocal(29304, this.handle29304.bind(this)); // 使用道具
this.RegisterProtocal(29305, this.handle29305.bind(this)); // 档案信息
this.RegisterProtocal(29307, this.handle29307.bind(this)); // 档案信息
},
// 从服务器初始化数据
reqBaseFromServer: function reqBaseFromServer(_cb) {
var _this = this;
// 配置加载
var cfgs = ["homeland_data",
// 家园
"favor_data",
// 亲密度
"halidom_data" // 基础核心
];
this.loadConfigs(cfgs, function (_ret, _data) {
_this.reqIntimacyData();
_this.reqHomeData(_cb);
});
},
// 更新当前家园信息
updateHomeData: function updateHomeData(_data) {
// 判空
if (nx.dt.objEmpty(_data)) {
return;
}
// 是不是自己家
var RC = RoleController.getInstance();
var Ro = RC.getRoleVo();
if (Ro && Ro.rid == _data.rid && Ro.srv_id == _data.srv_id) {
nx.bridge.vset("HomeMine", true);
} else {
nx.bridge.vset("HomeMine", false);
}
// 基础信息
nx.bridge.vset("HomeName", _data.name || "");
nx.bridge.vset("HomeOwnerRid", _data.rid || 0);
nx.bridge.vset("HomeOwnerSrv", _data.srv_id || "");
nx.bridge.vset("HomeOwnerName", _data.role_name || "");
nx.bridge.vset("HomeVisitors", _data.visitor_num || 0);
nx.bridge.vset("HomeThemeList", _data.look_list || []);
nx.bridge.vset("HomeTheme", _data.look_id || 1);
nx.bridge.vset("HomeRewards", _data.rewards || []);
nx.bridge.vset("HomePartners", _data.partner_bids || []);
nx.bridge.vset("HomeEditing", false);
// 提示信息刷新
this.updateTipView();
},
// 获取家园信息
reqHomeData: function reqHomeData(_cb) {
// 锁定中不请求数据
var lkifo = nx.bridge.vget("HomeLocked");
if (nx.dt.objNEmpty(lkifo)) {
nx.dt.fnInvoke(_cb, true);
return;
}
this.CB26031 = _cb;
this.SendProtocal(26031, {}, _cb);
},
// 家园信息返回
handle26031: function handle26031(_data) {
// 失败判定
if (!this.isGoodData(_data)) {
return;
}
this.updateHomeData(_data);
},
// 获取访客信息
reqVisitorList: function reqVisitorList(_cb) {
this.SendProtocal(26032, {}, _cb);
},
// 访客信息返回
handle26032: function handle26032(_data) {
// 失败判定
if (!this.isGoodData(_data)) {
return;
}
},
handle26038: function handle26038(_data) {
nx.mTip.openTip("home.footmark.new", _data && _data.code == 1);
},
// 更新推送
handle26033: function handle26033(_data) {
if (nx.dt.objEmpty(_data)) {
return;
}
nx.bridge.vset("HomeThemeList", _data.look_list);
nx.bridge.vset("HomeTheme", _data.look_id);
nx.bridge.vset("HomeRewards", _data.rewards);
nx.bridge.vset("HomePartners", _data.partner_bids);
},
// 奖励领取
reqGetReward: function reqGetReward(_id, _cb) {
var args = {
rid: nx.bridge.vget("HomeOwnerRid"),
srv_id: nx.bridge.vget("HomeOwnerSrv"),
reward_id: _id
};
this.SendProtocal(26034, args, _cb);
},
// 奖励领取
handle26034: function handle26034(_data) {
// 失败判定
if (!this.isGoodData(_data)) {
return;
}
},
// 改名
reqChangeName: function reqChangeName(_txt, _cb) {
this.SendProtocal(26035, {
name: _txt
}, _cb);
},
// 改名回复
handle26035: function handle26035(_data) {
// 失败判定
if (!this.isGoodData(_data)) {
return;
}
nx.bridge.vset("HomeName", _data.name);
},
// 拜访家园
reqVisitHome: function reqVisitHome(_srvId, _rid, _cb) {
this.SendProtocal(26036, {
rid: _rid,
srv_id: _srvId
}, _cb);
},
// 家园拜访
handle26036: function handle26036(_data) {
// 失败判定
if (!this.isGoodData(_data)) {
return;
}
// 成功
this.updateHomeData(_data);
},
// 改主题
reqChangeTheme: function reqChangeTheme(_id, _cb) {
this.SendProtocal(26037, {
look_id: _id
}, _cb);
},
// 改主题回复
handle26037: function handle26037(_data) {
// 失败判定
if (!this.isGoodData(_data)) {
return;
}
nx.bridge.vset("HomeTheme", _data.look_id);
},
// 主题编辑切换
togHomeEdit: function togHomeEdit() {
var open = nx.bridge.vget("HomeEditing");
nx.bridge.vset("HomeEditing", !open);
},
// 提示信息刷新
updateTipView: function updateTipView() {},
// ========================================================
// 闺房 / 亲密度
// ========================================================
// 闺蜜更新
setGirls: function setGirls(_list, _reset) {
// 重置
if (_reset) {
nx.bridge.vset("HomeGirls", _list || []);
return;
}
// 部分更新
var ids = [];
var arr = nx.bridge.vget("HomeGirls");
for (var i = 0; i < _list.length; ++i) {
var tm = _list[i];
ids.push(tm.partner_id);
for (var k = 0; k < arr.length; ++k) {
var girl = arr[k];
if (tm.partner_id == girl.partner_id) {
arr[k] = tm;
break;
}
}
}
nx.bridge.vset("HomeGirls", arr, false);
// 当前通告
var cur = nx.bridge.vget("HomeGirlShow");
if (nx.dt.arrMember(ids, cur)) {
nx.bridge.vnotify("HomeGirlShow");
}
},
// 当前闺蜜设定
setCurrentGirl: function setCurrentGirl(_pid) {
var pid = nx.bridge.vget("HomeGirlShow");
if (pid != _pid) {
nx.bridge.vset("HomeGirlShow", _pid);
}
},
// 获取当前闺蜜
queryGirl: function queryGirl(_pid) {
var arr = nx.bridge.vget("HomeGirls");
for (var i in arr) {
var gr = arr[i];
if (gr && gr.partner_id == _pid) {
return gr;
}
}
return null;
},
// 亲密度信息
reqIntimacyData: function reqIntimacyData(_cb) {
this.SendProtocal(29300, {}, _cb);
},
// 亲密度信息
handle29300: function handle29300(_data) {
// 失败判定
if (!this.isGoodData(_data)) {
return;
}
// 成功
this.setGirls(_data.intimacy_list, true);
},
// 亲密度推送
handle29301: function handle29301(_data) {
if (nx.dt.objEmpty(_data) || nx.dt.arrEmpty(_data.intimacy_list)) {
return;
}
this.setGirls(_data.intimacy_list, false);
},
// 使用道具
reqUseIntimacyItem: function reqUseIntimacyItem(_bid, _num, _cb) {
this.SendProtocal(29304, {
partner_id: nx.bridge.vget("HomeGirlShow"),
item_id: _bid,
num: _num
}, _cb);
},
// 使用道具
handle29304: function handle29304(_data) {
// 失败判定
if (!this.isGoodData(_data)) {
return;
}
},
// 领取奖励
reqGetIntimacyReward: function reqGetIntimacyReward(_pid, _tid, _cb) {
this.SendProtocal(29303, {
partner_id: nx.bridge.vget("HomeGirlShow"),
profile_id: _pid,
talk_id: _tid
}, _cb);
},
// 领取奖励
handle29303: function handle29303(_data) {
// 失败判定
if (!this.isGoodData(_data)) {
return;
}
},
// 密谈
reqStoryData: function reqStoryData(_pid, _cb) {
this.SendProtocal(29306, {
partner_id: nx.bridge.vget("HomeGirlShow"),
profile_id: _pid
}, _cb);
},
// 密谈返回
handle29306: function handle29306(_data) {
// 失败判定
if (!this.isGoodData(_data)) {
return;
}
},
// 密谈
commitStoryOp: function commitStoryOp(_pid, _tid, _cb) {
this.SendProtocal(29302, {
partner_id: nx.bridge.vget("HomeGirlShow"),
profile_id: _pid,
talk_id: _tid
}, _cb);
},
// 密谈返回
handle29302: function handle29302(_data) {
// 失败判定
if (!this.isGoodData(_data)) {
return;
}
},
// 档案信息
reqArchiveInfo: function reqArchiveInfo(_pid, _cb) {
this.SendProtocal(29305, {
partner_id: nx.bridge.vget("HomeGirlShow"),
profile_id: _pid
}, _cb);
},
// 档案信息返回
handle29305: function handle29305(_data) {
// 失败判定
if (!this.isGoodData(_data)) {
return;
}
},
// 档案信息返回
handle29307: function handle29307(_data) {
if (!nx.frame.vget("hMode")) {
nx.bridge.vset("HOpened", false);
return;
}
// 失败判定
if (!this.isGoodData(_data)) {
return;
}
// // 未开启
this.partners = _data.mood_list || [];
if (nx.dt.arrEmpty(this.partners)) {
nx.bridge.vset("HOpened", false);
return;
}
// // 重置
nx.bridge.vset("HOpened", true);
}
});
module.exports = HomeModel;
cc._RF.pop();