68 lines
2.1 KiB
JavaScript
68 lines
2.1 KiB
JavaScript
import GameModel from "../ts/core/GameModel";
|
|
import MsgAlert from "../ts/game/msg/MsgAlert";
|
|
import SKNetTask,{NetCode} from "../ts/gear_2.3.4/net/SKNetTask";
|
|
import SKDataUtil from "../ts/gear_2.3.4/util/SKDataUtil";
|
|
import SKUIUtil from "../ts/gear_2.3.4/util/SKUIUtil";
|
|
|
|
cc.Class({
|
|
extends: cc.Component,
|
|
properties: {
|
|
money_label: cc.Label,
|
|
name_label: cc.Label,
|
|
web_view: cc.WebView,
|
|
},
|
|
|
|
setData(data) {
|
|
this.data = data;
|
|
let item = GameModel.conf_charge[data.goodsid];
|
|
if (item) {
|
|
this.name_label.string = item.name;
|
|
this.money_label.string = '¥' + item.money.toFixed(2);
|
|
}
|
|
else {
|
|
this.name_label.string = 'XianYu' + data.money * 100;
|
|
this.money_label.string = '¥' + data.money.toFixed(2);
|
|
}
|
|
},
|
|
|
|
openWebView(pay_bankcode, webview) {
|
|
this.data.pay_bankcode = pay_bankcode;
|
|
let self=this;
|
|
SKNetTask.getWithJson("/charge",this.data,(code,result)=>{
|
|
if(code != NetCode.SUCCESS){
|
|
MsgAlert.addMsg(`充值失敗,請檢查網絡!錯誤碼[${code}]`);
|
|
return;
|
|
}
|
|
if(!result.data){
|
|
return;
|
|
}
|
|
let url = result.data.url;
|
|
if(SKDataUtil.isEmptyString(url)){
|
|
return;
|
|
}
|
|
if (webview) {
|
|
if(SKUIUtil.isValid(self.web_view.node)){
|
|
self.web_view.node.active = true;
|
|
self.web_view.url = encodeURI(url);
|
|
}
|
|
} else {
|
|
cc.sys.openURL(encodeURI(url));
|
|
}
|
|
});
|
|
},
|
|
|
|
onButtonClick(event, param) {
|
|
if (param == 'close') {
|
|
this.node.destroy();
|
|
} else if (param == 'ali') {
|
|
this.openWebView(220);
|
|
} else if (param == 'ali_saoma') {
|
|
this.openWebView(210, true);
|
|
} else if (param == 'wx') {
|
|
this.openWebView(330);
|
|
} else if (param == 'wx_saoma') {
|
|
this.openWebView(310, true);
|
|
}
|
|
},
|
|
});
|