cc.Class({ // extends: cc.BaseClass, // properties: {}, // ctor: function () { // this.m_szWXCode = ""; // //'resources/Audio/' // this.m_BasicSound = new Array( // ['BGM0', 'BGM0'], // ['BGM1', 'BGM1'], // ['Button', 'button'], // ['Jet', 'Jet'], // ['SendCard', 'sendcard'], // ); // }, extends: cc.BaseClass, // 继承自框架基础类(提供基础功能如事件管理) properties: {}, // 属性声明区块(当前为空,可在子类中添加编辑器可配置属性) ctor: function () { // 构造函数 // 微信授权码存储(可能用于登录/支付流程) this.m_szWXCode = ""; this.isLogining = false; // 基础音效资源配置(已注释的根路径可能在实际加载时拼接) /* 数据结构说明: [ [资源标识符, 文件名(无扩展名)], ... ] 示例:['BGM0', 'BGM0'] 表示: - 标识符为BGM0的音效 - 对应文件路径可能是 resources/Audio/BGM0.mp3 */ this.m_BasicSound = new Array( ['BGM0', 'BGM0'], // 主背景音乐 ['BGM1', 'BGM1'], // 备用背景音乐 ['Button', 'button'], // 按钮点击音效 ['Jet', 'Jet'], // 喷射音效(可能用于特效) ['SendCard', 'sendcard'] // 发牌音效 ); }, // onLoad: function () { // this.node.setContentSize(cc.winSize.width, cc.winSize.height); // this.InitView(); // this.m_BtWXLogin.active = !cc.share.IsH5_WX(); // this.m_BtPhoneLogin.active = !cc.share.IsH5_WX(); // this.m_AgreeToggle.node.active = !cc.share.IsH5_WX(); // //this.m_BtLogin.active = false; // cc.gSoundRes.LoadSoundArr(this.m_BasicSound, 'PublicAudio'); // }, // start: function () { // cc.audioEngine.stopAll(); // this.InitView(); // }, onLoad: function () { let str = "0123456789"; //console.log("str-------", str.slice(0,3)) //console.log("str-------", str) // while (str.length != 0) { // str = str.slice(2); // setTimeout((s)=>{ // console.log("s--: ",s) // },50,str) // } // 节点初始化:设置为全屏尺寸 this.node.setContentSize(cc.winSize.width, cc.winSize.height); // 初始化界面元素 this.InitView(); // 微信H5环境判断(隐藏特定登录方式) this.m_BtWXLogin.active = !cc.share.IsH5_WX(); // 微信登录按钮 this.m_BtPhoneLogin.active = !cc.share.IsH5_WX(); // 手机登录按钮 this.m_AgreeToggle.node.active = !cc.share.IsH5_WX(); // 协议勾选框 // 加载基础音频资源(预加载公共音效) cc.gSoundRes.LoadSoundArr( this.m_BasicSound, // 音频配置数组 'PublicAudio' // 资源目录/分类标识 ); console.log("登录--", window.location.search) if (window.location.search) { this.h5LoginCb(window.location.search) } }, start: function () { // 停止所有背景音乐(防止多场景音乐叠加) cc.audioEngine.stopAll(); // 再次初始化界面(防止数据不同步) this.InitView(); this.isShowOther = false; }, // InitView: function () { // if (!this.m_BtWXLogin) this.m_BtWXLogin = this.$('BtWXLogin'); // if (!this.m_BtPhoneLogin) this.m_BtPhoneLogin = this.$('BtPhoneLogin'); // if (!this.m_AgreeNode) this.m_AgreeNode = this.$('AgreeNode'); // if (!this.m_AgreeToggle) this.m_AgreeToggle = this.$('AgreeToggle@Toggle'); // if (!this.m_LabVersion) this.m_LabVersion = this.$('LabVersion@Label'); // if (!this.m_BtLogin) this.m_BtLogin = this.$('BtLogin'); // }, InitView: function () { // 初始化UI元素引用(延迟加载模式) // 平台登录按钮 if (!this.m_BtPlatformLogin) this.m_BtPlatformLogin = this.$('BtPlatformLogin'); // ios/google // 通用登录按钮:可能用于游客登录等备用登录方式 if (!this.m_BtLogin) this.m_BtLogin = this.$('BtLogin'); // 其他登录按钮 if (!this.m_BtOtherLogin) this.m_BtOtherLogin = this.$('BtOtherLogin'); // 协议条款容器节点:可能包含文本链接/勾选框等元素 if (!this.m_AgreeNode) this.m_AgreeNode = this.$('AgreeNode'); // 协议条款父节点 // 协议勾选框:用户需同意服务条款的Toggle组件 if (!this.m_AgreeToggle) this.m_AgreeToggle = this.$('AgreeToggle@Toggle'); // 版本号标签:显示当前应用版本信息的文本组件 if (!this.m_LabVersion) this.m_LabVersion = this.$('LabVersion@Label'); // other if (!this.m_otherNode) this.m_otherNode = this.$('otherNode'); // 微信登录按钮:通过选择器获取节点并绑定Button组件 // 选择器格式:"节点名@组件类型" if (!this.m_BtWXLogin) this.m_BtWXLogin = this.$('BtWXLogin'); // 微信授权登录按钮 // Line登录按钮 if (!this.m_BtLINELogin) this.m_BtLINELogin = this.$('BtLINELogin'); // Line授权登录按钮 // google登录按钮 if (!this.m_BtGOOGLELogin) this.m_BtGOOGLELogin = this.$('BtGOOGLELogin'); // googl授权登录按钮 // ios登录按钮 if (!this.m_BtIOSLogin) this.m_BtIOSLogin = this.$('BtIOSLogin'); // ios授权登录按钮 // 手机登录按钮:获取手机号登录方式的交互按钮 if (!this.m_BtPhoneLogin) this.m_BtPhoneLogin = this.$('BtPhoneLogin'); }, // OnShowView: function () { // ShowO2I(this.node); // this.InitView(); // this.BindButtonInit(); // this.OnEnter(); // CLUB_SCORE_LOGON_PSW = 0; // if(window.gClubClientKernel) window.gClubClientKernel.shutdown(); // }, OnShowView: function () { // 视图显示时的统一入口方法 // 1. 播放入场动画(假设为从Out到In的过渡效果) ShowO2I(this.node); // 可能需要传入动画时长参数 // 2. 初始化界面元素引用(确保节点正确获取) this.InitView(); // 防御性初始化,防止动态修改布局导致引用丢失 // 3. 绑定按钮事件监听(如点击/长按等交互) this.BindButtonInit(); // 通常包含类似 this.m_BtLogin.node.on('click', ...) // 4. 执行进入视图的业务逻辑(数据加载、状态更新等) this.OnEnter(); // 可能包含:加载用户数据、请求服务器状态等 // 5. 重置俱乐部登录密码状态(根据业务需求) CLUB_SCORE_LOGON_PSW = 0; // 可能表示:0-需要重新验证密码 // 6. 安全关闭俱乐部内核(如果存在) if (window.gClubClientKernel) window.gClubClientKernel.shutdown(); // 释放资源,防止多实例冲突 }, // OnHideView: function () { // HideI2O(this.node); // }, OnHideView: function () { // 视图隐藏时触发生命周期方法 // 执行退出动画(假设为In到Out的过渡效果) HideI2O(this.node); }, /* 代码逻辑说明: 1. 核心功能: - 触发视图隐藏动画,通常用于场景切换时的过渡效果 - 与OnShowView的ShowO2I形成对称动画逻辑(进场/离场) 2. 参数说明: - this.node: 当前组件挂载的节点,一般为整个视图的根节点 - HideI2O可能接收的额外参数(动画时长、缓动函数等需查看具体实现) 3. 动画特性: ▸ 可能包含透明度渐变、位移动画等视觉效果 ▸ 可能自动处理节点active状态(建议验证实现) ▸ 可能是异步动画(需要回调时应在HideI2O中添加完成事件) 4. 典型应用场景: - 用户点击返回按钮 - 执行场景切换操作时 - 收到系统事件强制关闭视图(如网络断开) 5. 注意事项: - 如动画结束后需要禁用节点,需在HideI2O回调中设置: this.node.active = false; - 若视图包含音频/粒子等后台资源,需在此方法中额外停止 - 多层级视图需确保父级动画不影响子视图独立控制*/ // OnEnter: function () { // if (cc.sys.isBrowser) { // if (window.LOG_NET_DATA) console.log("cc.sys.isBrowser"); // var AutoLogonAcc = getQueryString("AAcc"); // if (AutoLogonAcc) { // window.g_PhpUserName = AutoLogonAcc; // window.g_PhpPassword = getQueryString("APsw"); // } // if (window.g_PhpUserName == '') window.g_PhpUserName = null; // } // getLinkInfo(); // // this.StopLoading(); // // 加载声音 // // cc.gSoundRes.LoadSoundArr(this.m_BasicSound) // if (cc.sys.isBrowser) { // if (window.g_PhpUserName != null && !gReLogin) this.LoginAccount(window.g_PhpUserName, hex_md5(window.g_PhpPassword)); // } else { // //自动登录 // if (!gReLogin && cc.sys.localStorage.getItem('LoginPsw') != null) this.LoginAccount(cc.sys.localStorage.getItem('LoginAcc'), cc.sys.localStorage.getItem('LoginPsw')); // } // g_Login = this; // }, OnEnter: function () { // 视图进入时的核心初始化方法 // 浏览器环境处理(Web端逻辑) if (cc.sys.isBrowser) { //if (window.LOG_NET_DATA) console.log(cc.sys); // 调试日志 // 从URL参数获取自动登录凭证(示例URL:?AAcc=user&APsw=123) var AutoLogonAcc = getQueryString("AAcc"); if (AutoLogonAcc) { window.g_PhpUserName = AutoLogonAcc; // 存储全局用户名 window.g_PhpPassword = getQueryString("APsw"); // 明文密码(存在安全隐患) } if (window.g_PhpUserName == '') window.g_PhpUserName = null; // 空值处理 } //getLinkInfo(); // 获取推广链接信息(如渠道号、邀请码等) // 浏览器环境自动登录逻辑 if (cc.sys.isBrowser) { // 存在预置账号且不需要重新登录时触发自动登录 if (window.g_PhpUserName != null && !gReLogin) { this.LoginAccount( window.g_PhpUserName, hex_md5(window.g_PhpPassword) // 使用MD5加密传输(需改进为更安全方案) ); } } // 原生环境处理(APP端逻辑) else { // 通过本地存储获取持久化登录凭证 if (!gReLogin && cc.sys.localStorage.getItem('LoginPsw') != null) { this.LoginAccount( cc.sys.localStorage.getItem('LoginAcc'), // 本地存储的用户名 cc.sys.localStorage.getItem('LoginPsw') // 本地存储的密码(建议加密存储) ); } } g_Login = this; // 暴露当前实例给全局访问(需谨慎) // new this._updateBtns(); }, _updateBtns() { let isNative = !!cc.sys.isNative; this.m_BtPlatformLogin.active = isNative; if (isNative) { this.m_BtPlatformLogin.x = -360; this.m_BtPlatformLogin.getChildByName("ios").active = cc.sys.OS_IOS == cc.sys.os; this.m_BtPlatformLogin.getChildByName("google").active = cc.sys.OS_ANDROID == cc.sys.os; } this.m_BtLogin.x = isNative ? 0 : -180; this.m_BtOtherLogin.x = isNative ? 360 : 180; //other this._updateOtherView(); }, _updateOtherView() { this.m_otherNode.active = this.isShowOther; this.m_BtLINELogin.active = this.isShowOther; this.m_BtWXLogin.active = this.isShowOther && false; this.m_BtGOOGLELogin.active = this.isShowOther && !(cc.sys.isNative && cc.sys.OS_ANDROID == cc.sys.os); let btnsNode = [this.m_BtGOOGLELogin, this.m_BtIOSLogin, this.m_BtLINELogin, this.m_BtWXLogin]; let posIndex = 0; let posArr = [{ x: -160, y: 120 }, { x: 160, y: 120 }, { x: -160, y: 0 }, { x: 160, y: 0 }, { x: -160, y: -120 }, { x: 160, y: -120 },]; for (let btnNode of btnsNode) { if (!btnNode.active) { continue; } let posInfo = posArr[posIndex++]; btnNode.x = posInfo.x; btnNode.y = posInfo.y; } }, //微信账号登录按钮点击事件 OnClick_BtWXLogin: function () { // cc.gSoundRes.PlaySound('Button'); if (!this.CheckToggle()) return; if (this.isLogining) return; this.ShowLoading(null, '登入中'); if (cc.sys.isNative) { ThirdPartyWXLogin(); } else if (cc.sys.isBrowser) { window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=2007057599&redirect_uri=${window.PHP_HOME}/h5/web-mobile&state=12345abcde&scope=profile%20openid&nonce=09876xyz`; } }, //Line账号登录按钮点击事件 OnClick_BtLINELogin: function () { // cc.gSoundRes.PlaySound('Button'); if (!this.CheckToggle()) return; if (this.isLogining) return; this.ShowLoading(null, '登入中'); if (cc.sys.isNative) { ThirdPartyLINELogin(); } else if (cc.sys.isBrowser) { window.location.href = `https://access.line.me/oauth2/v2.1/authorize?response_type=code&client_id=2007057599&redirect_uri=${window.PHP_HOME}/h5/web-mobile&state=12345abcde&scope=profile%20openid&nonce=09876xyz`; } }, //苹果账号登录按钮点击事件 OnClick_BtIOSLogin: function () { // cc.gSoundRes.PlaySound('Button'); if (!this.CheckToggle()) return; if (this.isLogining) return; if (cc.sys.OS_IOS != cc.sys.os) { return; } this.ShowLoading(null, '登入中'); if (cc.sys.isNative) { ThirdPartyIOSLogin(); } else if (cc.sys.isBrowser) { window.location.href = `https://access.line.me/oauth2/v2.1/authorize?response_type=code&client_id=2007057599&redirect_uri=${window.PHP_HOME}/h5/web-mobile&state=12345abcde&scope=profile%20openid&nonce=09876xyz`; } }, //谷歌账号登录按钮点击事件 OnClick_BtGOOGLELogin: function () { // cc.gSoundRes.PlaySound('Button'); if (!this.CheckToggle()) return; if (this.isLogining) return; this.ShowLoading(null, '登入中'); if (cc.sys.isNative) { ThirdPartyGoogleLogin(); } else if (cc.sys.isBrowser) { window.location.href = `https://access.line.me/oauth2/v2.1/authorize?response_type=code&client_id=2007057599&redirect_uri=${window.PHP_HOME}/h5/web-mobile&state=12345abcde&scope=profile%20openid&nonce=09876xyz`; } }, //平台登录按钮点击事件 OnClick_BtPlatformLogin: function () { // cc.gSoundRes.PlaySound('Button'); if (!this.CheckToggle()) return; if (this.isLogining) return; this.ShowLoading(null, '登入中'); if (cc.sys.isNative) { if (cc.sys.OS_IOS == cc.sys.os) { ThirdPartyIOSLogin(); } else if (cc.sys.OS_ANDROID == cc.sys.os) { ThirdPartyGoogleLogin(); } } else if (cc.sys.isBrowser) { window.location.href = `https://access.line.me/oauth2/v2.1/authorize?response_type=code&client_id=2007057599&redirect_uri=${window.PHP_HOME}/h5/web-mobile&state=12345abcde&scope=profile%20openid&nonce=09876xyz`; } }, //其他登录方式 OnClick_BtOtherLogin: function () { this.isShowOther = true; this._updateOtherView(); }, onClickReturn() { this.isShowOther = false; this._updateOtherView(); }, h5LoginCb: function (res) { let code = this.getQueryStringNew(res, "code") console.log("code-5", code); if (code == null || code == undefined || code == "") { console.log("code错误"); return; } if (this.isLogining) return; this.isLogining = true; this.httpPost(code, this.postCb); this.scheduleOnce(() => { this.isLogining = false; }, 7); }, postCb: function (res) { let res_access_token = JSON.parse(res); // console.log("res_access_token--1",res_access_token) let access_token = res_access_token.access_token console.log("res_access_token--2", access_token) if (access_token == null || access_token == undefined || access_token == "") { console.log("access_token error"); return; } var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function () { if (xhr.readyState === 4 && (xhr.status >= 200 && xhr.status < 400)) { var respone = decodeURI(xhr.responseText); if (window.LOG_WEB_DATA) console.log("httpGet返回1 ", respone); //respone = respone.replace(/\s+\r\n/g,''); // while(respone != '' && respone[0].charCodeAt() == 65279){//口或?开头 原因不明 // var end1 = respone.lastIndexOf("}"); // var end2 = respone.lastIndexOf("]"); // var end = Math.max(end1, end2) // end = end>=0?end+1:respone.length; // respone = respone.substring(1, end ); // } // if(window.LOG_WEB_DATA)console.log("httpGet返回2 "+respone) let userinfo = JSON.parse(respone); if (userinfo == null || userinfo == undefined || userinfo == "") { console.log("获取用户信息失败") return; } console.log("userinfo-", userinfo) if (userinfo.pictureUrl == null || userinfo.pictureUrl == undefined) { userinfo.pictureUrl = "" } let codeObj = { openid: userinfo.userId, nickname: userinfo.displayName, sex: 1, headimgurl: userinfo.pictureUrl } let code = JSON.stringify(codeObj) //let code = "{openid:"+userinfo.userId+",nickname:"+userinfo.displayName+",sex:1,headimgurl:"+userinfo.pictureUrl+"}" var webUrlH5 = window.PHP_HOME + '/UserFunc.php?&GetMark=11&code=' + code; console.log("webUrl请求", webUrlH5) setTimeout(() => { WebCenter.GetData(webUrlH5, null, function (data) { if (window.LOG_NET_DATA) console.log("Login--22登入返回 " + data) var Login = JSON.parse(data); if (Login.errcode != null) return this.ShowAlert("ErrCode:" + Login.errcode); // cc.sys.localStorage.setItem(window.Key_LoginPlatform, window.PLATFORM_WX); g_Login.LoginAccount(Login.Accounts, Login.LogonPass); }.bind(this)); }, 500); } }.bind(this); xhr.timeout = 5000;// 5 seconds for timeout xhr.open("GET", "https://api.line.me/v2/profile", true); // xhr.setRequestHeader('Content-Type','text/plain'); xhr.setRequestHeader("Authorization", "Bearer " + access_token); xhr.send(); }, getQueryStringNew: function (url, name) { const queryString = url; const urlParams = new URLSearchParams(queryString); console.log("urlParams--1", urlParams.toString()) const param = urlParams.get(name); console.log("param--", param) return param; }, //获得第三方CODE "{\"headimgurl\":\"%@\",\"sex\":\"%@\",\"unionid\":\"%@\",\"openid\":\"%@\",\"nickname\":\"%@\"}" onWXCode: function (code) { if (window.LOG_NET_DATA) console.log("onWXCode " + code) if (code == '') { console.log("Login--空 ") return; } else { var json = JSON.parse(code); json.nickname = json.nickname.replace(/&/g, '%26'); code = JSON.stringify(json); var webUrl = window.PHP_HOME + '/UserFunc.php?&GetMark=11&code=' + code; setTimeout(() => { if (window.LOG_NET_DATA) console.log("Login--6登入 " + code) WebCenter.GetData(webUrl, null, function (data) { if (window.LOG_NET_DATA) console.log("Login--登入返回 " + data) var Login = JSON.parse(data); if (Login.errcode != null) return this.ShowAlert("ErrCode:" + Login.errcode); // cc.sys.localStorage.setItem(window.Key_LoginPlatform, window.PLATFORM_WX); this.LoginAccount(Login.Accounts, Login.LogonPass); }.bind(this)); }, 600); } }, //RegisterAccount // RegisterAccount: function (Account, Password, Nickname, Gender, PhoneReg) { // if (!this.CheckToggle()) return; // this.ShowLoading(null, '正在注册'); // var LogonAccounts = new CMD_GP_RegisterAccounts(); // LogonAccounts.dwPlazaVersion = cc.VERSION_PLAZA; // LogonAccounts.szAccounts = Account // LogonAccounts.szPassWord = Password; // LogonAccounts.szMachineID = "creator"; // LogonAccounts.cbGender = (Gender ? 1 : 0); // if(Nickname) LogonAccounts.szNickName = Nickname; // else { // var nowDate = new Date(); // LogonAccounts.szNickName = '游客'; // LogonAccounts.szNickName += nowDate.getMonth() + 1; // LogonAccounts.szNickName += nowDate.getDate(); // LogonAccounts.szNickName += 'r' + nowDate.getTime() % 1000; // } // if(PhoneReg) var LoginMission = new CGPLoginMission(this, MDM_GP_LOGON, SUB_GP_REGISTER_PHONE, LogonAccounts); // else var LoginMission = new CGPLoginMission(this, MDM_GP_LOGON, SUB_GP_REGISTER_ACCOUNTS, LogonAccounts); // var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData(); // pGlobalUserData.szPassword = LogonAccounts.szPassWord; // cc.sys.localStorage.setItem('LoginAcc', Account); // cc.sys.localStorage.setItem('LoginPswT', Password); // }, RegisterAccount: function (Account, Password, Nickname, Gender, PhoneReg) { // 注册账号主逻辑 if (!this.CheckToggle()) return; // 校验用户协议勾选状态,未勾选则中断流程 this.ShowLoading(null, '註冊中'); // 显示全局加载提示框 // 构建注册协议数据结构 var LogonAccounts = new CMD_GP_RegisterAccounts(); // 创建注册协议对象 LogonAccounts.dwPlazaVersion = cc.VERSION_PLAZA; // 设置当前大厅版本号 LogonAccounts.szAccounts = Account; // 用户输入账号 LogonAccounts.szPassWord = Password; // 用户输入明文密码 LogonAccounts.szMachineID = "creator"; // 固定设备标识(硬编码值) LogonAccounts.cbGender = (Gender ? 1 : 0); // 转换性別参数为协议格式(0-女,1-男) // 处理用户昵称逻辑 if (Nickname) { LogonAccounts.szNickName = Nickname; // 直接使用传入的昵称参数 } else { // 生成默认游客昵称(格式:游客+月份+日期+毫秒时间戳末三位) var nowDate = new Date(); LogonAccounts.szNickName = ''; LogonAccounts.szNickName += nowDate.getMonth() + 1; // 添加当前月份(+1修正0基值) LogonAccounts.szNickName += nowDate.getDate(); // 添加当前日期 LogonAccounts.szNickName += 'r' + nowDate.getTime() % 1000; // 添加随机后缀 } // 根据注册类型选择协议号 var LoginMission; // 声明网络任务对象 if (PhoneReg) { // 手机注册路径:使用手机注册子协议号 LoginMission = new CGPLoginMission(this, MDM_GP_LOGON, SUB_GP_REGISTER_PHONE, LogonAccounts); } else { // 普通注册路径:使用账号注册子协议号 LoginMission = new CGPLoginMission(this, MDM_GP_LOGON, SUB_GP_REGISTER_ACCOUNTS, LogonAccounts); } // 持久化存储用户凭证 var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData(); // 获取全局用户数据 pGlobalUserData.szPassword = LogonAccounts.szPassWord; // 更新全局密码字段 cc.sys.localStorage.setItem('LoginAcc', Account); // 本地存储账号 cc.sys.localStorage.setItem('LoginPswT', Password); // 本地存储明文密码 }, //LoginAccount // LoginAccount: function (Account, Password) { // if (!this.CheckToggle()) return; // gReLogin = false; // this.ShowLoading(null, '登录中'); // var LogonAccounts = new CMD_GP_LogonAccounts(); // LogonAccounts.dwPlazaVersion = cc.VERSION_PLAZA; // LogonAccounts.szAccounts = Account // LogonAccounts.szPassword = Password; // LogonAccounts.szPassPortID = "no"; // var LoginMission = new CGPLoginMission(this, MDM_GP_LOGON, SUB_GP_LOGON_ACCOUNTS, LogonAccounts); // var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData(); // pGlobalUserData.szPassword = LogonAccounts.szPassword; // cc.sys.localStorage.setItem('LoginAcc', Account); // cc.sys.localStorage.setItem('LoginPswT', Password); // }, LoginAccount: function (Account, Password) { console.log("LoginAccount--1") if (window.LOG_NET_DATA) console.log("LoginAccount--1"); // 账号登录主逻辑 if (!this.CheckToggle()) { return; // 校验用户协议勾选状态,未勾选则中断流程 } gReLogin = false; // 重置重新登录标识(防止循环登录) this.ShowLoading(null, '登入中'); // 显示全局加载提示框 if (window.LOG_NET_DATA) console.log("LoginAccount--2"); // 构建登录协议数据结构 var LogonAccounts = new CMD_GP_LogonAccounts(); // 创建登录协议对象 LogonAccounts.dwPlazaVersion = cc.VERSION_PLAZA; // 设置当前大厅版本号 LogonAccounts.szAccounts = Account; // 用户输入账号 LogonAccounts.szPassword = Password; // 用户输入明文密码 LogonAccounts.szPassPortID = "no"; // 固定护照标识(硬编码值) // 创建登录网络任务 var LoginMission = new CGPLoginMission( this, MDM_GP_LOGON, // 主协议号(登录模块) SUB_GP_LOGON_ACCOUNTS, // 子协议号(账号登录) LogonAccounts ); if (window.LOG_NET_DATA) console.log("LoginAccount--3"); // 持久化存储用户凭证 var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData(); // 获取全局用户数据 pGlobalUserData.szPassword = LogonAccounts.szPassword; // 更新全局密码字段 cc.sys.localStorage.setItem('LoginAcc', Account); // 本地存储账号 cc.sys.localStorage.setItem('LoginPswT', Password); // 本地存储明文密码 }, OnShowChangePsw: function () { // this.ShowPrefabDLG("ChangePsw"); }, OnClick_BtChangePsw: function () { // this.ShowPrefabDLG("ChangePsw"); }, // 显示登录框 OnClick_BtPhoneLogin: function () { // cc.gSoundRes.PlaySound('Button'); this.ShowPrefabDLG("PhoneLogin"); }, // 显示登录框 OnClick_BtLogin: function () { // cc.gSoundRes.PlaySound('Button'); this.ShowPrefabDLG("AccLogin"); }, onGPLoginSuccess: function () { }, OnClick_BtShowAgreeNode: function () { this.ShowPrefabDLG('AgreeMent', this.m_DlgNode); // if(this.m_AgreeNode) this.m_AgreeNode.runAction(cc.moveTo(0.1, cc.v2(0, 0))); }, OnClick_BtHideAgreeNode: function () { this.m_AgreeNode.runAction(cc.moveTo(0.1, cc.v2(-window.SCENE_WIGHT, 0))); }, // CheckToggle: function () { if (!this.m_AgreeToggle.isChecked) { this.ShowAlert("請同意使用者協定!", Alert_Yes); return false; } return true; }, //登录失败 onGPLoginFailure: function (szDescription) { this.StopLoading(); //提示信息 this.ShowAlert(szDescription, Alert_Yes); }, //登陆成功 onGPLoginComplete: function () { //查询重连 this.SendReLinkQuery() }, //查询回连 SendReLinkQuery: function () { // this.ShowLoading(); var QueryRL = new CMD_GP_C_Relink(); QueryRL.dwUserID = g_GlobalUserInfo.GetGlobalUserData().dwUserID; var LoginMission = new CGPLoginMission(this, MDM_GP_GET_SERVER, SUB_GP_QUERY_RELINK, QueryRL); }, //进入服务器信息 OnQueryServerRes: function (ReturnServer) { if (ReturnServer.wKindID == 0 || !this.BeLoadRes(ReturnServer.wKindID)) { ChangeScene('Lobby'); return; } g_ServerListDataLast = new CGameServerItem(); g_ServerListDataLast.wKindID = ReturnServer.wKindID; g_ServerListDataLast.wServerPort = ReturnServer.wServerPort; g_ServerListDataLast.szServerAddr = ReturnServer.szServerAddr; g_ServerListDataLast.wServerType = ReturnServer.wServerType; g_ServerListDataLast.llEnterScore = ReturnServer.llEnterScore; g_ServerListDataLast.szServerName = ""; if (g_CurScene && g_CurScene.EnterGameScene) g_CurScene.EnterGameScene(); }, OnQueryRoomRes: function (ReturnServer) { if (window.LOG_NET_DATA) console.log('OnQueryRoomRes ', ReturnServer) if (ReturnServer.wKindID == 0 || !this.BeLoadRes(ReturnServer.wKindID)) { ChangeScene('Lobby'); return; } g_ServerListDataLast = new CGameServerItem(); g_ServerListDataLast.wKindID = ReturnServer.wKindID; g_ServerListDataLast.wServerPort = ReturnServer.wServerPort; g_ServerListDataLast.szServerAddr = ReturnServer.szServerAddr; g_ServerListDataLast.wServerType = ReturnServer.wServerType; g_ServerListDataLast.llEnterScore = ReturnServer.llEnterScore; g_ServerListDataLast.szServerName = ""; window.g_dwRoomID = ReturnServer.dwRoomID; window.g_dwClubID = ReturnServer.dwClubID; if (g_CurScene && g_CurScene.EnterGameScene) g_CurScene.EnterGameScene(); }, //登陆成功 onGetServerListFinish: function () { }, OnBtTestLoginin: function (Tag, Num) { var key = 'test' + Num; if (this[key] == null) this[key] = true; else return this.OnReSetTestLogin(); var InPutCnt = 0; for (var i = 1; i <= Num; i++) { if (this['test' + i] == null) return this.OnReSetTestLogin(); else InPutCnt++; } if (InPutCnt >= 3) this.m_AccLogin.active = true; }, OnReSetTestLogin: function () { for (var i = 1; i < 4; i++) this['test' + i] = null; }, //游戏资源预加载 BeLoadRes: function (wKindID) { try { //游戏自定义 GameDef = new window['CMD_GAME_' + wKindID](); if (GameDef == null) { var game = window.GameList[wKindID]; if (game == null) game = wKindID; return false; } //游戏桌布 window.gGameBG = 'loading'; window.LoadSetting(); window.LoadSetting(wKindID); var pathInfo = window.Path_GameBG(wKindID, window.g_GameSetting[wKindID][window.SetKey_Table_BG], 0, true); GameDef.BGIndex = pathInfo.BGIndex; GameDef.BGPath = pathInfo.path; } catch (error) { return false; } return true; }, httpPost: function (code, CallBack) { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function () { if (xhr.readyState === 4 && (xhr.status >= 200 && xhr.status < 400)) { var respone = xhr.responseText; if (window.LOG_WEB_DATA) console.log("line-返回-1 " + respone) // while(respone != '' && respone[0].charCodeAt() == 65279){//口或?开头 原因不明 // var end1 = respone.lastIndexOf("}"); // var end2 = respone.lastIndexOf("]"); // var end = Math.max(end1, end2) // end = end>=0?end+1:respone.length; // respone = respone.substring(1, end ); // } //if(window.LOG_WEB_DATA) console.log("line-返回-2"+respone) CallBack(respone); } }.bind(this); xhr.timeout = 5000;// 5 seconds for timeout xhr.open("POST", "https://api.line.me/oauth2/v2.1/token/", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); // xhr.setRequestBody("grant_type","authorization_code"); // xhr.setRequestBody("code",code); // xhr.setRequestBody("redirect_uri","http://34.80.6.45:8080/h5/web-mobile"); // xhr.setRequestBody("client_id","2007057599"); // xhr.setRequestBody("client_secret","04bb8dd9bdf94572d44443df0643cc89"); // xhr.send(); xhr.send("grant_type=authorization_code&code=" + code + "&redirect_uri=http://34.80.6.45:8080/h5/web-mobile&client_id=2007057599&client_secret=04bb8dd9bdf94572d44443df0643cc89"); } });