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.

88 lines
2.0 KiB

  1. --
  2. local DaiLiView = class("DaiLiView", cc.UIView)
  3. function DaiLiView:ctor()
  4. DaiLiView.super.ctor(self)
  5. local ui = loadUI("res/ui/ui_dating/ui_dailizhaomu.ui")
  6. self.ui = ui
  7. self:addChild(ui)
  8. self:init()
  9. end
  10. function DaiLiView:init()
  11. self.ui.Items.Button:registerClick(function ()
  12. self:onClickClose()
  13. end)
  14. local wetchatInfo = loadUserInfo("wetchat") or 0
  15. -- 模板
  16. self.itemTemplate = self.ui.Items.Layout_Item
  17. self.itemTemplate:setVisible(false)
  18. self:updateView()
  19. --[[local arr = toStringArray(",")(wetchatInfo)
  20. if arr and table.nums(arr) > 0 then
  21. for k,v in pairs(arr) do
  22. local item = self.itemTemplate:getCopied()
  23. item.Items = getUIItems(item);
  24. item.Items.Text_ID:setText(tostring(v))
  25. self.ui.Items.Layout_2:addChild(item);
  26. end
  27. end--]]
  28. self:bindEvent(app.php, "getwetChatConfigResponse", handler(self, self.updateView))
  29. end
  30. function DaiLiView:updateView()
  31. -- 容器
  32. self.ui.Items.Layout_2:removeAllChildren()
  33. -- 数据
  34. local dailis = app.php.daili[0] or app.php.daili[-1] or {}
  35. local txt = ""
  36. local showNum = 0
  37. for k,v in pairs(dailis) do
  38. --[[if txt == "" then
  39. txt = txt..v
  40. else
  41. txt = txt.." , "..v
  42. end--]]
  43. local item = self.itemTemplate:getCopied()
  44. item.Items = getUIItems(item);
  45. item.Items.Button_copy:registerClick(function ()
  46. playBtnEffect()
  47. if v and type(v) == "string" then
  48. copyStringToClipboard(v)
  49. else
  50. copyStringToClipboard("")
  51. end
  52. --showTooltip("复制成功!")
  53. app.plugin:gotoWeiXin()
  54. end)
  55. item.Items.Text_ID:setText(tostring(v))
  56. local srcSize = item.Items.ImageView_2:getSize()
  57. local width = item.Items.Text_ID:getSize().width
  58. item.Items.ImageView_2:setSize(cc.size(width + 10,srcSize.height))
  59. self.ui.Items.Layout_2:addChild(item);
  60. showNum = showNum + 1
  61. end
  62. if showNum >2 then
  63. --self.ui.Items.ImageView:loadTexture("res/ui/zy_dating/daili/daili_di2.png" ,0)
  64. end
  65. end
  66. function DaiLiView:onClickClose()
  67. playBtnCloseEffect()
  68. app:dispatchEvent({name = GAME_EVENT.ACTIVITY_CLOSE})
  69. self:removeFromParent()
  70. end
  71. return DaiLiView