ShareWxView.lua
2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
local ShareWxView = dialog.uinode("ui/ShareWxLayer.csb",import(".BaseView"))
--微信分享界面
function ShareWxView:ctor()
ShareWxView.super.ctor(self);
end
function ShareWxView:show(selectedIndex)
local scene = cc.Director:getInstance():getRunningScene()
local inst = ShareWxView:create();
scene:addChild(inst, dialog.ZORDER_POP);
local panel = inst:getChildByName("panel");
panel:setScale(0.5);
local scaleTo = cc.ScaleTo:create(0.2,1);
panel:runAction(scaleTo);
selectedIndex = selectedIndex or 1;
inst.selectedIndex = selectedIndex;
inst:init();
UmengHelper.onEvent("share");
return inst;
end
function ShareWxView:init()
self:setContentSize(cc.size(display.width,display.height));
ccui.Helper:doLayout(self);
local btn_1 = self:getChildByName("panel"):getChildByName("btn_1");
btn_1.fn = handler(self,self.onShareFriend);
btn_1:addTouchEventListener(function(ref,type) self:onButtonClick(ref,type, btn_1.fn)end);
local btn_2 = self:getChildByName("panel"):getChildByName("btn_2");
btn_2.fn = handler(self,self.onShareTimeLine);
btn_2:addTouchEventListener(function(ref,type) self:onButtonClick(ref,type, btn_2.fn)end);
local btn_close = self:getChildByName("panel"):getChildByName("btn_close");
btn_close.fn = handler(self,self.onClose);
btn_close:addTouchEventListener(function(ref,type) self:onButtonClick(ref,type, btn_close.fn)end);
self.nodes[1] = {btn_close};
self.nodes[2] = {btn_1,btn_2};
self.nodeIndex = 2;
self:updateSelectedState();
end
function ShareWxView:onShareFriend()
self:shareToWx(0);
self:close();
end
function ShareWxView:onShareTimeLine()
self:shareToWx(1);
self:close();
end
function ShareWxView:onClose()
self:close();
end
function ShareWxView:shareToWx(shareScene)
local function onShareBackFun(result)
if result == "success" then
if shareScene== 0 then
SocketClient:getInstance():send("gateway_msg.mail_share_private_give_msg",{});
else
SocketClient:getInstance():send("gateway_msg.mail_share_public_give_msg",{});
end
elseif result == "notinstalled" then
Alert.showOne("未安装微信,请先安装微信");
end
end
local obj = {};
obj.url = SHARE_URL;
obj.title = "全家棋牌";
obj.content = "全家棋牌是一款包含斗地主、麻将、掼蛋、牛牛等棋牌游戏的游戏大厅";
obj.scene = shareScene;
DeviceUtil.ShareWxWebpage(json.encode(obj),onShareBackFun);
end
--返回键处理函数
function ShareWxView:onKeypadBack()
if self.cancelFun then
self.cancelFun();
end
self:close();
end
return ShareWxView