ClubInviteNode.ts 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. import GameM, { AUDIO_TYPE } from "../../manager/GameM";
  2. import UiM, { PANEL_NAME } from "../../manager/UiM";
  3. import LogUtil from "../../utils/LogUtil";
  4. import ClubMain from "../ClubMain";
  5. import EffectNode from "../EffectNode";
  6. import RedCodeNode from "../RedCodeNode";
  7. import ClubInviteItem from "./ClubInviteItem";
  8. import ClubInviteItem2 from "./ClubInviteItem2";
  9. import ClubMemberUnCheck from "./ClubMemberUnCheck";
  10. import ClubTixianNode from "./ClubTixianNode";
  11. const { ccclass, property } = cc._decorator;
  12. @ccclass
  13. export default class ClubInviteNode extends cc.Component {
  14. @property(cc.RichText)
  15. gongGaoRT: cc.RichText = null;
  16. @property(cc.Node)
  17. contentNode: cc.Node = null;
  18. @property(cc.Label)
  19. totalInvite: cc.Label = null
  20. @property(cc.Label)
  21. unChecking: cc.Label = null
  22. @property(cc.Node)
  23. firstNode: cc.Node = null
  24. @property(cc.Node)
  25. gonggaoNode: cc.Node = null
  26. @property(cc.Node)
  27. zhaomuBtn: cc.Node = null
  28. @property(cc.Node)
  29. mainNode: cc.Node = null
  30. @property(cc.Node)
  31. dragArea: cc.Node = null
  32. @property(cc.Node)
  33. item1: cc.Node = null
  34. @property(cc.Node)
  35. item2: cc.Node = null
  36. @property(cc.Node)
  37. item1Click: cc.Node = null
  38. @property(cc.Node)
  39. item2Click: cc.Node = null
  40. @property(cc.Node)
  41. pageIndexNode: cc.Node = null
  42. @property(cc.Node)
  43. pageIndexShowNode: cc.Node = null
  44. @property(cc.SpriteFrame)
  45. pointSf: cc.SpriteFrame = null
  46. @property(cc.Node)
  47. content: cc.Node = null;
  48. @property(cc.Node)
  49. clubInviteItem2: cc.Node = null;
  50. // @property(cc.PageView)
  51. // @property()
  52. onLoad() {
  53. let addY = cc.winSize.height - 1334
  54. // this.zhaomuBtn.height += addY/3
  55. // this.mainNode.height += addY/3
  56. if (addY > 0) {
  57. // this.gongGaoRT.node.parent.parent.y += addY/3
  58. this.mainNode.y -= addY / 4
  59. this.zhaomuBtn.y -= addY / 3
  60. }
  61. }
  62. private gonggaoIndex = 0
  63. private gonggaoList: Array<any> = new Array<any>()
  64. private index = 0
  65. start() {
  66. this.initView()
  67. }
  68. initView() {
  69. GameM.ClubData.requestClubRecruitProgress()
  70. GameM.ClubData.requestClubRecruitBroadcast()
  71. GameM.ClubData.requestClubMyRecruitMembers()
  72. }
  73. updateGonggao(data) {
  74. if (data == null || data == undefined || data.length == 0) {
  75. this.gongGaoRT.node.parent.parent.active = false
  76. return
  77. }
  78. this.gongGaoRT.node.parent.parent.active = true
  79. this.gonggaoList = data
  80. this.gongGaoRT.node.stopAllActions()
  81. this.showGonggao()
  82. }
  83. showGonggao() {
  84. // this.gongGaoRT.string = str
  85. this.gonggaoIndex++
  86. if (this.gonggaoIndex > this.gonggaoList.length - 1) {
  87. this.gonggaoIndex = 0
  88. }
  89. let gonggaoData = this.gonggaoList[this.gonggaoIndex]
  90. let name = gonggaoData.name
  91. let peopleCount = "(" + gonggaoData.peopleCount + "/" + gonggaoData.peopleCount + ")"
  92. let amount = gonggaoData.amount / 10000 + "元"
  93. this.gongGaoRT.string = `<b><outline color=#0F00FF width=2><color=#3bf8ff>${name}</color></outline><outline color=#b57541 width=2>完成招募${peopleCount}成功提现</outline><outline color=#0F00FF width=2><color=#3bf8ff>${amount}</color></outline></b>`
  94. this.gongGaoRT.node.position = cc.v3(0, -50)
  95. this.gongGaoRT.node.runAction(cc.sequence(cc.moveTo(0.6, cc.v2(0, 0)), cc.delayTime(3.5), cc.moveTo(0.6, cc.v2(0, 50)), cc.callFunc(() => {
  96. this.showGonggao()
  97. })))
  98. }
  99. // <color=#00ff00>Rich</c><color=#0fffff>Text</color>#D75B1C
  100. updateFirstChildInfo() {
  101. if (GameM.ClubData.memberInfo == null || GameM.ClubData.memberInfo == undefined) {
  102. this.firstNode.active = false
  103. return
  104. }
  105. this.firstNode.active = true
  106. let child1List = GameM.ClubData.memberInfo.g1Members
  107. let child1Num = GameM.ClubData.memberInfo.g1Num
  108. let uncheckNum = 0
  109. for (let i = 0; i < child1List.length; i++) {
  110. if (child1List[i].validStatus == 0) {
  111. uncheckNum++
  112. }
  113. }
  114. this.totalInvite.string = child1Num + ""
  115. this.unChecking.string = uncheckNum + ""
  116. }
  117. showUncheckList() {
  118. GameM.audioM.playEffect(AUDIO_TYPE.button)
  119. if (GameM.ClubData.memberInfo == null || GameM.ClubData.memberInfo == null) {
  120. EffectNode.instance.PlayTip("当前没有徒弟")
  121. return
  122. }
  123. cc.loader.loadRes('prefabs/club/clubMemberUnCheck', cc.Prefab, (err, assets) => {
  124. if (err) {
  125. cc.error(err);
  126. return;
  127. }
  128. let node: cc.Node = cc.instantiate(assets)
  129. node.parent = UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode
  130. node.getComponent(ClubMemberUnCheck).getChildInfo()
  131. })
  132. }
  133. sharePic() {
  134. GameM.audioM.playEffect(AUDIO_TYPE.button)
  135. GameM.ClubData.inviteOtherPlayer()
  136. }
  137. private coolTime = false
  138. private curSelDownItem = null
  139. private startX = 0
  140. private preDownItem = null
  141. private progressRecord = null
  142. _n = 0
  143. _dis = 5
  144. //1.1.6优化内容
  145. updateList() {
  146. if (GameM.ClubData.clubInviteInfo == null || GameM.ClubData.clubInviteInfo == undefined) {
  147. return
  148. }
  149. // let finishCount = GameM.ClubData.clubInviteInfo.finishCount
  150. // let progressRecord = GameM.ClubData.clubInviteInfo.progressRecord
  151. this.progressRecord = GameM.ClubData.clubInviteInfo.progressRecord
  152. let count = 0
  153. console.log("------->ProgressRecord: ", this.progressRecord);
  154. this.content.removeAllChildren();
  155. for (let i = 0; i < this.progressRecord.length; i++) {
  156. let item: cc.Node = cc.instantiate(this.clubInviteItem2)
  157. item.active = true
  158. let s = item.getComponent(ClubInviteItem2)
  159. s.initItem(this.progressRecord[i], count)
  160. this.content.addChild(item)
  161. count++
  162. }
  163. //for (let entry of this.progressRecord) {
  164. // console.log("Count: " + count + " Status: " + entry.status);
  165. // if (entry.status != 1) {
  166. // // this.index = count
  167. // this.item1.getChildByName("clubInviteItem").getComponent(ClubInviteItem).initItem(entry, count)
  168. // this.index = count
  169. // console.log("---->Index: " + this.index);
  170. // // this.firstNode.parent = this.item1
  171. // break
  172. // }
  173. // count++
  174. //}
  175. //this.pageIndexNode.destroyAllChildren()
  176. //for (let i = 0; i <= this.progressRecord.length; i++) {
  177. // let node = new cc.Node()
  178. // let sprite = node.addComponent(cc.Sprite)
  179. // sprite.spriteFrame = this.pointSf
  180. // node.anchorX = 0
  181. // node.parent = this.pageIndexNode
  182. //}
  183. //this.scheduleOnce(() => {
  184. // this.showPagePosition()
  185. //}, 0)
  186. //
  187. //this.dragArea.on(cc.Node.EventType.TOUCH_START, this.onDragStart, this)
  188. //this.dragArea.on(cc.Node.EventType.TOUCH_END, this.onDragEnd, this)
  189. }
  190. updateList2() {
  191. if (GameM.ClubData.clubInviteInfo == null || GameM.ClubData.clubInviteInfo == undefined) {
  192. return
  193. }
  194. // let finishCount = GameM.ClubData.clubInviteInfo.finishCount
  195. // let progressRecord = GameM.ClubData.clubInviteInfo.progressRecord
  196. this.progressRecord = GameM.ClubData.clubInviteInfo.progressRecord
  197. let count = 0
  198. console.log("------->ProgressRecord: ", this.progressRecord);
  199. for (let entry of this.progressRecord) {
  200. console.log("Count: " + count + " Status: " + entry.status);
  201. if (entry.status != 1) {
  202. // this.index = count
  203. this.item1.getChildByName("clubInviteItem").getComponent(ClubInviteItem).initItem(entry, count)
  204. this.index = count
  205. console.log("---->Index: " + this.index);
  206. // this.firstNode.parent = this.item1
  207. break
  208. }
  209. count++
  210. }
  211. this.pageIndexNode.destroyAllChildren()
  212. for (let i = 0; i <= this.progressRecord.length; i++) {
  213. let node = new cc.Node()
  214. let sprite = node.addComponent(cc.Sprite)
  215. sprite.spriteFrame = this.pointSf
  216. node.anchorX = 0
  217. node.parent = this.pageIndexNode
  218. }
  219. this.scheduleOnce(() => {
  220. this.showPagePosition()
  221. }, 0)
  222. this.dragArea.on(cc.Node.EventType.TOUCH_START, this.onDragStart, this)
  223. this.dragArea.on(cc.Node.EventType.TOUCH_END, this.onDragEnd, this)
  224. }
  225. showPagePosition() {
  226. let childrenNode = this.pageIndexNode.children
  227. if (cc.isValid(childrenNode[this.index])) {
  228. let worldPos = this.pageIndexNode.convertToWorldSpaceAR(childrenNode[this.index].position)
  229. this.pageIndexShowNode.position = this.pageIndexShowNode.parent.convertToNodeSpaceAR(worldPos)
  230. }
  231. }
  232. onDragStart(evt) {
  233. this.startX = evt.touch._point.x
  234. }
  235. onDragEnd(evt) {
  236. console.log("evt.touch._point.x " + evt.touch._point.x)
  237. console.log("evt.touch._point.y " + evt.touch._point.y)
  238. let end = evt.touch._point.x - this.startX
  239. if (Math.abs(end) > 20) {
  240. if (end > 0) {
  241. this.onSelDown(2, true)
  242. }
  243. else {
  244. this.onSelDown(1, true)
  245. }
  246. } else {
  247. if (Math.abs(end) < 5) {
  248. this.checkClickLingqu(evt.touch._point)
  249. }
  250. }
  251. }
  252. /**
  253. * 滑动选择
  254. * @param state 1 向左 2 向右
  255. */
  256. onSelDown(state, slide = false) {
  257. if (this.coolTime) {
  258. return
  259. }
  260. if (this.progressRecord == null || this.progressRecord.length == 0) {
  261. return
  262. }
  263. let preTo = -750
  264. let data = null
  265. if (state == 1) {
  266. if (this.index >= this.progressRecord.length - 1) {
  267. // if (slide) {
  268. // EffectNode.instance.PlayTip('已到最后一项')
  269. // }
  270. // return
  271. data = this.progressRecord[0]
  272. this.index = 0
  273. } else {
  274. data = this.progressRecord[this.index + 1]
  275. this.index++
  276. }
  277. if (this.curSelDownItem == this.item1) {
  278. this.curSelDownItem = this.item2
  279. this.preDownItem = this.item1
  280. }
  281. else {
  282. this.curSelDownItem = this.item1
  283. this.preDownItem = this.item2
  284. }
  285. this.curSelDownItem.getChildByName("clubInviteItem").getComponent(ClubInviteItem).initItem(data, this.index)
  286. this.curSelDownItem.x = 750
  287. preTo = -750
  288. }
  289. else if (state == 2) {
  290. if (this.index <= 0) {
  291. // if (slide) {
  292. // EffectNode.instance.PlayTip('已到第一项')
  293. // }
  294. // return
  295. data = this.progressRecord[this.progressRecord.length - 1]
  296. this.index = this.progressRecord.length - 1
  297. } else {
  298. data = this.progressRecord[this.index - 1]
  299. this.index--
  300. }
  301. if (this.curSelDownItem == this.item1) {
  302. this.curSelDownItem = this.item2
  303. this.preDownItem = this.item1
  304. }
  305. else {
  306. this.curSelDownItem = this.item1
  307. this.preDownItem = this.item2
  308. }
  309. this.curSelDownItem.getChildByName("clubInviteItem").getComponent(ClubInviteItem).initItem(data, this.index)
  310. this.curSelDownItem.x = -750
  311. preTo = 750
  312. }
  313. this.coolTime = true
  314. cc.tween(this.preDownItem).to(0.3, { x: preTo }, cc.easeInOut(1)).start()
  315. cc.tween(this.curSelDownItem).to(0.3, { x: 0 }, cc.easeInOut(1)).call(() => {
  316. this.coolTime = false
  317. this.showPagePosition()
  318. }).start()
  319. }
  320. onLeft() {
  321. GameM.audioM.playEffect(AUDIO_TYPE.button)
  322. this.onSelDown(2)
  323. }
  324. onRight() {
  325. GameM.audioM.playEffect(AUDIO_TYPE.button)
  326. this.onSelDown(1)
  327. }
  328. checkClickLingqu(pos: cc.Vec2) {
  329. if (this.item1Click.getBoundingBoxToWorld().contains(pos)) {
  330. this.clicktixian()
  331. return
  332. }
  333. if (this.item2Click.getBoundingBoxToWorld().contains(pos)) {
  334. this.clicktixian()
  335. return
  336. }
  337. if (this.firstNode.getBoundingBoxToWorld().contains(pos)) {
  338. this.showUncheckList()
  339. return
  340. }
  341. }
  342. clicktixian() {
  343. // to do
  344. LogUtil.logV('club>> clicktixian this.index', this.index)
  345. let curData = this.progressRecord[this.index]
  346. LogUtil.logV('club>> clicktixian curData', curData)
  347. if (GameM.ClubData.clubInviteInfo.finishCount < curData.peopleNum) {
  348. EffectNode.instance.PlayTip("招募人数不足")
  349. return
  350. }
  351. if (curData.status != 0) {
  352. this.clickRedCode()
  353. return
  354. }
  355. // GameM.ClubData.requestClubDoWithdraw(GameM.commonData.version,3+"", this.data.peopleNum, (this.data.rewardAmount)/10000)
  356. GameM.audioM.playEffect(AUDIO_TYPE.button)
  357. this.readyToLingqu(3 + "", (curData.rewardAmount / 10000), curData.peopleNum)
  358. }
  359. readyToLingqu(type, money, peopleNum) {
  360. GameM.audioM.playEffect(AUDIO_TYPE.button)
  361. // this.tixianNode.active = true
  362. cc.loader.loadRes('prefabs/club/ClubTixianNode', cc.Prefab, (err, assets) => {
  363. if (err) {
  364. cc.error(err);
  365. return;
  366. }
  367. let node: cc.Node = cc.instantiate(assets)
  368. node.parent = UiM.Instance.clubMainNode.getComponent(ClubMain).alertNode
  369. UiM.Instance.openPanel(node)
  370. node.getComponent(ClubTixianNode).initView(type, money, peopleNum, this.index)
  371. })
  372. }
  373. clickRedCode() {
  374. GameM.audioM.playEffect(AUDIO_TYPE.button)
  375. UiM.Instance.onPanel(PANEL_NAME.RedCodeNode, false, () => {
  376. UiM.Instance.redCodeNode.getComponent(RedCodeNode).init(50)
  377. })
  378. }
  379. }