homeStaticFunc.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. var Global = require("Global");
  2. var MakeLoginXieYi = require("MakeLoginXieYi");
  3. var ProtocolLoginServer = require("ProtocolLoginServer");
  4. var popScence = require("popScence");
  5. var UIHelper = require("UIHelper");
  6. var LanguageKey = require("LanguageKey");
  7. var WebView = require("WebView");
  8. window.HomeStaticFunc = cc.Class({
  9. extends: cc.Component,
  10. properties: {
  11. },
  12. statics:{
  13. //回到前台
  14. applicationWillEnterForeground: function() {
  15. Global.print("HomeStaticFunc applicationWillEnterForeground::");
  16. cc.audioEngine.resumeAll();
  17. if (cc.find("Canvas")) {
  18. var homeStartJS = cc.vv.GetHallScript();
  19. if (homeStartJS) {
  20. //VIP充值后回到游戏,刷新界面
  21. if(homeStartJS._VIP && homeStartJS._VIP.active) {
  22. UIHelper.showWaitNode("reqServer", "");
  23. homeStartJS._VIP.runAction(cc.sequence(cc.delayTime(2), cc.callFunc(function() {
  24. homeStartJS._VIP.getComponent("homeVIP").reqVipInfo(true, true);
  25. })));
  26. }
  27. if (homeStartJS._kaijiang && homeStartJS._kaijiang.active) { //开奖直接购买回调查询
  28. homeStartJS._kaijiang.getChildByName("rootNode").getChildByName("plane_list").getChildByName("plane1").getComponent("tradePlane").checkPayResult();
  29. }
  30. //homeStartJS.checkKanJiaCode()
  31. }
  32. }
  33. },
  34. //监听安卓返回键事件
  35. onKeyBack: function() {
  36. Global.print("homeStaticFunc_onKeyDown")
  37. if(cc.sys.os == cc.sys.OS_ANDROID && cc.sys.isNative){
  38. if(WebView && WebView.isActive()){
  39. WebView.close();
  40. Global.print("homeStaticFunc_onKeyDown WebView.close");
  41. return;
  42. }
  43. var Ok = function() {
  44. cc.game.end();
  45. };
  46. popScence.initPopScence(LanguageKey.PopScence.rootNode_tip_label0, null, Ok, function(){});
  47. }
  48. },
  49. //TODO 苹果支付验证
  50. //需要将此信息传给服务端进行支付成功的验证
  51. AppPayCheckReceipt: function(receipt) {
  52. var OrderID = Global.getLocalStorageVaule("OrderID", "0");
  53. var orderData = ProtocolLoginServer.CMD_GP_SendIOSVerify.data();
  54. orderData.UserID = cc.vv.globalUserInfo.getUserID();
  55. orderData.OrderID = parseInt(OrderID);
  56. orderData.verifyKey = receipt;
  57. var dataOrder= MakeLoginXieYi.makeSendIOSVerify(orderData);
  58. var homeStartNode = cc.vv.GetHallScript();
  59. if (homeStartNode) {
  60. homeStartNode.sendDataByMainSub(ProtocolLoginServer.MDM_GP_USER_SERVICE, ProtocolLoginServer.SUB_GP_SEND_IOS_VERIFY, dataOrder);
  61. }
  62. }
  63. }
  64. });
  65. module.exports = HomeStaticFunc;