|
- -- 充值界面
- local RechargeViewChoice = class("RechargeViewChoice", cc.UIView)
-
- --[[
- ["10212"] = {
- ["currency"] = 2,
- ["desc"] = ,
- ["ext"] = {
- },
- ["icon"] = http://img.dingdingqipai.com/images/goods/5cf0d78bb8eef.png?v=1559287691,
- ["id"] = 10212,
- ["name"] = 250房卡,
- ["number"] = 250,
- ["order"] = 12,
- ["pay_type"] = {
- [1] = {
- ["id"] = 1,
- ["name"] = 苹果支付,
- },
- },
- ["price"] = 50,
- ["privilege_icon"] = ,
- ["product_id"] = com_dangdang_chuannan_50,
- ["prop_id"] = 0,
- ["type"] = 0,
- },
- --]]
-
- function RechargeViewChoice:ctor(rechargeData, callback)
- RechargeViewChoice.super.ctor(self)
-
- self:loadUI()
-
- self.rechargeData = rechargeData
- end
-
- function RechargeViewChoice:loadUI()
- self.ui = loadUI("res/ui/ui_dating/ui_chongzhi_xuanze.ui")
- self:addChild(self.ui)
- end
-
- function RechargeViewChoice:onEnter()
- RechargeViewChoice.super.onEnter(self)
-
- -- --跳转网页支付
- -- self.ui.Items.Button_html5:registerClick(handler(self , self.onClickHtml));
-
- -- --微信原生支付
- -- self.ui.Items.Button_weixin:registerClick(handler(self , self.onClickWeixin));
-
- -- 关闭
- self.ui.Items.Layout_touch:registerClick(handler(self, self.onClickClose));
-
-
- local rechargeData = self.rechargeData;
-
- local payqr = app.serverConfigs.clientConfig.payqr
- local isShowPayQR = (payqr and payqr ~= "") and self:isShowPayQR()
-
- -- 如果system.clicfg有配置该字段,则显示支付宝和微信分享支付
- if isShowPayQR then
- self.ui.Items.Layout_Pay:setVisible(false)
- self.ui.Items.Layout_Pay_2:setVisible(true)
-
- local alipayInfo = nil -- 支付宝支付列表
- for k, v in pairs(rechargeData.pay_type) do
- if v.id == PayType.PAY_TYPE_ALIPAY then
- alipayInfo = v
- break
- end
- end
- if alipayInfo then
- -- 支付宝
- local ui = self.ui.Items.Layout_Item:getCopied()
- ui.Items = getUIItems(ui)
- --支付名
- ui.Items.Text_Name:setText("支付宝支付")
- --图标
- if alipayInfo.id == PayType.PAY_TYPE_ALIPAY then
- ui.Items.Button_Pay:loadTextureNormal("res/ui/zy_tongyong/zy_icon/icon_alipay.png")
- end
- --按钮事件
- ui.Items.Button_Pay:registerClick(function()
- app.phpShop:getOrderID(rechargeData.id, tonumber(alipayInfo.id))
- self:onClickClose()
- end)
- self.ui.Items.Layout_Alipay:addChild(ui)
-
- local str = self:getKeFuString()
- self.ui.Items.Text_Wechat:setString(str)
- else
- local pos = self.ui.Items.Layout_Wechat:getPositionPercent()
- self.ui.Items.Layout_Wechat:setPositionPercent(cc.p(0.5, pos.y))
- self.ui.Items.Text_Wechat:setVisible(false)
- self.ui.Items.ImageView_Line:setVisible(false)
-
- pos = self.ui.Items.Text_Share:getPositionPercent()
- self.ui.Items.Text_Share:setPositionPercent(cc.p(0.5, pos.y))
- end
-
-
- local ui = self.ui.Items.Layout_Item:getCopied()
- ui.Items = getUIItems(ui)
- --支付名
- ui.Items.Text_Name:setText("微信支付")
- --按钮事件
- ui.Items.Button_Pay:registerClick(function()
- local callback = function (fullPath)
- logD("RechargeViewChoice share path:", fullPath)
- local info = {}
- info.scene = "talk"
- info.contentType = "image"
- info.image = fullPath
- info.imageWidth = 1000
- info.thumbWidth = 100
- app.plugin:shareGame(info)
- log("分享支付二维码:",table.tostring(info))
- end
-
- local urlfile = convertIconUrl(payqr)
- local fileName = getImageNameFromUrl(urlfile)
- local fullPath = cc.FileUtils:getInstance():getWritablePath()..fileName;
- local isExist = cc.FileSystem:fileExists(fullPath)
- if not isExist then
- getImageFromUrlWithTime(payqr, fileName, nil, function()
- callback(fullPath)
- end)
- else
- callback(fullPath)
- end
- self:onClickClose()
- end)
-
- self.ui.Items.Layout_Wechat:addChild(ui)
- else
- -- 正常显示
- self.ui.Items.Layout_Pay:setVisible(true)
- self.ui.Items.Layout_Pay_2:setVisible(false)
-
-
- for k,v in pairs(rechargeData.pay_type) do
- local ui = self.ui.Items.Layout_Item:getCopied()
- self.ui.Items.Layout_Pay:addChild(ui)
- ui.Items = getUIItems(ui)
-
- --支付名
- ui.Items.Text_Name:setText(v.name or "")
-
- --图标
- --res/ui/zy_tongyong/zy_icon/icon_weixin.png
-
- if v.id == PayType.PAY_TYPE_ALIPAY then
- ui.Items.Button_Pay:loadTextureNormal("res/ui/zy_tongyong/zy_icon/icon_alipay.png")
- end
-
- --按钮事件
- ui.Items.Button_Pay:registerClick(function()
- if v.id == PayType.Apple then
- app.plugin:payIosPay(self.rechargeData);
- else
- app.phpShop:getOrderID(rechargeData.id, tonumber(v.id))
- end
- self:onClickClose()
- end)
- end
- end
-
- --隐藏模板
- self.ui.Items.Layout_Item:setVisible(false)
- end
-
- function RechargeViewChoice:onClickClose()
- playBtnCloseEffect()
- self:removeFromParent()
- end
-
- function RechargeViewChoice:getKeFuString()
- return ""
- end
-
- function RechargeViewChoice:isShowPayQR()
- return false
- end
-
- return RechargeViewChoice
|