|
- -- 下载界面
- local MainSettingView = class("MainSettingView", cc.UIView)
- local PluginConfig = require("preload.PluginConfig")
-
- local LoginConfig = require("luaScript.Views.Login.LoginConfig")
-
- function MainSettingView:ctor()
- MainSettingView.super.ctor(self);
- end
-
- function MainSettingView:onEnter()
- MainSettingView.super.onEnter(self)
- local ui = loadUI("res/ui/ui_dating/ui_shezhi.ui")
- self.ui = ui
- self:addChild(ui)
-
- self:registerButton()
- self:setPlayerInfo()
- self:initBindEvents()
- if app.config.ModuleConfig.IsSupportUnion then
- app.club_php:requestClubBelong()
- end
- self.lastSendLogin = 0;
-
- end
-
- function MainSettingView:initBindEvents()
- self:bindEvent(app, "onCheckForbidClubInvite", handler(self, self.onCheckForbidClubInvite))
- self:bindEvent(app.user, "onBindResponse", handler(self, self.onBindResponse))
- self:bindEvent(app.user, "onChangePlayerInfo", handler(self, self.onChangePlayerInfoResponse))
- self:bindEvent(app.club_php, GAME_EVENT.CLUB_UNION_CLUB_BELONG, handler(self, self.onClubBelongEvent))
- end
-
- function MainSettingView:registerButton()
- -- 关闭
- self.ui.Items.Button_close:registerClick(handler(self , self.onClickClose))
-
- -- 游戏管理
- self.ui.Items.Button_game_manage:registerClick(handler(self , self.onClickGameManage))
-
- -- 注销登陆
- self.ui.Items.Button_change_account:registerClick(handler(self , self.onClickLogout))
-
- -- 音乐
- self.ui.Items.Button_music:registerClick(handler(self , self.onClickYinYue))
- if app.systemSetting.info.musicVolume == 0 then
- self.ui.Items.Button_music:setBright(true)
- else
- self.ui.Items.Button_music:setBright(false)
- end
-
- -- 音效
- self.ui.Items.Button_effect:registerClick(handler(self , self.onClickYinXiao))
- if app.systemSetting.info.soundVolume == 0 then
- self.ui.Items.Button_effect:setBright(true)
- else
- self.ui.Items.Button_effect:setBright(false)
- end
-
- --手机绑定
- self.ui.Items.Text_bindPhone:registerClick(handler(self, self.onClickBindPhone))
- --微信绑定
- self.ui.Items.Text_bindWetChat:registerClick(handler(self, self.onClickBindWetChat))
-
- --设置密码
- self.ui.Items.Text_setPassword:registerClick(handler(self, self.onClickSetPassword))
-
- --我的装扮
- self.ui.Items.Button_zhuangban:registerClick(handler(self, self.onClickChaKan))
- self.ui.Items.Layout_zhuangban:setVisible(false)
-
- --亲友圈归属设置
- self.ui.Items.Layout_clubbelong:setVisible(app.config.ModuleConfig.IsSupportUnion)
- self.ui.Items.Button_clubbelong:registerClick(handler(self, self.onClickClubBelong))
- self.ui.Items.Text_zhuangban_1:setText((app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_NAME or PLN.CLUB_CEST_NAME2).."归属设置")
-
- --屏蔽茶馆邀请
- self.checkBoxForbid = import("luaScript.Tools.CheckBoxManager"):new();
- self.checkBoxForbid:setColorSwitch(false)
- self.checkBoxForbid:addItem(self.ui.Items.CheckBox_select,"forbidClubInvite",1,0)
- -- 设置默认状态
- local ttSelected = {}
- self.checkBoxForbid:setDefault(ttSelected);
- -- 设置回调
- self.checkBoxForbid:setCallback(handler(self,self.onClickForbidInviteClub))
-
- --用户协议
- self.ui.Items.Text_agreement:registerClick(handler(self, self.onClickAgreement))
- --隐私政策
- self.ui.Items.Text_private:registerClick(handler(self, self.onClickPrivate))
- --账号注销
- self.ui.Items.Text_logout:registerClick(handler(self, self.onClickAccountLogOut))
-
- --请求屏蔽茶馆邀请配置
- app.php:requestCheckForbidClubInvite()
- end
-
- function MainSettingView:onClickForbidInviteClub()
- local result = self.checkBoxForbid:getResult2()
- local isallowgroup = result["forbidClubInvite"]
- --请求屏蔽茶馆邀请配置
- app.php:requestSetForbidClubInvite(isallowgroup)
- end
-
- --设置玩家信息
- function MainSettingView:setPlayerInfo()
- -- 头像
- local headurl = app.user.headimgurl
- setPlayerHeadImage(app.user.loginInfo.uid, headurl or "", self.ui.Items.ImageView_head)
-
- -- 昵称
- local nickname = getShortName(app.user.nickname)
- self.ui.Items.Text_nickname:setText(tostring(nickname))
-
- -- ID
- self.ui.Items.Text_ID:setText(tostring(app.user.loginInfo.uid))
-
- local stUserInfo = json.decode(app.user.userInfo);
- logD("MainSettingView:setPlayerInfo() stUserInfo = ", table.tostring(stUserInfo))
-
- self:updatePhone()
- end
-
- function MainSettingView:updatePhone()
- -- 手机号
- local phonenum = app.user.phonenum
- local bindPhone = not phonenum or phonenum == ""
- if bindPhone then
- self.ui.Items.Text_phone:setText("未绑定")
- self.ui.Items.Text_bindPhone:setText("绑定手机")
- else
- self.ui.Items.Text_phone:setText(tostring(phonenum))
- self.ui.Items.Text_bindPhone:setText("修改手机")
- end
-
- --微信绑定
- local visible = app.user.unionid == "?"
- if visible then
- self.ui.Items.Text_wetChat:setText("未绑定")
- else
- --微信号
- local nickname = getShortName(app.user.nickname)
- self.ui.Items.Text_wetChat:setText(tostring(nickname))
- end
- self.ui.Items.Text_bindWetChat:setVisible(visible)
- end
-
- function MainSettingView:onClickUpload()
- local url = string.format("http://cnagent.dingdingqipai.com/client/user/loginpost?token=%s&app=%s",app.user.loginInfo.token,getAppId())
- app.plugin:callUrl(url)
- end
-
- function MainSettingView:onClickChaKan()
- playBtnEffect()
- app.serverConfigs:requestClientConfig(function()
- local url = string.format(app.serverConfigs.clientConfig.myHead.."&token=%s&app=%s",app.user.loginInfo.token,getAppId())
- app.plugin:callUrl(url)
- end)
- end
-
- function MainSettingView:onClickClubBelong()
- playBtnEffect()
- local view = import("luaScript.Views.Main.MainUnionBelong"):new()
- view:setAnchorPoint(cc.p(0.5,0.5))
- app:showWaitDialog(view)
- end
-
- -- 注销
- function MainSettingView:onClickLogout()
- playBtnEffect()
- app.plugin:logout()
- end
-
- -- 关闭设置界面
- function MainSettingView:onClickClose()
- playBtnCloseEffect()
- self:removeFromParent()
- end
-
- -- 音乐
- function MainSettingView:onClickYinYue()
- playBtnEffect()
- local curValue = 0
- if self.ui.Items.Button_music:isBright() then
- curValue = 1
- else
- curValue = 0
- end
-
- self.ui.Items.Button_music:setBright(not self.ui.Items.Button_music:isBright())
- app.systemSetting.info.musicVolume = curValue;
- app.systemSetting:save()
- end
-
- -- 音效
- function MainSettingView:onClickYinXiao()
- playBtnEffect()
- local curValue = 0
- if self.ui.Items.Button_effect:isBright() then
- curValue = 1
- else
- curValue = 0
- end
-
- self.ui.Items.Button_effect:setBright(not self.ui.Items.Button_effect:isBright())
- app.systemSetting.info.soundVolume = curValue;
- app.systemSetting:save()
- end
-
- --游戏管理
- function MainSettingView:onClickGameManage()
- playBtnEffect()
- local view = import("luaScript.Views.Main.GameManagerView"):new()
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- end
-
- function MainSettingView:onClickSetPassword()
- playBtnEffect()
- local view = import("luaScript.Views.Main.SetPasswordView"):new(endCallback)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- end
-
- --手机绑定
- function MainSettingView:onClickBindPhone()
- playBtnEffect()
- local phonenum = app.user.phonenum
- local bindPhone = not phonenum or phonenum == ""
- if bindPhone then
- local view = import("luaScript.Views.Main.PhoneBindView"):new()
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- else
- local view = import("luaScript.Views.Main.PhoneChangeView"):new()
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- end
- end
-
- --weixin绑定
- function MainSettingView:onClickBindWetChat()
- playBtnEffect()
- if isWin32Platform() then
- showTooltip("请在手机操作")
- return
- end
- local timeNow = os.time();
- if timeNow - self.lastSendLogin <= 2 then
- showTooltip("点击太过频繁,请稍后再试")
- return
- end
-
- if not app.plugin:isSupportWeiXin() then
- local text = "未安装【微信】,是否前往下载【微信】?"
- local okBtnImage = "res/ui/zy_tongyong/zy_button/btn_like_xiazai.png"
- local okCallBack = function()
- app.plugin:callUrl("http://weixin.qq.com/");
- end
- local cancelCallBack = function()
-
- end
- showConfirmDialog(text, okCallBack, cancelCallBack, 26, okBtnImage)
- return;
- end
-
- self.lastSendLogin = timeNow;
- --到时候二次授权可以用这段代码
- --绑定标志
- app.user.bindWeiXinIng = true
- --PluginConfig.WeiXin = PluginConfig.WeiXinNew
- --启动登录微信
- app.plugin:loginWeiXin()
- end
-
- function MainSettingView:onBindResponse(event)
- logD("MainSettingView:onBindResponse()")
- local response = event.response
- local errCode = response.ret
- if errCode == BIND_TYPE_RESULT.PHONE or errCode == BIND_TYPE_RESULT.WEIXIN then
- self:setPlayerInfo()
- end
- end
-
- function MainSettingView:onChangePlayerInfoResponse(event)
- logD("MainSettingView:onChangePlayerInfoResponse()")
- local response = event.response
- local errCode = response.ret
- local requestType = response.requestType
- if errCode == 0 then
- if requestType == ChangePlayerInfo.REPLCACE_PHONE then
- self:setPlayerInfo()
- end
- end
- end
-
- function MainSettingView:onClubBelongEvent(data)
- if not data then
- return
- end
- local result = data.result
- local bindInfo = result.bindInfo
- if bindInfo then
- self.ui.Items.Layout_clubbelong:setVisible(true)
- else
- self.ui.Items.Layout_clubbelong:setVisible(false)
- end
- self.ui.Items.Layout_btns:requestDoLayout()
- self.ui.Items.Layout_btns:doLayout()
- end
-
-
- function MainSettingView:onCheckForbidClubInvite(data)
- if not data then
- return
- end
- local response = data.response
- if response and response.isallowgroup then
- -- 设置默认状态
- local isallowgroup = tonumber(response.isallowgroup)
- local ttSelected = {}
- if isallowgroup > 0 then
- table.insert(ttSelected,"forbidClubInvite")
- end
- self.checkBoxForbid:setDefault(ttSelected);
- end
- end
-
- function MainSettingView:onClickAgreement()
- app.plugin:callUrl(LoginConfig.AgreementUrl)
- end
-
- function MainSettingView:onClickPrivate()
- --app.plugin:callUrl(LoginConfig.PrivateUrl)
- local view = import("luaScript.Views.Main.LogOut.LogOutPrivateTips"):new()
- view:setAnchorPoint(cc.p(0.5,0.5))
- app:showWaitDialog(view,nil,false)
- end
-
- function MainSettingView:onClickAccountLogOut()
- local logOut = app.user.logOut
- if logOut.status == 0 then
- local text = "注销账号将会清除您的账号及账号内的资产,且无法恢复"
- local notice = "是否确认注销账号?"
- local okCallBack = function()
- local view = import("luaScript.Views.Main.LogOut.LogOutView"):new()
- view:setAnchorPoint(cc.p(0.5,0.5))
- app:showWaitDialog(view,nil,false)
- end
- local cancelCallBack = function()
-
- end
- showConfirmDialog(text, okCallBack, cancelCallBack, 26, nil, notice, false);
- else
- local view = import("luaScript.Views.Main.LogOut.LogOutRevoke"):new()
- view:setAnchorPoint(cc.p(0.5,0.5))
- app:showWaitDialog(view,nil,false)
- end
- end
-
- return MainSettingView;
|