-- 大厅分享选择 local HallShareView = class("HallShareView", cc.UIView) function HallShareView:ctor() HallShareView.super.ctor(self); local ui = loadUI("res/ui/ui_dating/ui_dating_sharechose.ui") self.ui = ui self:addChild(ui) self.lastClick = 0 self.sharehy = false self.sharepyq = false end function HallShareView:onEnter() HallShareView.super.onEnter(self) self.ui.Items.Button_Close:registerClick(handler(self , self.onClickClose)) self.ui.Items.Button_share_hy:registerClick(handler(self , self.onShareHy))--分享给好友 self.ui.Items.Button_share_pyq:registerClick(handler(self , self.onSharePyq))--分享朋友圈 -- 更新提示信息 self:updateTips(); self:bindEvent(app, "onGetShareRewardResponse", handler(self, self.onGetShareRewardResponse)) self:updateView(); end --- HallShareView:updateTips 更新提示信息 function HallShareView:updateTips() local strTips = string.format("每日首次分享成功后,即可免费获得15%s%s", PLN.CURRENCY_UNIT, PLN.CURRENCY); self.ui.Items.Text_tips:setString(strTips); end function HallShareView:updateView() logD("HallShareView:updateView") local misstions,index = app.serverConfigs:getMissionListByType(2) for k,v in pairs(misstions) do if v.ext then local ext = json.decode(v.ext) if ext and ext.view == "ActivityShareView" then self.mission = v end end end logD("HallShareView:updateView", self.mission) if not self.mission then logD("HallShareView:updateView", "分享任务不存在"); return end if not self.mission.ext then logD("HallShareView:updateView", "扩展配置错误", self.mission); return end local ext = json.decode(self.mission.ext) if not ext then logD("HallShareView:updateView", "ext解析为空", self.mission.ext); return end local urlfile2, time2 = convertIconUrl(ext.share_pic) self.fileName2 = getImageNameFromUrl(urlfile2) logD("HallShareView:updateView fileName2: ", self.fileName2) local fullPath = cc.FileUtils:getInstance():getWritablePath()..self.fileName2; app.waitDialogManager:showWaitNetworkDialog("获取分享内容") getImageFromUrlWithTime(ext.share_pic, self.fileName2, nil, function() app.waitDialogManager:closeWaitNetworkDialog() end) end -- 关闭 function HallShareView:onClickClose() playBtnCloseEffect() self:removeFromParent() end -- 分享给好友 function HallShareView:onShareHy() playBtnCloseEffect() local timeNow = os.time(); if timeNow - self.lastClick <= 5 then showTooltip("点击太过频繁,请稍后再试") return end self.lastClick = timeNow; if cc.Application:getInstance():getTargetPlatform() == cc.PLATFORM_OS_ANDROID then local imagePath = cc.FileUtils:getInstance():getWritablePath()..self.fileName2; --local imagePath = cc.FileUtils:getInstance():getWritablePath().."icon.png" local function requestGetReward() app.php:requestGetShareReward() end local info = {} info.scene = "talk" info.contentType = "image" info.image = imagePath info.imageWidth = 1000 info.thumbWidth = 100 app.plugin:shareGame(info,requestGetReward) else app.php:requestGetShareReward() end self.sharehy = true self.sharepyq = false end -- 分享朋友圈 function HallShareView:onSharePyq() playBtnCloseEffect() local timeNow = os.time(); if timeNow - self.lastClick <= 5 then showTooltip("点击太过频繁,请稍后再试") return end self.lastClick = timeNow; if cc.Application:getInstance():getTargetPlatform() == cc.PLATFORM_OS_ANDROID then local imagePath = cc.FileUtils:getInstance():getWritablePath()..self.fileName2; --local imagePath = cc.FileUtils:getInstance():getWritablePath().."icon.png" local function requestGetReward() app.php:requestGetShareReward() end local info = {} info.scene = "friend" info.contentType = "image" info.image = imagePath info.imageWidth = 1000 info.thumbWidth = 100 app.plugin:shareGame(info,requestGetReward) else app.php:requestGetShareReward() end self.sharehy = false self.sharepyq = true end function HallShareView:onGetShareRewardResponse(result) if cc.Application:getInstance():getTargetPlatform() == cc.PLATFORM_OS_ANDROID then if result.data.flag == -1 then showTooltip("今日已领取过奖励!") else local addNum = result.data.add self:showRewardAnimation(addNum); end else local imagePath = cc.FileUtils:getInstance():getWritablePath()..self.fileName2; --local imagePath = cc.FileUtils:getInstance():getWritablePath().."icon.png" local function requestGetReward() --app.php:requestGetShareReward() end local info = {} info.scene = "friend" if self.sharehy then info.scene = "talk" end info.contentType = "image" info.image = imagePath info.imageWidth = 1000 info.thumbWidth = 100 app.plugin:shareGame(info,requestGetReward) if result.data.flag == -1 then showTooltip("今日已领取过奖励!") else self:runAction(cc.Sequence:create(cc.DelayTime:create(1.2),cc.CallFunc:create(function () local addNum = result.data.add self:showRewardAnimation(addNum); end))) end end end --- HallShareView:showRewardAnimation 显示获得房卡动画 function HallShareView:showRewardAnimation(addNum) local view = import("luaScript.Views.Main.JiangLi"):new(addNum) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view, 200, true) end return HallShareView;