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.

771 lines
26 KiB

  1. -- 战绩界面
  2. local ClubZhanJiView = class("ClubZhanJiView", cc.UIView)
  3. local ClubDefine = require("luaScript.Protocol.Club.ClubDefine")
  4. function ClubZhanJiView:ctor(data, tableIdx)
  5. ClubZhanJiView.super.ctor(self)
  6. self.ui = loadUI("res/ui/ui_club/ui_club_zhanji.ui")
  7. self:addChild(self.ui)
  8. self.clubInfo = data;
  9. --从房间返回茶馆的桌子标识
  10. self.tableIdx = tableIdx
  11. --战绩可选天数
  12. self.zhanjiDay = 3;
  13. --界面可设置总天数
  14. self.dayCount = 10;
  15. --天数复制的ui
  16. self.dayTable = {};
  17. self.months = {}
  18. self.curMonthIdx = 1;
  19. self.defaultDate = os.date("%Y-%m-%d");
  20. self.curShowType = 0; -- ClUB_ZHANJI_TYPE.Club or ClUB_ZHANJI_TYPE.Mine
  21. self.curPage = 1; -- 页数
  22. self.curDate = self.defaultDate; -- 当前显示的战绩日期
  23. --只用于是否播放标签页按钮音效
  24. self.touchIdx = 1;
  25. end
  26. function ClubZhanJiView:onEnter()
  27. ClubZhanJiView.super.onEnter(self)
  28. self:initView()
  29. self:registerButton()
  30. self:initBindEvent()
  31. --请求战绩消耗(默认请求当天数据)
  32. local cureTime = os.date("%Y-%m-%d")
  33. app.club_zhanji:requestZhanjiConsume(self.clubInfo.clubId, cureTime);
  34. end
  35. function ClubZhanJiView:initView()
  36. self.ui.Items.Layout_Page:setVisible(false)
  37. self.ui.Items.Layout_timeselect:setVisible(false)
  38. self.ui.Items.Layout_time_select:setVisible(false)
  39. self.ui.Items.Layout_no_data:setVisible(false)
  40. self.ui.Items.Layout_tongji_title:setVisible(false)
  41. self.ui.Items.Layout_tongji_content:setVisible(false)
  42. self.ui.Items.Layout_btn_menu:setVisible(false)
  43. self.ui.Items.Layout_riqi:setVisible(false);
  44. self.ui.Items.Button_quxiao:setVisible(false)
  45. --如果自己为管理员或创始人则显示茶馆战绩(1:成员 2:管理员 3:创始人)
  46. self.ui.Items.Layout_manager:setVisible(self.clubInfo.role ~= ClubDefine.Job.Member and self.clubInfo.role ~= ClubDefine.Job.Copartner)
  47. if self.clubInfo.role == ClubDefine.Job.Manager or self.clubInfo.role == ClubDefine.Job.Creator then
  48. if app.club_php:getIsMasterUnion(self.clubInfo.clubId) then
  49. self.ui.Items.Text_club_10:setText("联盟战绩")
  50. self.ui.Items.CheckBox_club:loadTextureFrontCross("res/ui/zy_club/club_zhanji/club_zhanji_all_btn_union.png")
  51. elseif app.club_php:getIsSlaveUnion(self.clubInfo.clubId) then
  52. self.ui.Items.CheckBox_club:loadTextureFrontCross("res/ui/zy_club/club_zhanji/club_zhanji_all_btn_sel_circle.png")
  53. if app.club_php:getCestIsOpen(self.clubInfo.clubId) then
  54. self.ui.Items.CheckBox_club:loadTextureFrontCross("res/ui/zy_club/club_zhanji/club_cest_zhanji_all_btn_sel_circle.png")
  55. end
  56. self.ui.Items.Layout_tongji:setVisible(false)
  57. self.ui.Items.ImageView_1ine_2:setVisible(false)
  58. self.ui.Items.Text_club_10:setText((app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_NAME or PLN.CLUB_NAME).."战绩")
  59. else
  60. if app.club_php:getCestIsOpen(self.clubInfo.clubId) then
  61. self.ui.Items.CheckBox_club:loadTextureFrontCross("res/ui/zy_club/club_zhanji/club_cest_zhanji_all_btn_sel.png")
  62. end
  63. self.ui.Items.Text_club_10:setText((app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_NAME or PLN.CLUB_NAME).."战绩")
  64. end
  65. elseif self.clubInfo.role == ClubDefine.Job.LevelOneCopartner then
  66. self.ui.Items.Layout_txtIntro:setVisible(false)
  67. self.ui.Items.Layout_tongji:setVisible(false)
  68. self.ui.Items.ImageView_1ine_2:setVisible(false)
  69. self.ui.Items.Text_club_10:setText("战队成员战绩")
  70. self.ui.Items.CheckBox_club:loadTextureFrontCross("res/ui/zy_club/club_zhanji/club_zhanji_team_btn_sel_circle.png")
  71. elseif self.clubInfo.role == ClubDefine.Job.LevelTwoCopartner then
  72. self.ui.Items.Layout_txtIntro:setVisible(false)
  73. self.ui.Items.Layout_tongji:setVisible(false)
  74. self.ui.Items.ImageView_1ine_2:setVisible(false)
  75. self.ui.Items.Text_club_10:setText("小队成员战绩")
  76. self.ui.Items.CheckBox_club:loadTextureFrontCross("res/ui/zy_club/club_zhanji/club_zhanji_small_team_btn_sel_circle.png")
  77. elseif self.clubInfo.role == ClubDefine.Job.LevelThreeCopartner then
  78. self.ui.Items.Layout_txtIntro:setVisible(false)
  79. self.ui.Items.Layout_tongji:setVisible(false)
  80. self.ui.Items.ImageView_1ine_2:setVisible(false)
  81. self.ui.Items.Text_club_10:setText("小组成员战绩")
  82. self.ui.Items.CheckBox_club:loadTextureFrontCross("res/ui/zy_club/club_zhanji/club_zhanji_zc_btn_sel_circle.png")
  83. end
  84. self.ui.Items.Layout_manager:requestDoLayout()
  85. self.ui.Items.Layout_manager:doLayout()
  86. if app.club_php:getIsUnion(self.clubInfo.clubId) then
  87. self.ui.Items.Layout_txtIntro:setVisible(false)
  88. else
  89. self.ui.Items.Text_notice:setVisible(false)
  90. end
  91. if PLN.CLUB_UNION_CLUB_ZHANJI then
  92. self.ui.Items.Text_notice:setText(PLN.CLUB_UNION_CLUB_ZHANJI)
  93. end
  94. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  95. self.ui.Items.TextField_search:setPlaceHolder("请输入选手ID")
  96. end
  97. self.ui.Items.TextField_search:setMaxLength(10);
  98. self:bindTextFildTouch()
  99. self:initCurrencyTitle()
  100. end
  101. function ClubZhanJiView:registerButton()
  102. -- 关闭按钮
  103. self.ui.Items.Button:registerClick(handler(self , self.onClickClose))
  104. --点击层
  105. self.ui.Items.Layout_timeselect:registerClick(handler(self , self.onTouch))
  106. --消息分类
  107. local radioManager = import("luaScript.Tools.RadioManager"):new()
  108. radioManager:addItem(self.ui.Items.CheckBox_my,ClUB_ZHANJI_TYPE.Mine)
  109. radioManager:addItem(self.ui.Items.CheckBox_club,ClUB_ZHANJI_TYPE.Club)
  110. radioManager:addItem(self.ui.Items.CheckBox_tongji,ClUB_ZHANJI_TYPE.ZhanjiTongji)
  111. radioManager:setCallback(handler(self , self.onClickTitle))
  112. radioManager:setDefault(ClUB_ZHANJI_TYPE.Mine)
  113. --选择时间
  114. self.ui.Items.Button_time:registerClick(handler(self , self.onClickTime))
  115. self.ui.Items.Layout_time:registerClick(handler(self , self.onClickTime))
  116. -- 翻页按钮
  117. self.ui.Items.Button_Pre:registerClick(handler(self, self.onClickPagePre))
  118. self.ui.Items.Button_Next:registerClick(handler(self, self.onClickPageNext))
  119. self.ui.Items.Button_time_left:registerClick(handler(self , self.onClickTimeLeft))
  120. self.ui.Items.Button_time_right:registerClick(handler(self , self.onClickTimeRight))
  121. --查找
  122. self.ui.Items.Button_search:registerClick(handler(self , self.onSearchPlayerZhanJi))
  123. self.ui.Items.Button_quxiao:registerClick(handler(self , self.onQuXiaoSaiXuan))
  124. self.ui.Items.Layout_riqi:registerClick(handler(self , self.onTouch))
  125. self:initButtonTips()
  126. --初始化日期选择
  127. self:setDays()
  128. end
  129. function ClubZhanJiView:initButtonTips()
  130. self.isHuoDongFangKaInited = false
  131. self.ui.Items.Button_tips:registerClick(handler(self, self.onBtnTipsClicked))
  132. self.ui.Items.Layout_HuoDong_FangKa_Mask:registerClick(handler(self, self.onBtnTipsClicked))
  133. self.ui.Items.Layout_HuoDong_FangKa:setVisible(false)
  134. self.ui.Items.ListView_HuoDong_FangKa:hideAllBar()
  135. self.ui.Items.Text_HuoDong_Title_2:setText(string.format("消耗专用%s数", PLN.CURRENCY))
  136. end
  137. function ClubZhanJiView:onBtnTipsClicked()
  138. local isVisible = not self.ui.Items.Layout_HuoDong_FangKa:isVisible()
  139. self.ui.Items.Layout_HuoDong_FangKa:setVisible(isVisible)
  140. end
  141. function ClubZhanJiView:refreshHuoDongFanKaView(data)
  142. if not (data and #data > 0) then
  143. self.ui.Items.Text_HuoDong_Empty_Tips:setVisible(true)
  144. return ;
  145. end
  146. self.ui.Items.Text_HuoDong_Empty_Tips:setVisible(false)
  147. local listView = self.ui.Items.ListView_HuoDong_FangKa
  148. listView:removeAllItems()
  149. for k,v in pairs(data) do
  150. local gameConfig = app.serverConfigs.subGameList[tonumber(v.game_id)]
  151. if gameConfig then
  152. local item = self.ui.Items.Layout_HuoDong_FangKa_Template:getCopied()
  153. local items = getUIItems(item)
  154. items.Text_Column_1:setText(gameConfig.gameName) -- 游戏名
  155. items.Text_Column_2:setText(v.owner_props_card_count) -- 消耗钻石数量
  156. listView:pushBackCustomItem(item)
  157. end
  158. end
  159. end
  160. function ClubZhanJiView:initBindEvent()
  161. self:bindEvent(app , "ClubZhanjiConsumeCallback" , handler(self , self.onShowConsume));
  162. self:bindEvent(app.club_zhanji, "getZhanjiBriefResponse", handler(self, self.updateZhanJiList))
  163. --监听数据查询回调
  164. self:bindEvent(app.club_php , "MemberStatSuccess" , handler(self , self.MemberStatSuccess));
  165. --监听战绩统计查询回调
  166. self:bindEvent(app.club_zhanji , "onGetZhanjiGroupDateListSucc" , handler(self , self.onGetZhanjiGroupDateListSucc))
  167. --权限发生改变
  168. self:bindEvent(app.club_php , GAME_EVENT.CLUB_CHANGE_ROLE , handler(self , self.onChangeRole));
  169. self:bindEvent(app.club_zhanji , "onDeleteZhanJiResponse", handler(self , self.onDeleteZhanJiResponse));
  170. end
  171. -- 角色权限修改
  172. function ClubZhanJiView:onChangeRole()
  173. self:removeFromParent()
  174. end
  175. --点击层
  176. function ClubZhanJiView:onTouch()
  177. self.ui.Items.Layout_timeselect:setVisible(false)
  178. self.ui.Items.Layout_time_select:setVisible(false);
  179. end
  180. -- 关闭响应函数
  181. function ClubZhanJiView:onClickClose()
  182. playBtnCloseEffect()
  183. self:removeFromParent()
  184. end
  185. -- 提供给单局界面来关闭此界面
  186. function ClubZhanJiView:onCallbackFun()
  187. playBtnEffect()
  188. self:removeFromParent()
  189. end
  190. function ClubZhanJiView:onClickTitle(tag)
  191. self.curShowType = tag
  192. self.curPage = 1
  193. if ClUB_ZHANJI_TYPE.Club == tag then
  194. if self.clubInfo.role ~= ClubDefine.Job.LevelOneCopartner and self.clubInfo.role ~= ClubDefine.Job.LevelTwoCopartner
  195. and self.clubInfo.role ~= ClubDefine.Job.LevelThreeCopartner then
  196. self:setSelectedDay(self.curDate)
  197. else
  198. self.ui.Items.Text_notice:setVisible(false)
  199. self.ui.Items.ScrollView:removeAllChildren()
  200. self.ui.Items.Layout_no_data:setVisible(true)
  201. if app.club_php:getIsQuanMinSai(self.clubInfo.clubId) then
  202. if self.clubInfo.role == ClubDefine.Job.LevelOneCopartner then
  203. self.ui.Items.Text_no_data:setText("请在上方输入您的战队成员id进行查询")
  204. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  205. self.ui.Items.Text_no_data:setText("请在上方输入您的战队选手id进行查询")
  206. end
  207. elseif self.clubInfo.role == ClubDefine.Job.LevelTwoCopartner then
  208. self.ui.Items.Text_no_data:setText("请在上方输入您的小队成员id进行查询")
  209. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  210. self.ui.Items.Text_no_data:setText("请在上方输入您的小队选手id进行查询")
  211. end
  212. elseif self.clubInfo.role == ClubDefine.Job.LevelThreeCopartner then
  213. self.ui.Items.Text_no_data:setText("请在上方输入您的小组成员id进行查询")
  214. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  215. self.ui.Items.Text_no_data:setText("请在上方输入您的小组选手id进行查询")
  216. end
  217. end
  218. end
  219. end
  220. self.ui.Items.Layout_saixuan:setVisible(true)
  221. else
  222. self.ui.Items.Text_no_data:setText("暂无数据,快喊小伙伴一起玩耍吧 : )")
  223. self.ui.Items.Layout_saixuan:setVisible(false)
  224. self.ui.Items.TextField_search:setText("")
  225. self.ui.Items.Button_search:setVisible(true)
  226. self.ui.Items.Button_quxiao:setVisible(false)
  227. end
  228. if tag == ClUB_ZHANJI_TYPE.ZhanjiTongji then
  229. self.ui.Items.Layout_tongji_title:setVisible(true)
  230. self.ui.Items.ScrollView_TongJi:setVisible(true)
  231. self.ui.Items.ScrollView:setVisible(false)
  232. else
  233. self.ui.Items.Layout_tongji_title:setVisible(false)
  234. self.ui.Items.ScrollView_TongJi:setVisible(false)
  235. self.ui.Items.ScrollView:setVisible(true)
  236. end
  237. self:requestUpdateList()
  238. end
  239. --设置天数选中状态
  240. function ClubZhanJiView:setSelectedDay(selectTime)
  241. if self.dayTable and self.dayTable[self.curDate] then
  242. self.dayTable[self.curDate].setSelected(false)
  243. end
  244. self.curDate = selectTime
  245. self.curPage = 1
  246. if self.dayTable and self.dayTable[self.curDate] then
  247. self.dayTable[self.curDate].setSelected(true)
  248. end
  249. self.ui.Items.Layout_timeselect:setVisible(false)
  250. self.ui.Items.Layout_time_select:setVisible(false);
  251. --请求战绩消耗(默认请求当天数据)
  252. app.club_zhanji:requestZhanjiConsume(self.clubInfo.clubId, selectTime);
  253. local searchCont = self.ui.Items.TextField_search:getText();
  254. if searchCont ~= "" then
  255. local isNum = tonumber(searchCont)
  256. if not isNum then
  257. self:requestUpdateList();
  258. return;
  259. end
  260. local length = string.len(searchCont)
  261. if length ~= 7 then
  262. self:requestUpdateList();
  263. return;
  264. end
  265. app.club_zhanji:getIdxlistByPlayerUid(self.clubInfo.clubId, self.curShowType, self.curDate, self.curPage,searchCont,true);
  266. else
  267. self:requestUpdateList();
  268. end
  269. end
  270. function ClubZhanJiView:initCurrencyTitle()
  271. local tongjiTitleLayout = self.ui.Items.Layout_tongji_title
  272. local text3 = tongjiTitleLayout:getChildByName("Text_3")
  273. text3:setString(string.format("消耗%s", PLN.CURRENCY))
  274. local text4 = tongjiTitleLayout:getChildByName("Text_4")
  275. text4:setString(string.format("专用%s", PLN.CURRENCY))
  276. local textHuoDongFangKa = self.ui.Items.Text_font_huodong_fangka
  277. textHuoDongFangKa:setString(string.format("专用%s:", PLN.CURRENCY))
  278. end
  279. function ClubZhanJiView:bindTextFildTouch()
  280. local nodeName = self.ui.Items.TextField_search;
  281. local function onTouchEnded(touch , event)
  282. local searchCont = nodeName:getText();
  283. if searchCont == "" then
  284. --self:updatePlayerList()
  285. return;
  286. end
  287. self.ui.Items.Button_search:setVisible(true)
  288. self.ui.Items.Button_quxiao:setVisible(false)
  289. --self:onSearchPlayer()
  290. end
  291. nodeName:addEventListener(onTouchEnded)
  292. end
  293. --搜索玩家
  294. function ClubZhanJiView:onSearchPlayerZhanJi()
  295. playBtnEffect()
  296. logD("ClubZhanJiView onSearchPlayerZhanJi")
  297. if not self.clubInfo then
  298. showTooltip("self.clubInfo is not exist!")
  299. return
  300. end
  301. local searchCont = self.ui.Items.TextField_search:getText();
  302. if searchCont == "" then
  303. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  304. showTooltip("请输入选手ID!");
  305. else
  306. showTooltip("请输入玩家ID!");
  307. end
  308. return;
  309. end
  310. self.ui.Items.Button_search:setVisible(false)
  311. self.ui.Items.Button_quxiao:setVisible(true)
  312. local isNum = tonumber(searchCont)
  313. if not isNum then
  314. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  315. showTooltip("请输入正确的选手ID!");
  316. else
  317. showTooltip("请输入正确的玩家ID!");
  318. end
  319. return;
  320. end
  321. local length = string.len(searchCont)
  322. if length ~= 7 then
  323. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  324. showTooltip("请输入正确的选手ID!");
  325. else
  326. showTooltip("请输入正确的玩家ID!");
  327. end
  328. return;
  329. end
  330. --搜索时默认搜第一页
  331. self.curPage = 1
  332. app.club_zhanji:getIdxlistByPlayerUid(self.clubInfo.clubId, self.curShowType, self.curDate, self.curPage,searchCont,true);
  333. end
  334. --取消搜索玩家战绩
  335. function ClubZhanJiView:onQuXiaoSaiXuan()
  336. self.ui.Items.TextField_search:setText("")
  337. self.ui.Items.Button_search:setVisible(true)
  338. self.ui.Items.Button_quxiao:setVisible(false)
  339. self.ui.Items.ScrollView:removeAllChildren();
  340. self.ui.Items.Layout_no_data:setVisible(true)
  341. if app.club_php:getIsQuanMinSai(self.clubInfo.clubId) then
  342. if self.clubInfo.role == ClubDefine.Job.LevelOneCopartner then
  343. self.ui.Items.Text_no_data:setText("请在上方输入您的战队成员id进行查询")
  344. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  345. self.ui.Items.Text_no_data:setText("请在上方输入您的战队选手id进行查询")
  346. end
  347. elseif self.clubInfo.role == ClubDefine.Job.LevelTwoCopartner then
  348. self.ui.Items.Text_no_data:setText("请在上方输入您的小队成员id进行查询")
  349. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  350. self.ui.Items.Text_no_data:setText("请在上方输入您的小队选手id进行查询")
  351. end
  352. elseif self.clubInfo.role == ClubDefine.Job.LevelThreeCopartner then
  353. self.ui.Items.Text_no_data:setText("请在上方输入您的小队成员id进行查询")
  354. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  355. self.ui.Items.Text_no_data:setText("请在上方输入您的小队选手id进行查询")
  356. end
  357. end
  358. end
  359. self:requestUpdateList();
  360. end
  361. function ClubZhanJiView:requestUpdateList()
  362. -- 茶馆战绩才显示消耗
  363. self.ui.Items.Layout_xiaohao:setVisible(self.curShowType == ClUB_ZHANJI_TYPE.Club)
  364. if self.curShowType == ClUB_ZHANJI_TYPE.Club and self.clubInfo.role ~= ClubDefine.Job.LevelOneCopartner
  365. and self.clubInfo.role ~= ClubDefine.Job.LevelTwoCopartner and self.clubInfo.role ~= ClubDefine.Job.LevelThreeCopartner then
  366. --请求战绩消耗(默认请求当天数据)
  367. app.club_zhanji:requestZhanjiConsume(self.clubInfo.clubId, self.curDate);
  368. end
  369. -- 请求最新的战绩信息(只有我的战绩和茶馆战绩才请求战绩数据)
  370. if self.curShowType == ClUB_ZHANJI_TYPE.Club
  371. or self.curShowType == ClUB_ZHANJI_TYPE.Mine then
  372. if self.curShowType == ClUB_ZHANJI_TYPE.Club and
  373. (self.clubInfo.role == ClubDefine.Job.LevelOneCopartner or self.clubInfo.role == ClubDefine.Job.LevelTwoCopartner
  374. or self.clubInfo.role == ClubDefine.Job.LevelThreeCopartner) then
  375. else
  376. app.club_zhanji:getIdxlist(self.clubInfo.clubId, self.curShowType, self.curDate, self.curPage);
  377. end
  378. elseif self.curShowType == ClUB_ZHANJI_TYPE.ZhanjiTongji then
  379. --战绩统计数据请求
  380. local startTime = os.date("%Y-%m-%d")
  381. local endTime = os.date("%Y-%m-%d")
  382. app.club_zhanji:requestZhanjiGroupDateList(tonumber(self.clubInfo.clubId), startTime, endTime)
  383. end
  384. if self.curShowType == ClUB_ZHANJI_TYPE.Club and (self.clubInfo.role == ClubDefine.Job.LevelOneCopartner
  385. or self.clubInfo.role == ClubDefine.Job.LevelTwoCopartner or self.clubInfo.role == ClubDefine.Job.LevelThreeCopartner) then
  386. else
  387. --app.waitDialogManager:showWaitNetworkDialog()
  388. end
  389. end
  390. function ClubZhanJiView:updateZhanJiList()
  391. app.waitDialogManager:closeWaitNetworkDialog()
  392. self.ui.Items.ScrollView:setVisible(true)
  393. -- 显示当前页数
  394. local strPage = string.format("%d/%d", self.curPage, app.club_zhanji.tpage)
  395. self.ui.Items.Text_Page:setText(strPage)
  396. self.ui.Items.Layout_Page:setVisible(tonumber(app.club_zhanji.tpage) > 1)
  397. local uiScrollView = self.ui.Items.ScrollView
  398. uiScrollView:getInnerContainer():setAutoSize(true)
  399. uiScrollView:removeAllChildren();
  400. uiScrollView:hideAllBar();
  401. local zhanjiList = app.club_zhanji:getZhanJiList(self.clubInfo.clubId, self.curShowType, self.curPage)
  402. if table.nums(zhanjiList) <= 0 then
  403. --无数据显示
  404. self.ui.Items.Layout_no_data:setVisible(true);
  405. return
  406. else
  407. self.ui.Items.Layout_no_data:setVisible(false);
  408. end
  409. local index = table.nums(zhanjiList)
  410. for logid, zhanjiInfo in pairsByKeysEx(zhanjiList) do
  411. local endtime = tonumber(zhanjiInfo.endtime)
  412. if endtime > 1522684800 then
  413. local uiContent = import("luaScript.Views.Club.ClubZhanJiItem"):new(self.clubInfo.clubId, self.curShowType, zhanjiInfo, self.tableIdx,index)
  414. if uiContent and uiContent.ui then
  415. uiScrollView:addChild(uiContent.ui)
  416. index = index-1
  417. end
  418. end
  419. end
  420. uiScrollView:jumpToTopOnSizeChanged()
  421. end
  422. --显示战绩总消耗
  423. function ClubZhanJiView:onShowConsume(event)
  424. if not event then
  425. return;
  426. end
  427. local roomNum = event.roomNum or 0; --成局数
  428. local cardCost = event.cardCost or 0; --房卡消耗
  429. local activityCardCost = event.activityCardCost; --活动房卡消耗
  430. --总共局数
  431. self.ui.Items.Text_jushu_count:setText(roomNum.."场");
  432. --消耗总房卡
  433. self.ui.Items.Text_fangka_count:setText(cardCost .. PLN.CURRENCY_UNIT);
  434. --活动房卡消耗
  435. if event.activityCardCost and event.activityCardCost > 0 then
  436. self.ui.Items.Text_font_huodong_fangka:setVisible(true)
  437. self.ui.Items.Text_huodong_fangka_count:setText(activityCardCost .. PLN.CURRENCY_UNIT);
  438. self:refreshHuoDongFanKaView(event.propList)
  439. else
  440. self.ui.Items.Text_font_huodong_fangka:setVisible(false)
  441. end
  442. end
  443. --时间选择
  444. function ClubZhanJiView:onClickTime()
  445. playBtnEffect()
  446. self.ui.Items.Layout_btn_menu:setVisible(not self.ui.Items.Layout_btn_menu:isVisible());
  447. self.ui.Items.Layout_riqi:setVisible(not self.ui.Items.Layout_riqi:isVisible());
  448. end
  449. --点击层
  450. function ClubZhanJiView:onTouch()
  451. self.ui.Items.Layout_timeselect:setVisible(false)
  452. self.ui.Items.Layout_time_select:setVisible(false);
  453. self.ui.Items.Layout_riqi:setVisible(false);
  454. self.ui.Items.Layout_btn_menu:setVisible(false);
  455. end
  456. --设置日期
  457. function ClubZhanJiView:setDays()
  458. local timeBegin = os.time() - (self.zhanjiDay)* 24 * 3600
  459. for i = 1, self.zhanjiDay do
  460. local nTime = timeBegin + i * 24 * 3600
  461. local strDay = os.date("%Y-%m-%d", nTime)
  462. local riqi = {
  463. [1] = "前 日",
  464. [2] = "昨 日",
  465. [3] = "今 日",
  466. }
  467. local layoutBtn = string.format("Layout_Btn_%d",i)
  468. self.ui.Items[layoutBtn]:registerClick(function()
  469. playBtnEffect()
  470. self:setSelectedDay(strDay)
  471. --选中时间
  472. self.ui.Items.Text_request_time:setText(riqi[i]);
  473. self:onTouch()
  474. end)
  475. end
  476. self.ui.Items.Text_request_time:setText("今 日");
  477. end
  478. function ClubZhanJiView:showTimeLayout(idx, mon, days)
  479. if idx == 1 then
  480. --前一个月
  481. self.ui.Items.Layout_day_1:removeAllChildren();
  482. for k,v in ipairs(days) do
  483. if v ~= "" then
  484. local uiDay = self:createDay(mon, v);
  485. self.ui.Items.Layout_day_1:addChild(uiDay);
  486. end
  487. end
  488. elseif idx == 2 then
  489. --后一个月
  490. self.ui.Items.Layout_day_2:removeAllChildren();
  491. for k,v in ipairs(days) do
  492. if v ~= "" then
  493. local uiDay = self:createDay(mon, v);
  494. self.ui.Items.Layout_day_2:addChild(uiDay);
  495. end
  496. end
  497. end
  498. end
  499. function ClubZhanJiView:createDay(mon, day)
  500. --默认状态
  501. local uiCopyDay = self.ui.Items.Layout_day:getCopied()
  502. uiCopyDay.Items = getUIItems(uiCopyDay);
  503. uiCopyDay.Items.ImageView_day_selected:setVisible(false);
  504. uiCopyDay.Items.Text_day:setVisible(false);
  505. -- 当前日期对应的值
  506. uiCopyDay.value = string.format("%s-%s",mon,day)
  507. -- 设置选中状态
  508. uiCopyDay.setSelected = function(bSelected)
  509. uiCopyDay.Items.ImageView_day_selected:setVisible(bSelected);
  510. end
  511. if day and day ~= "" then
  512. uiCopyDay.Items.Text_day:setText(tostring(day));
  513. uiCopyDay.Items.Text_day:setVisible(true);
  514. uiCopyDay.Items.Layout_time_select_touch:registerClick(function ()
  515. playBtnEffect()
  516. self:setSelectedDay(uiCopyDay.value)
  517. end)
  518. end
  519. -- 默认未选中
  520. uiCopyDay.setSelected(false)
  521. --用年月日做下标
  522. self.dayTable[tostring(uiCopyDay.value)] = uiCopyDay;
  523. return uiCopyDay
  524. end
  525. function ClubZhanJiView:updateMonth()
  526. local strMonth = self.months[self.curMonthIdx]
  527. self.ui.Items.Text_select_time:setText(strMonth);
  528. end
  529. function ClubZhanJiView:onClickTimeLeft()
  530. playBtnEffect()
  531. if self.curMonthIdx <= 1 then
  532. return
  533. end
  534. self.ui.Items.Layout_day_action:playClip("move")
  535. self.curMonthIdx = self.curMonthIdx - 1
  536. self:updateMonth()
  537. end
  538. function ClubZhanJiView:onClickTimeRight()
  539. playBtnEffect()
  540. local sz = table.nums(self.months)
  541. if self.curMonthIdx >= sz then
  542. return
  543. end
  544. self.ui.Items.Layout_day_action:playClip("moveback")
  545. self.curMonthIdx = self.curMonthIdx + 1
  546. self:updateMonth()
  547. end
  548. -- 上一页
  549. function ClubZhanJiView:onClickPagePre()
  550. playBtnEffect()
  551. if self.curPage > 1 then
  552. self.curPage = self.curPage - 1
  553. end
  554. local searchCont = self.ui.Items.TextField_search:getText();
  555. if searchCont ~= "" then
  556. local isNum = tonumber(searchCont)
  557. if not isNum then
  558. self:requestUpdateList();
  559. return;
  560. end
  561. local length = string.len(searchCont)
  562. if length ~= 7 then
  563. self:requestUpdateList();
  564. return;
  565. end
  566. app.club_zhanji:getIdxlistByPlayerUid(self.clubInfo.clubId, self.curShowType, self.curDate, self.curPage,searchCont,true);
  567. else
  568. self:requestUpdateList();
  569. end
  570. end
  571. -- 下一页
  572. function ClubZhanJiView:onClickPageNext()
  573. playBtnEffect()
  574. local tpage = app.club_zhanji.tpage or 0
  575. if self.curPage < tpage then
  576. self.curPage = self.curPage + 1
  577. end
  578. local searchCont = self.ui.Items.TextField_search:getText();
  579. if searchCont ~= "" then
  580. local isNum = tonumber(searchCont)
  581. if not isNum then
  582. self:requestUpdateList();
  583. return;
  584. end
  585. local length = string.len(searchCont)
  586. if length ~= 7 then
  587. self:requestUpdateList();
  588. return;
  589. end
  590. app.club_zhanji:getIdxlistByPlayerUid(self.clubInfo.clubId, self.curShowType, self.curDate, self.curPage,searchCont,true);
  591. else
  592. self:requestUpdateList();
  593. end
  594. end
  595. --数据查询成功
  596. function ClubZhanJiView:MemberStatSuccess(event)
  597. if not event then
  598. return
  599. end
  600. local view = import("luaScript.Views.Club.ClubZhanJiShare"):new(event.memberData)
  601. view:setAnchorPoint(cc.p(0.5, 0.5))
  602. app:showWaitDialog(view)
  603. end
  604. --战绩统计查询成功
  605. function ClubZhanJiView:onGetZhanjiGroupDateListSucc()
  606. app.waitDialogManager:closeWaitNetworkDialog()
  607. local uiScrollView = self.ui.Items.ScrollView_TongJi
  608. uiScrollView:setVisible(true)
  609. uiScrollView:getInnerContainer():setAutoSize(true)
  610. uiScrollView:removeAllChildren();
  611. uiScrollView:hideAllBar();
  612. local zhanjiTongjiDataList = app.club_zhanji.zhanjiTongjiDataList[tonumber(self.clubInfo.clubId)]
  613. if not zhanjiTongjiDataList or table.nums(zhanjiTongjiDataList) <= 0 then
  614. --无数据显示
  615. self.ui.Items.Layout_no_data:setVisible(true);
  616. return
  617. else
  618. self.ui.Items.Layout_no_data:setVisible(false);
  619. end
  620. --战绩统计内容
  621. local uiTemplate = self.ui.Items.Layout_tongji_content;
  622. for k, tongjiInfo in pairsByKeysEx(zhanjiTongjiDataList) do
  623. local uiItem = uiTemplate:getCopied()
  624. local uiSize = uiItem:getSize();
  625. local realSize = {width = uiSize.width * g_radio_x,height = uiSize.height * g_radio_y}
  626. uiItem:setSize(realSize)
  627. uiItem.Items = getUIItems(uiItem)
  628. self:updateTongJiItem(uiItem,tongjiInfo)
  629. uiScrollView:addChild(uiItem)
  630. end
  631. uiScrollView:jumpToTopOnSizeChanged()
  632. end
  633. function ClubZhanJiView:updateTongJiItem(uiItem,tongjiInfo)
  634. --日期
  635. uiItem.Items.Text_data:setText(string.format("%s",tongjiInfo.create_date))
  636. --开房成局
  637. uiItem.Items.Text_chengju_count:setText(tonumber(tongjiInfo.openhouse_count))
  638. --大家赢
  639. uiItem.Items.Text_win_count:setText(tonumber(tongjiInfo.play_win_number))
  640. --馆主消耗
  641. uiItem.Items.Text_xiaohao_count:setText(tonumber(tongjiInfo.owner_card_consume_count))
  642. --馆主专属房卡/房卡消耗
  643. uiItem.Items.Text_zhuanshu_xiaohao:setText(tonumber(tongjiInfo.owner_props_card_count))
  644. uiItem.Items.Button_XianQiang:registerClick(function()
  645. local view = import("luaScript.Views.Club.ClubZhanJiTongJiView"):new(tongjiInfo.list)
  646. view:setAnchorPoint(cc.p(0.5, 0.5))
  647. app:showWaitDialog(view)
  648. end)
  649. end
  650. function ClubZhanJiView:onDeleteZhanJiResponse()
  651. self:updateZhanJiList()
  652. end
  653. return ClubZhanJiView