CashOut.ts 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. /** 常规提现界面 */
  2. import GameM, { AUDIO_TYPE, VIDEO_TYPE } from "../manager/GameM";
  3. import CashItem from "../prefabs/CashItem";
  4. import EffectNode from "./EffectNode";
  5. import UiM, { PANEL_NAME } from "../manager/UiM";
  6. import { HTTP_TYPE } from "../datas/CommonData";
  7. import Main from "../Main";
  8. import AdM from "../manager/AdM";
  9. import RedCodeNode from "./RedCodeNode";
  10. import CashRecordNode from "./CashRecordNode";
  11. import CashOutData from "../datas/CashOutData";
  12. import GuideMng from "../manager/GuideMng";
  13. import { PlayerPrefs } from "../tools/MyExtends";
  14. import LogUtil from "../utils/LogUtil";
  15. import { FightData } from "../datas/FightData";
  16. import { GameController } from "../manager/GameController";
  17. import { Utils } from "../utils/Utils";
  18. const { ccclass, property } = cc._decorator;
  19. @ccclass
  20. export default class CashOut extends cc.Component {
  21. @property(cc.Label)
  22. labRedMoney: cc.Label = null;
  23. @property(cc.Node)
  24. contentBg: cc.Node = null;
  25. @property(cc.Node)
  26. content: cc.Node = null;
  27. @property(cc.Node)
  28. cashMain: cc.Node = null;
  29. @property(cc.Label)
  30. labShowMoney: cc.Label = null;
  31. @property(cc.Node)
  32. cashPro: cc.Node = null;
  33. @property(cc.Label)
  34. labMoney: cc.Label = null;
  35. @property(cc.Label)
  36. labTime: cc.Label = null;
  37. @property(cc.Node)
  38. loadPart: cc.Node = null;
  39. @property(cc.Animation)
  40. loadAni: cc.Animation = null;
  41. @property(cc.Node)
  42. tip: cc.Node = null;
  43. @property(cc.Node)
  44. hand: cc.Node = null;
  45. //授权部分
  46. @property(cc.Node)
  47. authPart: cc.Node = null;
  48. @property(cc.Node)
  49. authBg: cc.Node = null;
  50. @property(cc.Toggle)
  51. toggle: cc.Toggle = null;
  52. @property(cc.Node)
  53. btnGoAuth: cc.Node = null;
  54. @property(cc.Node)
  55. guide2: cc.Node = null;
  56. @property(cc.Node)
  57. labRedCode: cc.Node = null
  58. @property(cc.Node)
  59. redCodePart: cc.Node = null
  60. //------红包动画部分
  61. @property(cc.Node)
  62. moneyBg: cc.Node = null;
  63. @property(cc.Node)
  64. frontNode: cc.Node = null;
  65. @property(cc.Animation)
  66. openAni: cc.Animation = null;
  67. @property(cc.Node)
  68. hongbaoTop: cc.Node = null;
  69. @property(cc.Node)
  70. hongbaoDown: cc.Node = null;
  71. @property(cc.Node)
  72. btnRedClose: cc.Node = null;
  73. @property(cc.Label)
  74. labShowRed: cc.Label = null;
  75. @property(cc.Node)
  76. moneyPart: cc.Node = null;
  77. @property(cc.Node)
  78. boxNode: cc.Node = null;
  79. @property(cc.Node)
  80. guideRect: cc.Node = null;
  81. curSelItem = null
  82. curData = null
  83. // <=0 时间上满足提现
  84. isTimeFull: number = 0
  85. videoNode = null
  86. addTotal = 0
  87. addNum = 0
  88. _n = 0
  89. _dis = 2
  90. cfg = null
  91. itemP = null
  92. //排序数组
  93. rankArr = []
  94. onLoad() {
  95. this.cashMain.height = cc.winSize.height
  96. this.cashPro.height = cc.winSize.height
  97. this.node.height = cc.winSize.height
  98. let addY = cc.winSize.height - 1334
  99. this.content.parent.height += addY
  100. this.content.parent.parent.height += addY
  101. this.contentBg.height += addY
  102. }
  103. async onEnable() {
  104. this.itemP = await Utils.loadResPromise('prefabs/CashItem')
  105. this.hasTap = false
  106. this.curData = null
  107. this.checkEnable(true)
  108. this.hand.active = false
  109. this.guideRect.active = GuideMng.Ins.CurGuideId == 14;
  110. }
  111. showGuide() {
  112. //西游
  113. //引导
  114. this.guideRect.active = GuideMng.Ins.CurGuideId == 14;
  115. console.log('GuideMng.Ins.CurGuideId ', GuideMng.Ins.CurGuideId)
  116. if (GuideMng.Ins.CurGuideId == 14) {
  117. this.scheduleOnce(() => {
  118. console.log('GuideMng.Ins.CurGuideId >>> ', GuideMng.Ins.CurGuideId)
  119. GuideMng.Ins.ResumeGuide();
  120. }, 0.6);
  121. }
  122. }
  123. onDisable() {
  124. //西游
  125. GameM.audioM.setTempEffect(true)
  126. GameController.Ins.SwitchAudio(1);
  127. //GameM.audioM.setResumeMusic()
  128. }
  129. start() {
  130. let y = this.boxNode.y
  131. let x = this.boxNode.x
  132. let delayTime = Math.random()
  133. this.scheduleOnce(() => {
  134. this.boxNode.runAction(cc.repeatForever(cc.sequence(cc.moveTo(1.5, cc.v2(x, y - 5)), cc.moveTo(1.2, cc.v2(x, y + 5)))))
  135. }, delayTime)
  136. }
  137. /** 授权返回刷新 */
  138. authBack() {
  139. this.authPart.active = false
  140. }
  141. checkEnable(first = false) {
  142. this.cfg = null
  143. if (first) {
  144. this.content.removeAllChildren()
  145. this.cfg = CashOutData.Instance.cashCft
  146. let hasCashArr = []
  147. for (var i = 0; i < this.cfg.length; i++) {
  148. let obj = CashOutData.Instance.getCashStatusByIndex(this.cfg[i].index)
  149. if (obj && obj.status == 1) {
  150. hasCashArr.push(this.cfg[i])
  151. }
  152. else {
  153. this.rankArr.push(this.cfg[i])
  154. }
  155. }
  156. this.rankArr = this.rankArr.concat(hasCashArr)
  157. this.addNum = 0
  158. this.addTotal = this.cfg.length
  159. }
  160. else {
  161. this.cfg = CashOutData.Instance.cashCft
  162. for (var i = 0; i < this.cfg.length; i++) {
  163. let item = this.content.getChildByName(this.cfg[i].index.toString())
  164. if (cc.isValid(item)) {
  165. let s = item.getComponent(CashItem)
  166. let hasGet = false
  167. let redCode = ''
  168. let amount = 0
  169. let obj = CashOutData.Instance.getCashStatusByIndex(this.cfg[i].index)
  170. if (this.cfg[i].num == 1 && obj && obj.status == 1) {
  171. hasGet = true
  172. amount = obj.amount
  173. if (obj.withdrawalCode) {
  174. redCode = obj.withdrawalCode
  175. }
  176. }
  177. s.init(this.cfg[i], hasGet, redCode, amount)
  178. }
  179. }
  180. }
  181. let realMoney = GameM.commonData.redMoney / 10000
  182. this.labRedMoney.string = `${Math.round(GameM.commonData.redMoney)} ≈ ${realMoney}元`
  183. }
  184. setRedCode(index, withdrawalCode) {
  185. let item = this.content.getChildByName(index.toString())
  186. let s = item.getComponent(CashItem)
  187. s.setRedCode(withdrawalCode)
  188. }
  189. update() {
  190. if (!this.cfg) {
  191. return
  192. }
  193. if (this.addNum < this.addTotal) {
  194. if (this._n <= this._dis) {
  195. this._n++
  196. }
  197. else {
  198. this._n = 0
  199. let item: cc.Node = cc.instantiate(this.itemP)
  200. let s = item.getComponent(CashItem)
  201. let hasGet = false
  202. let redCode = ''
  203. let amount = 0
  204. let curCfg = this.rankArr[this.addNum]
  205. let obj = CashOutData.Instance.getCashStatusByIndex(curCfg.index)
  206. item.name = curCfg.index.toString()
  207. if (curCfg.num == 1 && obj && obj.status == 1) {
  208. hasGet = true
  209. amount = obj.amount
  210. if (obj.withdrawalCode) {
  211. redCode = obj.withdrawalCode
  212. }
  213. }
  214. s.init(curCfg, hasGet, redCode, amount)
  215. this.content.addChild(item)
  216. this.addNum++
  217. //if (this.addNum == this.addTotal) {
  218. //if (this.addNum == 2) {
  219. // //西游
  220. // //引导
  221. // this.scheduleOnce(() => {
  222. // GuideMng.Ins.CheckCashGuide10();
  223. // }, 0.6);
  224. // //if(PlayerPrefs.GetInt("GGuide10", 0)!=1){
  225. // // GuideMng.Ins.ResumeGuide();
  226. // //}
  227. //}
  228. }
  229. }
  230. }
  231. clickOpenRecord() {
  232. GameM.audioM.playEffect(AUDIO_TYPE.button)
  233. UiM.Instance.onPanel(PANEL_NAME.CashRecordNode, true, () => {
  234. if (cc.isValid(UiM.Instance.cashRecordNode)) {
  235. UiM.Instance.cashRecordNode.getComponent(CashRecordNode).initType()
  236. }
  237. })
  238. }
  239. clickClose() {
  240. GameM.audioM.playEffect(AUDIO_TYPE.button)
  241. if (GameM.commonData.richbank_noSave > 0) {
  242. UiM.Instance.hallNode.getComponent(Main).BankQipaoTip.creatPacketAnim(1)
  243. GameM.commonData.richbank_noSave = 0
  244. }
  245. UiM.Instance.offPanel(PANEL_NAME.CashNode, true, () => {
  246. AdM.createInter(16);
  247. })
  248. UiM.Instance.offPanel(PANEL_NAME.SettingNode, false)
  249. if (PlayerPrefs.GetInt("GGuide14") == 1) {
  250. GuideMng.Ins.CheckDailyGuide16();
  251. }
  252. }
  253. clickHelp() {
  254. // //test
  255. // this.checkEnable()
  256. // return
  257. GameM.audioM.playEffect(AUDIO_TYPE.button)
  258. this.redCodePart.active = true
  259. }
  260. clickCloseHelp() {
  261. GameM.audioM.playEffect(AUDIO_TYPE.button)
  262. this.redCodePart.active = false
  263. }
  264. onTixian(cfg) {
  265. //提现
  266. this.curData = cfg
  267. this.showRed()
  268. GameM.commonData.getCashMoney(this.curData.index)
  269. }
  270. clickCloseTixian() {
  271. GameM.audioM.playEffect(AUDIO_TYPE.button)
  272. this.moneyPart.active = false
  273. this.moneyBg.active = false
  274. this.frontNode.active = false
  275. }
  276. clickTixian() {
  277. GameM.audioM.playEffect(AUDIO_TYPE.button)
  278. //提现
  279. GameM.httpM.sendDatas(HTTP_TYPE.cash, { 'index': this.curData.index }, CashOutData.Instance.resultCash.bind(CashOutData.Instance), CashOutData.Instance.resultCashFail.bind(CashOutData.Instance))
  280. this.loadPart.active = true
  281. this.loadAni.play('load', 0)
  282. }
  283. tiXianSuccess(showPro, tmoney) {
  284. this.scheduleOnce(() => {
  285. this.loadPart.active = false
  286. this.showCashPro(showPro, tmoney)
  287. }, 1.5)
  288. this.scheduleOnce(() => {
  289. this.checkEnable()
  290. }, 2)
  291. if (!showPro) {
  292. this.moneyPart.active = false
  293. this.moneyBg.active = false
  294. this.frontNode.active = false
  295. }
  296. }
  297. tixianFail() {
  298. this.scheduleOnce(() => {
  299. this.loadPart.active = false
  300. }, 1.5)
  301. }
  302. showCashPro(showPro, tmoney) {
  303. CashOutData.Instance.canCashIndex = -1
  304. UiM.Instance.hallNode.getComponent(Main).hideCashHand()
  305. this.labMoney.string = `¥${tmoney.toFixed(2)}`
  306. if (showPro) {
  307. UiM.Instance.openPanel(this.cashPro)
  308. }
  309. }
  310. clickCloseCashPro() {
  311. GameM.audioM.playEffect(AUDIO_TYPE.button)
  312. GameM.commonData.backShowDaily = true
  313. UiM.Instance.closePanelM()
  314. this.moneyPart.active = false
  315. this.moneyBg.active = false
  316. this.frontNode.active = false
  317. //注释裂变弹窗
  318. // UiM.Instance.onPanel(PANEL_NAME.clubGuideNode)
  319. }
  320. showAuth() {
  321. this.authPart.active = true
  322. this.authBg.position.y = -880
  323. cc.tween(this.authBg).to(0.3, { y: -457 }).start()
  324. this.guide2.active = true
  325. }
  326. clickBackBg() {
  327. cc.tween(this.authBg).to(0.3, { y: -880 }).call(() => {
  328. this.authPart.active = false
  329. }).start()
  330. this.guide2.active = false
  331. }
  332. clickToggle() {
  333. GameM.audioM.playEffect(AUDIO_TYPE.button)
  334. if (this.toggle.isChecked) {
  335. this.btnGoAuth.getChildByName('No').active = false
  336. this.btnGoAuth.getChildByName('Yes').active = true
  337. }
  338. else {
  339. this.btnGoAuth.getChildByName('No').active = true
  340. this.btnGoAuth.getChildByName('Yes').active = false
  341. }
  342. }
  343. private hasTap = false
  344. clickGoAuth() {
  345. GameM.audioM.playEffect(AUDIO_TYPE.button)
  346. if (this.toggle.isChecked) {
  347. if (!this.hasTap) {
  348. console.log('clickGoAuth')
  349. this.hasTap = true
  350. AdM.WxLogin()
  351. }
  352. }
  353. else {
  354. EffectNode.instance.PlayTip('请选择提现方式')
  355. }
  356. }
  357. clickRedCode() {
  358. GameM.audioM.playEffect(AUDIO_TYPE.button)
  359. UiM.Instance.onPanel(PANEL_NAME.RedCodeNode, false, () => {
  360. UiM.Instance.redCodeNode.getComponent(RedCodeNode).init(1)
  361. })
  362. }
  363. /** 点击复制公众号 */
  364. clickCopyOfficial() {
  365. GameM.audioM.playEffect(AUDIO_TYPE.button)
  366. AdM.setClipboard("白羊游戏社")
  367. }
  368. coolTime = false
  369. /** 点击教程 */
  370. async clickTeach() {
  371. GameM.audioM.playEffect(AUDIO_TYPE.button)
  372. if (this.coolTime) {
  373. return
  374. }
  375. this.coolTime = true
  376. GameM.commonData.teachVideoType = 1;
  377. console.log('clickTeach')
  378. let temp = await Utils.loadResPromise('prefabs/VideoNode')
  379. this.videoNode = cc.instantiate(temp)
  380. this.videoNode.getChildByName('video').on("completed", this.onCompleted, this)
  381. this.node.addChild(this.videoNode)
  382. }
  383. onCompleted() {
  384. this.videoNode.getChildByName('video').off("completed", this.onCompleted, this)
  385. this.videoNode.destroy()
  386. //西游
  387. GameM.audioM.setTempEffect(true)
  388. GameController.Ins.SwitchAudio(1)
  389. //GameM.audioM.setResumeMusic()
  390. this.coolTime = false
  391. }
  392. /** 开红包动画 */
  393. showRed() {
  394. this.moneyBg.active = true
  395. this.frontNode.active = true
  396. this.moneyPart.active = false
  397. this.hongbaoTop.setScale(0.78, 0.78)
  398. this.hongbaoDown.setScale(0.78, 0.78)
  399. this.hongbaoTop.setPosition(0, -293.5)
  400. this.hongbaoDown.setPosition(0, -178.1)
  401. this.labShowRed.string = `${this.curData.moneyshow}`
  402. this.openAni.currentClip = null
  403. cc.loader.loadRes('gift/tongbi', cc.SpriteFrame, (err, assets) => {
  404. if (err) {
  405. cc.error(err);
  406. return;
  407. }
  408. this.openAni.node.getComponent(cc.Sprite).spriteFrame = assets;
  409. })
  410. this.openAni.node.active = true
  411. }
  412. clickCloseRed() {
  413. GameM.audioM.playEffect(AUDIO_TYPE.button)
  414. this.moneyBg.active = false
  415. this.frontNode.active = false
  416. this.moneyPart.active = false
  417. }
  418. clickOpenRed() {
  419. GameM.audioM.playEffect(AUDIO_TYPE.button)
  420. this.openAni.play('openAni', 0)
  421. this.scheduleOnce(this.schedueOpen, 0.9)
  422. }
  423. schedueOpen() {
  424. this.openAni.stop()
  425. this.openAni.node.active = false
  426. let toy = 473 + (cc.winSize.height - 1334) * 0.5
  427. cc.tween(this.hongbaoTop).to(0.3, { scale: 1, position: cc.v2(0, toy) }).start()
  428. cc.tween(this.hongbaoDown).to(0.3, { scale: 1, position: cc.v2(0, -1000) }).start()
  429. this.scheduleOnce(() => {
  430. this.moneyPart.active = true
  431. }, 0.1)
  432. this.btnRedClose.active = true
  433. }
  434. Click_GuideRect() {
  435. this.guideRect.active = false;
  436. }
  437. /**战斗按钮*/
  438. Click_FightBtn() {
  439. AdM.onSendEvent('button_2', '降妖伏魔icon', 'button')
  440. GameM.audioM.playEffect(AUDIO_TYPE.button);
  441. this.hand.active = false
  442. FightData.Ins.EnterFight();
  443. }
  444. /** 显示小手 */
  445. showHand() {
  446. //注释
  447. // this.hand.active = true;
  448. }
  449. }