You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

694 lines
21 KiB

  1. local CoinFunctions = import("luaScript.Views.Coin.Util.CoinFunctions");
  2. -- 充值界面
  3. local RechargeView = class("RechargeView", cc.UIView)
  4. function RechargeView:ctor(shopType,isWebGame,isOpenCoinGame,pid)
  5. RechargeView.super.ctor(self)
  6. self.ui = loadUI("res/ui/ui_dating/ui_chongzhi.ui")
  7. self:addChild(self.ui)
  8. self.ui.Items.Layout_liquan_shuoming:setVisible(false)
  9. self.btnRadioManager = import("luaScript.Tools.RadioManager"):new()
  10. self.isWebGame = isWebGame
  11. --此类型和PHP传过来的type类型需要对应上,且ui上显示的按钮也需要和此类型对应
  12. self.shopType = shopType or STORE_TYPE.BUY_ZUANSHI
  13. --是否在金币场游戏中(金币场游戏中可能打开商城界面)
  14. self.isOpenCoinGame = isOpenCoinGame
  15. --self:requestBuyRecord()
  16. self.pid = pid
  17. if self.pid then
  18. self.ui.Items.ImageView_BG:loadTexture(string.format("res/ui/zy_dating/dating/dating_di_%d.jpg",self.pid))
  19. end
  20. end
  21. function RechargeView:onEnter()
  22. RechargeView.super.onEnter(self)
  23. self:initButton()
  24. self:initUI()
  25. --初始化购买钻石界面
  26. self:initRechargeView()
  27. -- 默认显示充值界面
  28. self:showRechargeView()
  29. --显示顶部数据信息
  30. self:showTopInfo()
  31. self:initBindEvent()
  32. --请求商城数据
  33. if not app.phpShop.shopData then
  34. --没有数据,需要去获取数据
  35. app.phpShop:getShopInfo()
  36. end
  37. if isReviewVersion() then
  38. self.ui.Items.CheckBox_liquan:setVisible(false)
  39. self.ui.Items.CheckBox_huanledou:setVisible(false)
  40. self.ui.Items.CheckBox_qinyouquanbg:setVisible(false)
  41. self.ui.Items.CheckBox_datingbg:setVisible(false)
  42. self.ui.Items.CheckBox_liaotianqipao:setVisible(false)
  43. self.ui.Items.CheckBox_yuyinqipao:setVisible(false)
  44. end
  45. self.Time = cc.Director:getInstance():getScheduler():scheduleScriptFunc(function()
  46. cc.Director:getInstance():getScheduler():unscheduleScriptEntry(self.Time)
  47. if app.user.logOut.status == 1 then
  48. local view = import("luaScript.Views.Main.LogOut.LogOutTips"):new()
  49. view:setAnchorPoint(cc.p(0.5,0.5))
  50. app:showWaitDialog(view,nil,false)
  51. self:onClickClose();
  52. return
  53. end
  54. end,0.1,false)
  55. end
  56. function RechargeView:initButton()
  57. self.ui.Items.Button_Close:registerClick(handler(self , self.onClickClose));
  58. --兑换记录
  59. self.ui.Items.Button_history:registerClick(handler(self , self.onClickHistory));
  60. --背包
  61. self.ui.Items.Button_BeiBao:registerClick(handler(self, self.onClickGotoBag))
  62. self.btnRadioManager:addItem(self.ui.Items.CheckBox_buy_jinbi_bg, STORE_TYPE.CHANGE_COIN)--兑换金币
  63. if self.isOpenCoinGame then
  64. --在金币场游戏中打开此界面时,只显示金币
  65. self.ui.Items.CheckBox_huanledou:setVisible(false)
  66. self.ui.Items.CheckBox_buy_bg:setVisible(false)
  67. self.ui.Items.CheckBox_liquan:setVisible(false)
  68. self.ui.Items.CheckBox_qinyouquanbg:setVisible(false)
  69. self.ui.Items.CheckBox_datingbg:setVisible(false)
  70. self.ui.Items.CheckBox_liaotianqipao:setVisible(false)
  71. self.ui.Items.CheckBox_yuyinqipao:setVisible(false)
  72. else
  73. self.btnRadioManager:addItem(self.ui.Items.CheckBox_huanledou, STORE_TYPE.BUY_HUANLEDOU)--购买欢乐豆
  74. self.btnRadioManager:addItem(self.ui.Items.CheckBox_buy_bg, STORE_TYPE.BUY_ZUANSHI) --购买钻石
  75. self.btnRadioManager:addItem(self.ui.Items.CheckBox_liquan, STORE_TYPE.CHANGE_LIQUAN) --礼券兑换
  76. self.btnRadioManager:addItem(self.ui.Items.CheckBox_qinyouquanbg, STORE_TYPE.CHANGE_QYQBG) --亲友圈背景兑换
  77. self.btnRadioManager:addItem(self.ui.Items.CheckBox_datingbg, STORE_TYPE.CHANGE_DTBG) --大厅背景兑换
  78. self.btnRadioManager:addItem(self.ui.Items.CheckBox_liaotianqipao, STORE_TYPE.CHANGE_LTQP) --聊天气泡兑换
  79. self.btnRadioManager:addItem(self.ui.Items.CheckBox_yuyinqipao, STORE_TYPE.CHANGE_YYQP) --语音气泡兑换
  80. end
  81. --默认显示购买按钮为选中状态
  82. local index = self.shopType
  83. self:updateLeftBtnStatus(tonumber(index))
  84. self.btnRadioManager:setDefault(index)
  85. local callBack = function ( value )
  86. playBtnEffect()
  87. local selectImgName = string.format("res/ui/zy_dating/chongzhi/chongzhi_btn_left_normal_%d.png",index)
  88. self.selectImageView:loadTexture(selectImgName)
  89. --购买
  90. self:showRechargeView()
  91. --更新左边按钮
  92. self:updateLeftBtnStatus(tonumber(value))
  93. self.shopType = value
  94. index = value
  95. self:initRechargeView()
  96. self:showTopInfo()
  97. --选择非礼券选项,隐藏礼券说明框
  98. if tonumber(value) ~= STORE_TYPE.CHANGE_LIQUAN then
  99. self.ui.Items.Layout_liquan_shuoming:setVisible(false)
  100. end
  101. end
  102. self.btnRadioManager:setCallback(callBack)
  103. -- 未成年人消费限制
  104. self.ui.Items.Layout_tip:registerClick(handler(self, self.onOpenTip))
  105. end
  106. function RechargeView:onOpenTip()
  107. local view = import("luaScript.Views.Main.RechargeXianzhiTip"):new()
  108. view:setAnchorPoint(cc.p(0.5, 0.5))
  109. app:showWaitDialog(view)
  110. end
  111. function RechargeView:initUI()
  112. --金币数量
  113. self.ui.Items.Text_jinbi:bind(app.user.loginInfo, "curJingbiNum", function()
  114. --超过1w的金币,后面显示文字
  115. local strCoin = CoinFunctions.getCoinDisplayText(app.user.loginInfo.curJingbiNum)
  116. self.ui.Items.Text_jinbi:setString(strCoin)
  117. end )
  118. -- 钻石数量
  119. self.ui.Items.Text_zuanshiNum:bind(app.user.loginInfo, "curCardNum", function()
  120. self.ui.Items.Text_zuanshiNum:setString(tostring(app.user.loginInfo.curCardNum))
  121. end )
  122. --欢乐豆
  123. self.ui.Items.Text_huanledou:bind(app.user.loginInfo, "curBeanNum", function()
  124. self.ui.Items.Text_huanledou:setString(tostring(app.user.loginInfo.curBeanNum))
  125. end )
  126. --礼券
  127. self.ui.Items.Text_liquan:bind(app.user.loginInfo, "curLiquanNum", function()
  128. local strLiquan = CoinFunctions.getCoinDisplayText(app.user.loginInfo.curLiquanNum)
  129. self.ui.Items.Text_liquan:setString(strLiquan)
  130. end )
  131. self.ui.Items.Layout_liquan:registerClick(function ()
  132. playBtnEffect()
  133. self.ui.Items.Layout_liquan_shuoming:setVisible(not self.ui.Items.Layout_liquan_shuoming:isVisible())
  134. end);
  135. --点击非礼券说明的地方,隐藏礼券说明框
  136. self.ui.Items.Layout_1:registerClick(function ()
  137. self.ui.Items.Layout_liquan_shuoming:setVisible(false)
  138. end)
  139. self.ui.Items.CheckBox_liquan:setVisible(self:isShowLiQuanTab())
  140. self.ui.Items.CheckBox_qinyouquanbg:setVisible(app.config.ModuleConfig.IsSupportPropShop)
  141. self.ui.Items.CheckBox_datingbg:setVisible(app.config.ModuleConfig.IsSupportPropShop)
  142. self.ui.Items.CheckBox_liaotianqipao:setVisible(app.config.ModuleConfig.IsSupportPropShop)
  143. self.ui.Items.CheckBox_yuyinqipao:setVisible(app.config.ModuleConfig.IsSupportPropShop)
  144. self.ui.Items.CheckBox_huanledou:setVisible(app.config.ModuleConfig.IsSupportYouXianBean)
  145. self.ui.Items.CheckBox_buy_jinbi_bg:setVisible(app.config.ModuleConfig.IsSupportCoin)
  146. self.ui.Items.Layout_2:requestDoLayout()
  147. self.ui.Items.Layout_2:doLayout();
  148. local layoutLeftSize = self.ui.Items.Layout_2:getContentSize()
  149. autoAdaptHeight(self.ui.Items.ImageView)
  150. autoAdaptHeight(self.ui.Items.ScrollView_left)
  151. if layoutLeftSize then
  152. self.ui.Items.ScrollView_left:setInnerContainerSize(layoutLeftSize)
  153. end
  154. self.ui.Items.Layout_record_item:setVisible(false)
  155. self.ui.Items.Layout_buy_item:setVisible(false)
  156. self.ui.Items.Layout_liquan_item:setVisible(false)
  157. end
  158. --- RechargeView:isShowLiQuanTab 是否显示左侧礼券tab
  159. function RechargeView:isShowLiQuanTab ()
  160. return false;
  161. end
  162. function RechargeView:initBindEvent()
  163. --商品信息拉取
  164. self:bindEvent(app.phpShop, "getShopInfoSuccessed", handler(self, self.initRechargeView))
  165. --兑换金币回调
  166. self:bindEvent(app.phpShop , "exchangeCoinSuccess" , handler(self , self.onDuiHuanCoin));
  167. --操作成功
  168. self:bindEvent(app , "onBagOperateResponse" , handler(self , self.onBagOperateResponse));
  169. end
  170. function RechargeView:onBagOperateResponse()
  171. if not app.php.mypropdata then
  172. return
  173. end
  174. for k,v in pairs(app.php.mypropdata) do
  175. if v.prop_id and v.prop_id >= 200 and v.prop_id < 300 then
  176. self.pid = v.prop_id
  177. self.ui.Items.ImageView_BG:loadTexture(string.format("res/ui/zy_dating/dating/dating_di_%d.jpg",v.prop_id))
  178. end
  179. end
  180. showTooltip("装扮成功")
  181. end
  182. --更新左边按钮选中状态图片
  183. function RechargeView:updateLeftBtnStatus(value)
  184. local selectImgName = string.format("res/ui/zy_dating/chongzhi/chongzhi_btn_left_select_%d.png", value)
  185. self.selectImageView = self.ui.Items["ImageView_buy_"..value]
  186. self.selectImageView:loadTexture(selectImgName)
  187. end
  188. -- 创建一个充值项的ui
  189. function RechargeView:createRechargeItem(config, idx)
  190. --[[
  191. ["10023"] = {
  192. ["currency"] = 2,
  193. ["desc"] = 18房卡,
  194. ["icon"] = http://api.dingdingqipai.com/pic/d_18.png,
  195. ["id"] = 10023,
  196. ["name"] = 18房卡,
  197. ["number"] = 18,
  198. ["order"] = 2,
  199. ["pay_type"] = {
  200. [1] = {
  201. ["id"] = 2,
  202. ["name"] = 微信支付,
  203. },
  204. [2] = {
  205. ["id"] = 3,
  206. ["name"] = H5支付,
  207. },
  208. },
  209. ["price"] = 18,
  210. ["privilege_icon"] = ,
  211. ["product_id"] = ,
  212. },
  213. --]]
  214. local uiTemplate = self.ui.Items.Layout_buy_item
  215. local uiItem = uiTemplate:getCopied()
  216. uiItem.Items = getUIItems(uiItem)
  217. --最热标签
  218. -- if idx ==3 then--> 1 and idx < 5 then
  219. -- uiItem.Items.ImageView_hot:setVisible(true)
  220. -- else
  221. uiItem.Items.ImageView_hot:setVisible(false)
  222. -- end
  223. local rechargeId = (config.id);
  224. -- 标题
  225. --uiItem.Items.RechargeName:setText(tostring(config.number))
  226. -- 更新商品图标
  227. uiItem.updateIcon = function()
  228. uiItem.Items.ImageIcon:setVisible(false)
  229. local rechargeConfig = app.phpShop.shopData[rechargeId]
  230. if not rechargeConfig then
  231. return
  232. end
  233. local iconUrl = convertIconUrl(rechargeConfig.icon)
  234. local iconFile = getImageNameFromUrl(iconUrl)
  235. local texture = loadTextureFromFile(iconFile)
  236. if texture then
  237. local w = texture:getWidth();
  238. local sz = uiItem.Items.ImageIcon:getContentSize()
  239. uiItem.Items.ImageIcon:setVisible(true)
  240. uiItem.Items.ImageIcon:setTexture2(texture);
  241. --uiItem.Items.ImageIcon:setScale(w / sz.width)
  242. end
  243. end
  244. -- 更新赠送角标
  245. uiItem.updatePrivilege = function()
  246. uiItem.Items.ImageView_zengsong:setVisible(false)
  247. local rechargeConfig = app.phpShop.shopData[rechargeId]
  248. if not rechargeConfig then
  249. return
  250. end
  251. local iconFile = getImageNameFromUrl(rechargeConfig.privilege_icon)
  252. local texture = loadTextureFromFile(iconFile)
  253. if texture then
  254. uiItem.Items.ImageView_zengsong:setVisible(true)
  255. uiItem.Items.ImageView_zengsong:setTexture2(texture);
  256. end
  257. end
  258. local function onUpdateImage(event)
  259. if tolua.isnull(uiItem) then
  260. return
  261. end
  262. if not event or event.id ~= rechargeId then
  263. return
  264. end
  265. uiItem.updateIcon();
  266. uiItem.updatePrivilege();
  267. end
  268. -- 监听下载事件,本充值项的图片下载成功时更新图片
  269. uiItem:bindEvent(app.phpShop, "downloadImageSuccessed", onUpdateImage);
  270. onUpdateImage({id = config.id});
  271. -- 价格
  272. uiItem.Items.RechargeNum:setText(tostring(config.price))
  273. --标识图
  274. if tonumber(config.type) == STORE_TYPE.CHANGE_COIN or tonumber(config.type) >= STORE_TYPE.CHANGE_QYQBG then
  275. uiItem.Items.ImageView_9:loadTexture("res/ui/zy_tongyong/zy_icon/icon_zuanshi.png")
  276. uiItem.Items.ImageView_10:loadTexture("res/ui/zy_dating/chongzhi/chongzhi_img_ke.png")
  277. else
  278. uiItem.Items.ImageView_9:loadTexture("res/ui/zy_dating/chongzhi/chongzhi_img_zuanshi_btn.png")
  279. uiItem.Items.ImageView_10:loadTexture("res/ui/zy_dating/chongzhi/chongzhi_img_yuan.png")
  280. end
  281. -- 按钮
  282. uiItem.Items.ImageIcon:registerClick(function()
  283. playBtnEffect()
  284. logD("RechargeView:createRechargeItem(), onClickBuy, config = ", table.tostring(config))
  285. if tonumber(config.type) >= STORE_TYPE.CHANGE_QYQBG then
  286. local view = import("luaScript.Views.Recharge.StoreDuiHuanView"):new(config.type,config.prop_id,0);
  287. view:setAnchorPoint(cc.p(0.5, 0.5))
  288. app:showWaitDialog(view)
  289. return
  290. end
  291. if tonumber(config.type) == STORE_TYPE.CHANGE_COIN then
  292. --金币兑换
  293. CoinFunctions.exchangeCoinFromDiamond(config.id,config.price,config.number)
  294. return
  295. end
  296. local payTypeSize = table.nums(config.pay_type)
  297. if payTypeSize==0 then
  298. showConfirmDialog("支付不可用,请联系客服手工充值!")
  299. return
  300. end
  301. local payTypeInfo = config.pay_type[1]
  302. if payTypeSize == 1 and payTypeInfo and tonumber(payTypeInfo.id) == PayType.Apple then
  303. logD("payTypeInfo = ", table.tostring(payTypeInfo))
  304. app.plugin:payIosPay(config);
  305. else
  306. local view = import("luaScript.Views.Main.RechargeViewChoice"):new(config)
  307. view:setAnchorPoint(cc.p(0.5, 0.5))
  308. app:showWaitDialog(view)
  309. end
  310. end)
  311. return uiItem;
  312. end
  313. -- 创建一个礼券兑换项的ui
  314. function RechargeView:createLiquanItem(config, idx)
  315. local uiTemplate = self.ui.Items.Layout_liquan_item
  316. local uiItem = uiTemplate:getCopied()
  317. uiItem.Items = getUIItems(uiItem)
  318. --最热标签
  319. uiItem.Items.ImageView_hot_liquan:setVisible(false)
  320. local rechargeId = (config.id);
  321. -- 更新商品图标
  322. uiItem.updateIcon = function()
  323. uiItem.Items.ImageIcon_liquan:setVisible(false)
  324. local rechargeConfig = app.phpShop.shopData[rechargeId]
  325. if not rechargeConfig then
  326. return
  327. end
  328. local iconFile = getImageNameFromUrl(rechargeConfig.icon)
  329. local texture = loadTextureFromFile(iconFile)
  330. if texture then
  331. local w = texture:getWidth();
  332. local sz = uiItem.Items.ImageIcon_liquan:getContentSize()
  333. uiItem.Items.ImageIcon_liquan:setVisible(true)
  334. uiItem.Items.ImageIcon_liquan:setTexture2(texture);
  335. end
  336. end
  337. -- 更新赠送角标
  338. uiItem.updatePrivilege = function()
  339. uiItem.Items.ImageView_zengsong_liquan:setVisible(false)
  340. local rechargeConfig = app.phpShop.shopData[rechargeId]
  341. if not rechargeConfig then
  342. return
  343. end
  344. local iconUrl = convertIconUrl(rechargeConfig.icon)
  345. local iconFile = getImageNameFromUrl(iconUrl)
  346. local texture = loadTextureFromFile(iconFile)
  347. if texture then
  348. uiItem.Items.ImageView_zengsong_liquan:setVisible(true)
  349. uiItem.Items.ImageView_zengsong_liquan:setTexture2(texture);
  350. end
  351. end
  352. local function onUpdateImage(event)
  353. if tolua.isnull(uiItem) then
  354. return
  355. end
  356. if not event or event.id ~= rechargeId then
  357. return
  358. end
  359. uiItem.updateIcon();
  360. uiItem.updatePrivilege();
  361. end
  362. -- 监听下载事件,本充值项的图片下载成功时更新图片
  363. uiItem:bindEvent(app.phpShop, "downloadImageSuccessed", onUpdateImage);
  364. onUpdateImage({id = config.id});
  365. -- 价格
  366. local itemPrice = config.price
  367. if tonumber(config.price) > 10000 then
  368. itemPrice = itemPrice / 10000
  369. uiItem.Items.Layout_wan:setVisible(true)
  370. else
  371. uiItem.Items.Layout_wan:setVisible(false)
  372. end
  373. uiItem.Items.RechargeNum_liquan:setText(tostring(itemPrice))
  374. --重新布局
  375. uiItem.Items.Layout_7:requestDoLayout();
  376. uiItem.Items.Layout_7:doLayout();
  377. -- 礼券兑换按钮
  378. uiItem.Items.ImageIcon_liquan:registerClick(function()
  379. playBtnEffect()
  380. if tonumber(app.user.loginInfo.curLiquanNum) < tonumber(config.price) then
  381. --礼券不足
  382. local function callback()
  383. self:removeFromParent()
  384. end
  385. local view = import("Views.Main.LiquanBuzuView"):new(callback)
  386. view:setAnchorPoint(cc.p(0.5, 0.5))
  387. app:showWaitDialog(view)
  388. return
  389. end
  390. if idx == 1 or idx == 2 then
  391. --兑换金币或钻石
  392. else
  393. --兑换实物
  394. local function onOk()
  395. end
  396. -- showConfirmDialog("请联系客服微信进行兑换:ddph5566", onOk);
  397. showConfirmDialog("请联系客服进行兑换", onOk);
  398. end
  399. end)
  400. return uiItem;
  401. end
  402. -- 初始化充值项
  403. function RechargeView:initRechargeView()
  404. local shopData = app.phpShop.shopData
  405. if not shopData then
  406. return
  407. end
  408. app.phpShop:onDownLoadImageByType(tonumber(self.shopType))
  409. local ttshopdata = {}
  410. for k,v in pairs (shopData) do
  411. table.insert(ttshopdata,v)
  412. end
  413. table.sort(ttshopdata,function(a,b)
  414. if a.order and b.order then
  415. if a.order ~= b.order then
  416. return a.order < b.order
  417. else
  418. return a.price < b.price
  419. end
  420. else
  421. return false
  422. end
  423. end)
  424. local uiScrollView = self.ui.Items.ScrollView_buy;
  425. uiScrollView:hideAllBar();
  426. uiScrollView:removeAllChildren()
  427. uiScrollView:getInnerContainer():setAutoSize(true)
  428. local idx = 1
  429. for id, config in pairs(ttshopdata) do
  430. --暂时先只显示六个商品
  431. if config.type == self.shopType then
  432. if tonumber(config.type) == STORE_TYPE.CHANGE_LIQUAN then
  433. --礼券类型创建礼券项
  434. local item = self:createLiquanItem(config, idx)
  435. uiScrollView:addChild(item, config.order)
  436. idx = idx + 1
  437. else
  438. if tonumber(config.type) < STORE_TYPE.CHANGE_QYQBG then
  439. local item = self:createRechargeItem(config, idx)
  440. uiScrollView:addChild(item, config.order)
  441. idx = idx + 1
  442. else
  443. if config.price < 10 then
  444. local item = self:createRechargeItem(config, idx)
  445. uiScrollView:addChild(item, config.order)
  446. idx = idx + 1
  447. end
  448. end
  449. end
  450. end
  451. end
  452. uiScrollView:jumpToTopOnSizeChanged()
  453. end
  454. -- 显示充值界面
  455. function RechargeView:showRechargeView()
  456. self.ui.Items.Layout_buy:setVisible(true)
  457. end
  458. -- 显示金币兑换界面
  459. function RechargeView:showExchangeView()
  460. self.ui.Items.Layout_buy:setVisible(false)
  461. end
  462. -- 关闭界面
  463. function RechargeView:onClickClose()
  464. playBtnCloseEffect()
  465. self:removeFromParent()
  466. if self.isWebGame then
  467. app.phpShop:dispatchEvent({name = GAME_EVENT.RECHARGE_CLOSE})
  468. end
  469. end
  470. function RechargeView:onDuiHuanCoin(data)
  471. if not data then
  472. return;
  473. end
  474. local response = data.response;
  475. local id = response.id
  476. local gold = response.gold --金币
  477. local card = response.card --钻石
  478. local coupons = response.coupons --礼券
  479. local fileName = "res/ui/zy_dating/chongzhi/chongzhi_img_icon.png"
  480. local info = {}
  481. if gold and not coupons then
  482. --只有金币变化,说明是用钻石兑换金币
  483. logD("RechargeView:onDuiHuanCoin zuanshi curJingbiNum = "..table.tostring(app.user.loginInfo.curJingbiNum))
  484. if tonumber(response.lastCoinNum) > tonumber(gold) then
  485. info.coin = tonumber(response.lastCoinNum) - gold;
  486. else
  487. logD("coin",gold)
  488. logD("app.user.loginInfo.curJingbiNum",response.lastCoinNum)
  489. info.coin = gold - tonumber(response.lastCoinNum);
  490. end
  491. app.user.loginInfo.curJingbiNum = gold
  492. info.fileName = fileName
  493. showFuLiConfirmForCoin(info)
  494. elseif gold and coupons then
  495. --礼券和金币同时变化,说明是用礼券兑换了金币
  496. logD("RechargeView:onDuiHuanCoin liquan curJingbiNum = "..table.tostring(app.user.loginInfo.curJingbiNum))
  497. if tonumber(response.lastCoinNum) > tonumber(gold) then
  498. info.coin = tonumber(response.lastCoinNum) - gold;
  499. else
  500. info.coin = gold - tonumber(response.lastCoinNum);
  501. end
  502. app.user.loginInfo.curJingbiNum = gold
  503. app.user.loginInfo.curLiquanNum = coupons
  504. info.fileName = fileName
  505. showFuLiConfirmForCoin(info)
  506. elseif not gold and coupons then
  507. --礼券变化,但金币没变化,表示兑换的是钻石
  508. logD("RechargeView:onDuiHuanCoin curCardNum = "..table.tostring(app.user.loginInfo.curCardNum))
  509. fileName = "res/ui/zy_dating/chongzhi/chongzhi_icon_zuan.png"
  510. info.coupons = app.user.loginInfo.curLiquanNum - coupons;
  511. app.user.loginInfo.curLiquanNum = coupons
  512. info.card = card - app.user.loginInfo.curCardNum
  513. end
  514. info.fileName = fileName
  515. -- 刷新房卡数量
  516. app.user.loginInfo.curCardNum = card
  517. --黄十八兑换道具的时候没有金币返回
  518. if gold then
  519. app.user.loginInfo.curJingbiNum = gold
  520. end
  521. end
  522. --购买/兑换记录
  523. function RechargeView:onClickHistory()
  524. playBtnEffect()
  525. local view = import("luaScript.Views.Main.HistoryView"):new(self.shopType);
  526. view:setAnchorPoint(cc.p(0.5, 0.5))
  527. app:showWaitDialog(view)
  528. end
  529. --根据当前类型显示顶部数据
  530. function RechargeView:showTopInfo()
  531. self.ui.Items.Layout_jinbi:setVisible(app.config.ModuleConfig.IsSupportCoin)
  532. self.ui.Items.Layout_zuanshi:setVisible(true)
  533. self.ui.Items.Layout_liquan:setVisible(false)
  534. --兑换记录按钮
  535. if tonumber(self.shopType) == STORE_TYPE.CHANGE_COIN then
  536. --金币不需要兑换记录
  537. self.ui.Items.Layout_beibao:setVisible(false)
  538. self.ui.Items.Button_history:setVisible(false)
  539. elseif tonumber(self.shopType) == STORE_TYPE.BUY_ZUANSHI or tonumber(self.shopType) == STORE_TYPE.BUY_HUANLEDOU then
  540. --钻石和欢乐豆需要显示购买记录
  541. self.ui.Items.Layout_history:setVisible(true)
  542. self.ui.Items.Layout_beibao:setVisible(false)
  543. self.ui.Items.Button_history:setVisible(true)
  544. self.ui.Items.Button_history:loadTextureNormal("res/ui/zy_dating/chongzhi/chongzhi_btn_buy_history.png")
  545. elseif tonumber(self.shopType) == STORE_TYPE.CHANGE_LIQUAN then
  546. --礼券需要显示兑换记录
  547. self.ui.Items.Button_history:setVisible(true)
  548. self.ui.Items.Button_history:loadTextureNormal("res/ui/zy_dating/chongzhi/chongzhi_btn_exchange_history.png")
  549. else
  550. self.ui.Items.Layout_history:setVisible(false)
  551. self.ui.Items.Layout_beibao:setVisible(true)
  552. end
  553. if isReviewVersion() then
  554. self.ui.Items.Layout_dingdingdou:setVisible(false)
  555. else
  556. self.ui.Items.Layout_dingdingdou:setVisible(app.config.ModuleConfig.IsSupportYouXianBean)
  557. end
  558. self.ui.Items.Layout_top:requestDoLayout();
  559. self.ui.Items.Layout_top:doLayout();
  560. end
  561. function RechargeView:onClickGotoBag()
  562. playBtnEffect()
  563. local view = import("luaScript.Views.Recharge.MineBag"):new();
  564. view:setAnchorPoint(cc.p(0.5, 0.5))
  565. app:showWaitDialog(view)
  566. self:removeFromParent()
  567. end
  568. return RechargeView