-- 手机绑定 local PhoneChangeView = class("PhoneChangeView", cc.UIView) function PhoneChangeView:ctor(callBack) PhoneChangeView.super.ctor(self) logD("yhj: 进入手机修改界面") local ui = loadUI("res/ui/ui_dating/ui_phone_change.ui") self.ui = ui self:addChild(ui) self.callBack = callBack end function PhoneChangeView: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:bindEvent(app.user, "onChangePlayerInfo", handler(self, self.onChangePlayerInfo)) end function PhoneChangeView:onExit() if self.timeDown then self.timeDown:stopTimer() self.timeDown = null end end function PhoneChangeView:onClickClose() playBtnCloseEffect() self:removeFromParent() end function PhoneChangeView: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 PhoneChangeView:onClickGetcode() playBtnEffect() local phoneNum = self.ui.Items.TextField_PhoneNew:getString() if string.len(phoneNum) ~= 11 or not checkIsNumberString(phoneNum) then showTooltip("您输入的手机号码格式不正确") return end if app.user.phonenum and tonumber(app.user.phonenum) == tonumber(phoneNum) then showTooltip("您的手机号已经是"..phoneNum) return end self.ui.Items.Button_Code:setVisible(false) self:showTimeDown(60) self.phoneNum = phoneNum app.php:requestBindPhoneProvingCode(self.phoneNum) end function PhoneChangeView:onClickOk() playBtnEffect() local phoneNum = app.user.phonenum local newPhone = self.ui.Items.TextField_PhoneNew: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(newPhone) < 8 or string.len(newPhone) > 12 or not checkIsPasswordString(newPhone) then showTooltip("请输入英文字母或者数字的8-12位任意组合") return end -- 验证验证码 if string.len(checkcode) ~= 6 or not checkIsNumberString(checkcode) then showTooltip("您输入的验证码格式不正确") return end if phoneNum and newPhone and checkcode then local request = changePlayerInfoRequest:new() request.uid = app.user.loginInfo.uid request.openId = phoneNum request.unionId = newPhone request.checkcode = checkcode request.loginType = ChangePlayerInfo.REPLCACE_PHONE request.weixinInfo = app.user.userInfo logD("PhoneChangeView onClickOk",table.tostring(request)) logD("yhj: 手机修改") self.ui:sendMsg(app.user, "playerInfoChange",request) end end function PhoneChangeView:onChangePlayerInfo(event) local response = event.response local errCode = response.ret if errCode and errCode == 0 then self:removeFromParent() end end function PhoneChangeView:onClickPassword() local view = import("luaScript.Views.Main.SetPasswordView"):new(endCallback) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end return PhoneChangeView