-- 手机绑定 local PhoneBindView = class("PhoneBindView", cc.UIView) function PhoneBindView:ctor(endCallback) PhoneBindView.super.ctor(self) local ui = loadUI("res/ui/ui_dating/ui_phone_bind.ui") self.ui = ui self:addChild(ui) self.endCallback = endCallback end function PhoneBindView:onEnter() self.ui.Items.Text_TimeDown:setVisible(false) self.ui.Items.Button_Close:registerClick(handler(self, self.onClickClose)); self.ui.Items.Button_Code:registerClick(handler(self, self.onClickGetcode)); self.ui.Items.Button_Sure:registerClick(handler(self, self.onClickOk)); self.ui.Items.Button_Normal:registerClick(handler(self, self.onClickRestEye)) self.ui.Items.Button_Sel:registerClick(handler(self, self.onClickEye)) self.ui.Items.Button_Sel:setVisible(false) self.ui.Items.ImageView_1:setVisible(app.config.ModuleConfig.IsSupportHongBaoKa); self:bindEvent(app.user, "onBindResponse", handler(self, self.onPhoneBindResponse)) end function PhoneBindView:onExit() if self.timeDown then self.timeDown:stopTimer() self.timeDown = null end end function PhoneBindView:onClickClose() playBtnCloseEffect() if self.endCallback then self.endCallback() end self:removeFromParent() end function PhoneBindView:showTimeDown(timeLeft) self.ui.Items.Text_TimeDown:setVisible(true) self.ui.Items.Text_TimeDown:startRemainTime(tonumber(timeLeft) or 0, function(obj, value) value = math.floor(value + 0.5) self.ui.Items.Text_TimeDown:setText(value.."秒后重试") self.ui.Items.Button_Code:setVisible(value <= 0) end) end function PhoneBindView:onClickGetcode() playBtnEffect() if app.user.phonenum and app.user.phonenum ~= "" then showTooltip("您已经绑定过手机号了") return end local phoneNum = self.ui.Items.TextField_PhoneNum:getString() if string.len(phoneNum) ~= 11 or not checkIsNumberString(phoneNum) then showTooltip("您输入的手机号码格式不正确") return end self.ui.Items.Button_Code:setVisible(false) self:showTimeDown(60) self.phoneNum = phoneNum app.php:requestBindPhoneProvingCode(self.phoneNum) end function PhoneBindView:onClickOk() playBtnEffect() if app.user.phonenum and app.user.phonenum ~= "" then showTooltip("您已经绑定过手机号了") return end local phoneNum = self.ui.Items.TextField_PhoneNum:getString() local password = self.ui.Items.TextField_PhoneCode:getString() local checkcode = self.ui.Items.TextField_Code:getString() -- 验证手机号码 if string.len(phoneNum) ~= 11 or not checkIsNumberString(phoneNum) then showTooltip("您输入的手机号码格式不正确") return end -- 验证手机密码 if string.len(password) < 8 or string.len(password) > 12 or not checkIsPasswordString(password) then showTooltip("请输入英文字母或者数字的8-12位任意组合") return end -- 验证验证码 if string.len(checkcode) ~= 6 or not checkIsNumberString(checkcode) then showTooltip("您输入的验证码格式不正确") return end local request = PhoneBindRequest:new() request.uid = app.user.loginInfo.uid request.account = phoneNum request.password = password request.checkcode = checkcode request.weixinInfo = app.user.userInfo request.rewardType = 5 -- 奖励类型:1. 房卡 2.金币 3. 活动房卡 4. RMB 5. 红包券 request.bindType = BIND_TYPE.PHONE self.ui:sendMsg(app.user, "requestBindPhoneNum", request) end function PhoneBindView:onPhoneBindResponse(event) local response = event.response local errCode = response.ret local userInfo = response.userInfo local rewardCoin = response.rewardCoin if errCode and errCode == BIND_TYPE_RESULT.PHONE then -- 如果成功则关闭界面 --显示红包券奖励 if rewardCoin and rewardCoin > 0 and app.config.ModuleConfig.IsSupportHongBaoKa then app.user.loginInfo.curLiquanNum = tonumber(app.user.loginInfo.curLiquanNum) + rewardCoin local view = import("luaScript.Views.Main.HongBaoKa.GetHongBaoKaEffect"):new(rewardCoin,1) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end if self.endCallback then self.endCallback() end self:removeFromParent() end end function PhoneBindView:onClickEye() playBtnEffect() self.ui.Items.TextField_PhoneCode:setPasswordEnabled(true) self.ui.Items.Button_Normal:setVisible(true) self.ui.Items.Button_Sel:setVisible(false) self.ui.Items.TextField_PhoneCode:setText(self.ui.Items.TextField_PhoneCode:getString()) end function PhoneBindView:onClickRestEye() playBtnEffect() self.ui.Items.TextField_PhoneCode:setPasswordEnabled(false) self.ui.Items.Button_Normal:setVisible(false) self.ui.Items.Button_Sel:setVisible(true) self.ui.Items.TextField_PhoneCode:setText(self.ui.Items.TextField_PhoneCode:getString()) end return PhoneBindView