fix: 修复 onCoinAdd 方法参数处理逻辑
调整事件参数处理方式,确保 payload 正确提取自 args 或 event 参数,以兼容不同调用场景。避免因参数结构不一致导致的硬币数量更新错误。
This commit is contained in:
@@ -161,13 +161,14 @@ export class MissionCardComp extends CCComp {
|
||||
this.cards_up?.on(NodeEventType.TOUCH_END, this.onUpgradeTouchEnd, this);
|
||||
this.cards_up?.on(NodeEventType.TOUCH_CANCEL, this.onUpgradeTouchCancel, this);
|
||||
}
|
||||
private onCoinAdd(args:any){
|
||||
if (args?.syncOnly) {
|
||||
private onCoinAdd(event: string, args: any){
|
||||
const payload = args ?? event;
|
||||
if (payload?.syncOnly) {
|
||||
this.updateCoinAndCostUI();
|
||||
this.playCoinChangeAnim((args?.delta ?? 0) > 0);
|
||||
this.playCoinChangeAnim((payload?.delta ?? 0) > 0);
|
||||
return;
|
||||
}
|
||||
const v = typeof args === 'number' ? args : (args?.delta ?? args?.value ?? 0);
|
||||
const v = typeof payload === 'number' ? payload : (payload?.delta ?? payload?.value ?? 0);
|
||||
if (v === 0) return;
|
||||
this.setMissionCoin(this.getMissionCoin() + v);
|
||||
this.updateCoinAndCostUI();
|
||||
|
||||
Reference in New Issue
Block a user