SafeDepositBox.ts 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. import BankData from "../datas/BankData";
  2. import { HTTP_TYPE } from "../datas/CommonData";
  3. import Main from "../Main";
  4. import AdM from "../manager/AdM";
  5. import GameM, { AUDIO_TYPE } from "../manager/GameM";
  6. import UiM, { PANEL_NAME } from "../manager/UiM";
  7. import MoneySaveItem from "../prefabs/MoneySaveItem";
  8. import LogUtil from "../utils/LogUtil";
  9. import { Utils } from "../utils/Utils";
  10. import EffectNode from "./EffectNode";
  11. import RedCodeNode from "./RedCodeNode";
  12. const { ccclass, property } = cc._decorator;
  13. @ccclass
  14. export default class SafeDepositBox extends cc.Component {
  15. @property(cc.Node)
  16. content: cc.Node = null
  17. @property(cc.Label)
  18. totalMoneyLabel: cc.Label = null
  19. @property(cc.Label)
  20. readyTixianLabel: cc.Label = null
  21. @property(cc.Button)
  22. readyTixianBtn: cc.Button = null
  23. @property(cc.Node)
  24. weitixianNode: cc.Node = null
  25. @property(cc.Node)
  26. tixianzhongNode: cc.Node = null
  27. @property(cc.Label)
  28. tixianzhongMoneyLabel: cc.Label = null
  29. @property(cc.Node)
  30. confirmTixianNode: cc.Node = null
  31. @property(cc.Node)
  32. saveNode: cc.Node = null
  33. @property(cc.Node)
  34. tixianTask: cc.Node = null
  35. @property(cc.RichText)
  36. loginProgress: cc.RichText = null
  37. @property(cc.RichText)
  38. playVideoProgress: cc.RichText = null
  39. @property(cc.Label)
  40. tipLogin: cc.Label = null
  41. @property(cc.Label)
  42. tipPlayVideo: cc.Label = null
  43. @property(cc.Node)
  44. safeBox: cc.Node = null
  45. @property(cc.Node)
  46. tipNode: cc.Node = null
  47. @property(cc.Node)
  48. completeNode: cc.Node = null
  49. @property(cc.Node)
  50. inCompleteNode: cc.Node = null
  51. @property(cc.Node)
  52. completeBtn: cc.Node = null
  53. @property(cc.Node)
  54. logDaysNode: cc.Node = null
  55. @property(cc.Node)
  56. videoTimesNode: cc.Node = null
  57. @property(cc.Node)
  58. saveSuccessNode: cc.Node = null
  59. @property(cc.Label)
  60. confirmMoneyLabel: cc.Label = null
  61. @property([cc.SpriteFrame])
  62. boxSfLsit: cc.SpriteFrame[] = []
  63. @property(cc.Sprite)
  64. boxSprite: cc.Sprite = null
  65. @property(cc.Node)
  66. ruleNode: cc.Node = null
  67. @property(cc.Node)
  68. boxNode: cc.Node = null
  69. @property(sp.Skeleton)
  70. openDraw: sp.Skeleton = null
  71. @property([cc.Node])
  72. taskStartNodeList: cc.Node[] = []
  73. @property(cc.Node)
  74. noPacketTip: cc.Node = null
  75. // 提现部分
  76. @property(cc.Node)
  77. tixianNode: cc.Node = null
  78. @property(cc.Label)
  79. labRedMoneyF: cc.Label = null
  80. @property(cc.Label)
  81. labMoeny: cc.Label = null
  82. @property(cc.Node)
  83. cashPro: cc.Node = null
  84. @property(cc.Node)
  85. loadPart: cc.Node = null
  86. @property(cc.Animation)
  87. spot1: cc.Animation = null
  88. @property(cc.Button)
  89. startLingquBtn: cc.Button = null
  90. @property(cc.Label)
  91. rulelabel: cc.Label = null
  92. @property([cc.SpriteFrame])
  93. spriteFrameList: cc.SpriteFrame[] = []
  94. @property(cc.Node)
  95. labRedCode: cc.Node = null
  96. addNum = 0
  97. addTotal = 0
  98. itemP = null
  99. _n = 0
  100. _dis = 5
  101. animNode: cc.Node = null
  102. private totalMoney = 0
  103. private startTixian: number = 0
  104. private data: Array<any> = null
  105. private test = false
  106. nodePos = [cc.v3(54, -63), cc.v3(313, 57), cc.v3(572, -67), cc.v3(862, -67)]
  107. private packet = [{
  108. "amount": 30,
  109. "isSaveBank": 0,
  110. "partnerTradeNo": "a",
  111. "cashType": 1
  112. }, {
  113. "amount": 500,
  114. "isSaveBank": 0,
  115. "partnerTradeNo": "a",
  116. "cashType": 1
  117. }, {
  118. "amount": 600,
  119. "isSaveBank": 0,
  120. "partnerTradeNo": "a",
  121. "cashType": 1
  122. }]
  123. // LIFE-CYCLE CALLBACKS:
  124. async onLoad() {
  125. this.itemP = await Utils.loadResPromise('prefabs/MoneySaveItem')
  126. }
  127. start() {
  128. // GameM.httpM.sendDatas(HTTP_TYPE.backIsOpenRichBank, {})
  129. if (!this.test) {
  130. GameM.httpM.sendDatas(HTTP_TYPE.bankCashRecord, null, GameM.commonData.updateBankPacket.bind(GameM.commonData))
  131. }
  132. // let isShowGuide = cc.sys.localStorage.getItem("bankGuideStep1")
  133. // if (isShowGuide == "true") {
  134. // UiM.Instance.guideNode.getComponent(Guide).bankGuideStep2()
  135. // }
  136. if (this.test) {
  137. // this.scheduleOnce(() => {
  138. // CommonData.Instance.updateBankPacket(this.packet)
  139. this.updateScrollView(this.packet)
  140. // }, 1)
  141. }
  142. BankData.Instance.getRichBankConfig(this.initView.bind(this))
  143. // BankData.Instance.getCurrentCashTaskInfo(null)
  144. }
  145. clickClose() {
  146. GameM.audioM.playEffect(AUDIO_TYPE.button)
  147. let main = UiM.Instance.hallNode.getComponent(Main)
  148. let pos1 = main.bankBtn.node.position
  149. if (cc.winSize.height > 1500) {
  150. pos1.y = pos1.y + 45
  151. }
  152. // pos1.y = pos1.y + 30
  153. // let pos2 = main..position
  154. // let pos = cc.v2(pos1.x, pos1.y + pos2.y)
  155. let parNode = this.node.getChildByName("Par")
  156. cc.tween(parNode).to(0.2, { scale: 0, position: pos1 }).call(() => {
  157. UiM.Instance.offPanel(PANEL_NAME.SafeDepositBox)
  158. }).start();
  159. // UiM.Instance.offPanel(PANEL_NAME.SafeDepositBox)
  160. }
  161. initView(showStep = false) {
  162. let money: number = GameM.commonData.richBankCashAmount
  163. if (money == null || undefined) {
  164. money = 0
  165. }
  166. this.startTixian = GameM.commonData.currentRichBankCashTaskIndex
  167. if (this.startTixian > 0) {
  168. if (this.test) {
  169. this.weitixianNode.active = false
  170. this.tixianzhongNode.active = true
  171. let config = this.getBankTaskIndex()
  172. this.tixianzhongMoneyLabel.string = (config.money * 0.01).toFixed(2) + "元"
  173. this.readyTixianLabel.node.active = false
  174. this.tixianzhongNode.getChildByName("tixianLabel").active = true
  175. this.tixianTask.active = true
  176. this.labRedCode.active = false
  177. this.saveNode.active = true
  178. this.setTaskProgress()
  179. this.boxSprite.spriteFrame = this.boxSfLsit[1]
  180. if (showStep) {
  181. this.showInfoByStep()
  182. }
  183. this.noPacketTip.getChildByName("taskLabel").active = GameM.commonData.currentRichBankCashTaskIndex > 0
  184. this.noPacketTip.getChildByName("noTaskLabel").active = !(GameM.commonData.currentRichBankCashTaskIndex > 0)
  185. } else {
  186. BankData.Instance.getCurrentCashTaskInfo(() => {
  187. this.weitixianNode.active = false
  188. this.tixianzhongNode.active = true
  189. let config = this.getBankTaskIndex()
  190. this.tixianzhongMoneyLabel.string = (config.money * 0.01).toFixed(2) + "元"
  191. this.readyTixianLabel.node.active = false
  192. this.tixianzhongNode.getChildByName("tixianLabel").active = true
  193. this.tixianTask.active = true
  194. this.labRedCode.active = false
  195. this.saveNode.active = true
  196. this.setTaskProgress()
  197. this.boxSprite.spriteFrame = this.boxSfLsit[1]
  198. if (showStep) {
  199. this.showInfoByStep()
  200. }
  201. this.noPacketTip.getChildByName("taskLabel").active = GameM.commonData.currentRichBankCashTaskIndex > 0
  202. this.noPacketTip.getChildByName("noTaskLabel").active = !(GameM.commonData.currentRichBankCashTaskIndex > 0)
  203. })
  204. }
  205. } else {
  206. this.tixianzhongNode.active = false
  207. this.weitixianNode.active = true
  208. this.readyTixianLabel.node.active = true
  209. this.totalMoneyLabel.string = (money * 0.01).toFixed(2) + "元"
  210. this.content.active = true
  211. this.tixianTask.active = false
  212. this.labRedCode.active = true
  213. this.saveNode.active = true
  214. this.completeBtn.active = false
  215. this.checkCurrentCanStartTask(money)
  216. this.boxSprite.spriteFrame = this.boxSfLsit[0]
  217. }
  218. }
  219. updateScrollView(data) {
  220. LogUtil.logV("updateScrollView", data)
  221. this.content.destroyAllChildren()
  222. if (data == null || data == undefined) {
  223. this.showNoPacket()
  224. return
  225. }
  226. if (!(data.length > 0)) {
  227. this.showNoPacket()
  228. return
  229. }
  230. this.noPacketTip.active = false
  231. this.noPacketTip.stopAllActions()
  232. this.noPacketTip.position = cc.v3(324, -10)
  233. // data.push(data[0])
  234. // data.push(data[0])
  235. // data.push(data[0])
  236. // data.push(data[0])
  237. let count = 0
  238. let startTixian = GameM.commonData.currentRichBankCashTaskIndex
  239. let showFinger: boolean = startTixian > 0
  240. for (let entry of data) {
  241. if (entry.isSaveBank != 0) {
  242. continue
  243. }
  244. count++
  245. if (count > 5) {
  246. break
  247. }
  248. let info = entry
  249. if (info == null || info == undefined) {
  250. break
  251. }
  252. let item: cc.Node = cc.instantiate(this.itemP)
  253. let s = item.getComponent(MoneySaveItem)
  254. item.parent = this.content
  255. s.init(info, showFinger, this.clickItemEvent.bind(this), count)
  256. // item.y = - item.height * 0.5*1.5 // - this.disY * this.addNum
  257. }
  258. }
  259. //将提现金额放入保险箱
  260. clickItemEvent(data, node) {
  261. GameM.audioM.playEffect(AUDIO_TYPE.button);
  262. if (GameM.commonData.currentRichBankCashTaskIndex > 0) {
  263. EffectNode.instance.PlayTip("提现后可存入")
  264. return
  265. }
  266. this.animNode = node
  267. // this.showAnim(node)
  268. if (this.test) {
  269. GameM.commonData.richBankCashAmount = GameM.commonData.richBankCashAmount + data.amount
  270. GameM.commonData.updateBankView({ "RichBankCashAmount": data.amount })
  271. // this.saveMoneySuccess(CommonData.Instance.richBankCashAmount)
  272. } else {
  273. GameM.httpM.sendDatas(HTTP_TYPE.bankUpdateCashRecord, { "partnerTradeNo": data.partnerTradeNo }, GameM.commonData.updateBankView.bind(GameM.commonData))
  274. }
  275. }
  276. saveMoneySuccess(money) {
  277. AdM.onSendEvent("Bank_01", "钱庄-点击存入", 'Bank')
  278. this.showAnim(this.animNode)
  279. this.totalMoneyLabel.string = ((money * 0.01).toFixed(2)) + "元"
  280. this.checkCurrentCanStartTask(money)
  281. }
  282. // checkItemEvent()
  283. //存入宝箱中的数据和动画处理
  284. showAnim(itemNode: cc.Node) {
  285. itemNode.stopAllActions()
  286. let startWorldPos = itemNode.parent.convertToWorldSpaceAR(itemNode.position)
  287. let startPos = this.node.convertToNodeSpaceAR(startWorldPos)
  288. let worldEndPos = this.safeBox.parent.convertToWorldSpaceAR(this.safeBox.position)
  289. itemNode.parent = this.node
  290. itemNode.position = startPos
  291. let movePos = this.node.convertToNodeSpaceAR(worldEndPos)
  292. itemNode.runAction(cc.sequence(cc.spawn(cc.moveTo(1, cc.v2(movePos)), cc.scaleTo(1, 0.4), cc.fadeTo(1, 180)), cc.callFunc(() => {
  293. GameM.audioM.playEffect(AUDIO_TYPE.saveSuccess);
  294. this.openDraw.node.active = true
  295. this.openDraw.setAnimation(0, 'animation', false)
  296. this.saveSuccessNode.runAction(cc.sequence(cc.scaleTo(0.2, 1), cc.delayTime(0.5), cc.scaleTo(0.1, 0)))
  297. if (cc.isValid(itemNode)) {
  298. itemNode.destroy()
  299. }
  300. if (this.test) {
  301. this.updateScrollView(this.packet)
  302. } else {
  303. GameM.httpM.sendDatas(HTTP_TYPE.bankCashRecord, null, GameM.commonData.updateBankPacket.bind(GameM.commonData))
  304. }
  305. })))
  306. }
  307. //点提现按钮
  308. readyTixian() {
  309. GameM.audioM.playEffect(AUDIO_TYPE.button)
  310. let configInfo = GameM.commonData.richBankConfig
  311. let richBankCashAmount = GameM.commonData.richBankCashAmount
  312. if (configInfo == null || configInfo == undefined) {
  313. return
  314. }
  315. let minConfig = this.getBankTaskIndex()
  316. let minMoney: number = minConfig.money
  317. // this.readyTixianBtn.interactable = money >= minMoney
  318. let showMoney = Math.floor(minMoney / 100) > 0 ? (minMoney / 100) + "" : (minMoney / 100).toFixed(2)
  319. if (richBankCashAmount < minMoney) {
  320. EffectNode.instance.PlayTip("存款达到" + showMoney + "元可提现哦")
  321. return
  322. }
  323. let currentConfig = this.getBankTaskIndex()
  324. // for (let entry of configInfo) {
  325. // if (entry.money <= richBankCashAmount) {
  326. // currentConfig = entry
  327. // }
  328. // }
  329. let totaldays = currentConfig.logintimes
  330. let totalVideoTimes = currentConfig.videotimes
  331. this.tipLogin.string = "1、连续登陆" + totaldays + "天"
  332. this.tipPlayVideo.string = "2、每天观看视频" + totalVideoTimes + "次"
  333. this.confirmMoneyLabel.string = Math.floor(currentConfig.money / 100) > 0 ? (currentConfig.money / 100) + "元" : (currentConfig.money / 100).toFixed(2) + "元"
  334. let y = this.boxNode.y
  335. let x = this.boxNode.x
  336. let delayTime = Math.random()
  337. this.scheduleOnce(() => {
  338. this.boxNode.runAction(cc.repeatForever(cc.sequence(cc.moveTo(1.5, cc.v2(x, y - 5)), cc.moveTo(1.2, cc.v2(x, this.node.y + 5)))))
  339. }, delayTime)
  340. this.confirmTixianNode.active = true
  341. this.saveNode.active = true
  342. this.content.active = false
  343. this.readyTixianLabel.node.active = false
  344. }
  345. //点开始任务
  346. confirmStartTixian() {
  347. GameM.audioM.playEffect(AUDIO_TYPE.button)
  348. let config = this.getBankTaskIndex()
  349. if (!config) {
  350. LogUtil.logV("SafeDepositBox", "can not confirmStartTixian")
  351. return
  352. }
  353. this.confirmTixianNode.active = false
  354. this.boxNode.stopAllActions()
  355. this.boxNode.x = 161
  356. this.boxNode.y = 0
  357. this.content.active = true
  358. if (this.test) {
  359. GameM.commonData.updateBankTask(null, config.index)
  360. } else {
  361. GameM.httpM.sendDatas(HTTP_TYPE.bankOpenCashTask, { "index": config.index }, GameM.commonData.updateBankTask.bind(GameM.commonData))
  362. }
  363. }
  364. startTixianTask() {
  365. this.startTixian = 1
  366. this.totalMoneyLabel.string = (GameM.commonData.richBankCashAmount) + "元 提现中..."
  367. this.confirmTixianNode.active = false
  368. this.saveNode.active = true
  369. this.tixianTask.active = true
  370. this.labRedCode.active = false
  371. this.content.active = true
  372. this.readyTixianLabel.node.active = false
  373. }
  374. showCompleteNode() {
  375. cc.sys.localStorage.setItem("showBankTaskSuccess", Date.now() + "")
  376. this.tipNode.active = true
  377. this.tipNode.getChildByName("tipNode").active = true
  378. this.tipNode.getChildByName("tipNode").scale = 0;
  379. //1
  380. // this.tipNode.getChildByName("tipNode").active = true
  381. this.completeNode.active = true
  382. this.inCompleteNode.active = false
  383. cc.tween(this.tipNode.getChildByName("tipNode")).to(0.3, { scale: 1 }, { easing: "backOut" }).start();
  384. }
  385. showRestartTaskNode() {
  386. cc.sys.localStorage.setItem("showBankTaskRestart", Date.now() + "")
  387. this.tipNode.active = true
  388. this.tipNode.getChildByName("tipNode").active = true
  389. this.tipNode.getChildByName("tipNode").scale = 0;
  390. this.completeNode.active = false
  391. this.inCompleteNode.active = true
  392. cc.tween(this.tipNode.getChildByName("tipNode")).to(0.3, { scale: 1 }, { easing: "backOut" }).start();
  393. AdM.onSendEvent("Bank_05", "钱庄-任务进度重置", 'Bank')
  394. }
  395. hideCompleteTipNode() {
  396. this.tipNode.active = false
  397. this.tipNode.getChildByName("tipNode").active = false
  398. }
  399. hideConfirmTixianNode() {
  400. GameM.audioM.playEffect(AUDIO_TYPE.button)
  401. this.confirmTixianNode.active = false
  402. this.saveNode.active = true
  403. this.content.active = true
  404. this.readyTixianLabel.node.active = true
  405. this.boxNode.stopAllActions()
  406. this.boxNode.x = 161
  407. this.boxNode.y = 0
  408. }
  409. //设置提现按钮状态
  410. checkCurrentCanStartTask(money) {
  411. let configInfo = GameM.commonData.richBankConfig
  412. this.readyTixianLabel.string = ""
  413. if (configInfo == null || configInfo == undefined) {
  414. // this.readyTixianBtn.interactable = false
  415. this.readyTixianBtn.node.getComponent(cc.Sprite).spriteFrame = this.spriteFrameList[0]
  416. return
  417. }
  418. let outLine = this.readyTixianBtn.node.getChildByName("btnLabel").getComponent(cc.LabelOutline)
  419. let minConfig = this.getBankTaskIndex()
  420. let minMoney: number = minConfig.money
  421. // this.readyTixianBtn.interactable = money >= minMoney
  422. let showMoney = Math.floor(minMoney / 100) > 0 ? (minMoney / 100) + "" : (minMoney / 100).toFixed(2)
  423. if (money >= minMoney) {
  424. this.readyTixianBtn.node.getComponent(cc.Sprite).spriteFrame = this.spriteFrameList[0]
  425. this.readyTixianBtn.interactable = true
  426. outLine.color = cc.color(181, 140, 59)
  427. showMoney = Math.floor(minConfig.money / 100) > 0 ? (minConfig.money / 100) + "" : (minConfig.money / 100).toFixed(2)
  428. } else {
  429. this.readyTixianBtn.node.getComponent(cc.Sprite).spriteFrame = this.spriteFrameList[1]
  430. outLine.color = cc.Color.GRAY
  431. // this.readyTixianBtn.grayMaterial
  432. }
  433. this.readyTixianBtn.node.getChildByName("btnLabel").getComponent(cc.Label).string = "提现" + showMoney + "元"
  434. }
  435. /**
  436. * 检查在哪个段位
  437. */
  438. getBankTaskIndex(): any {
  439. LogUtil.logV("getBankTaskIndex addRichBankFinishIndex:", GameM.commonData.roleData.addRichBankFinishIndex)
  440. let configInfo = GameM.commonData.richBankConfig
  441. let richBankCashAmount = GameM.commonData.richBankCashAmount
  442. let currentConfig: any = null
  443. if (configInfo == null || configInfo == undefined) {
  444. return
  445. }
  446. let curIndex = GameM.commonData.roleData.addRichBankFinishIndex
  447. if (curIndex > configInfo.length) {
  448. return configInfo[configInfo.length - 1]
  449. }
  450. for (let entry of configInfo) {
  451. if (entry.index == curIndex) {
  452. return entry
  453. }
  454. }
  455. // for (let entry of configInfo) {
  456. // if (entry.money <= richBankCashAmount) {
  457. // currentConfig = entry
  458. // }
  459. // }
  460. // return currentConfig
  461. }
  462. clickLingqu() {
  463. GameM.audioM.playEffect(AUDIO_TYPE.button)
  464. let config = this.getBankTaskIndex()
  465. if (this.test) {
  466. GameM.commonData.updateBankCash({ "CashMode": 2, "withdrawalCode": "131231" })
  467. } else {
  468. GameM.httpM.sendDatas(HTTP_TYPE.bankCash, {
  469. "index": config.index,
  470. 'appVersion': GameM.commonData.appVersion
  471. }, GameM.commonData.updateBankCash.bind(GameM.commonData), GameM.commonData.updateBankCashFail.bind(GameM.commonData))
  472. this.loadPart.active = true
  473. this.spot1.play('load', 0)
  474. }
  475. }
  476. readyLingqu() {
  477. GameM.audioM.playEffect(AUDIO_TYPE.button)
  478. let config = this.getBankTaskIndex()
  479. // this.tixianNode.active = true
  480. UiM.Instance.openPanel(this.tixianNode)
  481. this.labRedMoneyF.string = "¥ " + (config.money * 0.01).toFixed(2)
  482. this.labMoeny.string = "¥" + (config.money * 0.01).toFixed(2)
  483. }
  484. tixianSuccess(showPro) {
  485. this.loadPart.active = false
  486. if (showPro) {
  487. this.cashPro.active = true
  488. UiM.Instance.openPanel(this.cashPro)
  489. }
  490. this.initView()
  491. this.startLingquBtn.interactable = false
  492. this.startLingquBtn.node.getComponent(cc.Animation).stop()
  493. this.startLingquBtn.node.getChildByName("labGet").getComponent(cc.Label).string = "已领取"
  494. }
  495. tixianFail() {
  496. this.loadPart.active = false
  497. this.cashPro.active = false
  498. // this.initView()
  499. // this.startLingquBtn.interactable = false
  500. // this.startLingquBtn.node.getComponent(cc.Animation).stop()
  501. // this.startLingquBtn.node.getChildByName("labGet").getComponent(cc.Label).string = "已领取"
  502. }
  503. hideTixianNode() {
  504. GameM.audioM.playEffect(AUDIO_TYPE.button)
  505. UiM.Instance.closePanelM()
  506. }
  507. closeTixianNode() {
  508. GameM.audioM.playEffect(AUDIO_TYPE.button)
  509. UiM.Instance.closePanelFromHome()
  510. UiM.Instance.closePanelFromHome()
  511. }
  512. setTaskProgress() {
  513. let richBankDailyVideoTimes = GameM.commonData.richBankDailyVideoTimes
  514. let richbank_logindays = GameM.commonData.richbank_logindays
  515. let totaldays = BankData.Instance.logintimes
  516. let progress = "(" + richbank_logindays + "/" + totaldays + ")"
  517. this.loginProgress.string = "<color=#8A2F01>1.连续登录" + totaldays + "天" + progress + "</>"
  518. if (richbank_logindays < totaldays) {
  519. this.logDaysNode.getChildByName("label").active = true
  520. this.logDaysNode.getChildByName("gou").active = false
  521. } else {
  522. this.logDaysNode.getChildByName("label").active = false
  523. this.logDaysNode.getChildByName("gou").active = true
  524. }
  525. let totalVideoTimes = BankData.Instance.videotimes
  526. let timeProgress = "(" + richBankDailyVideoTimes + "/" + totalVideoTimes + ")"
  527. this.playVideoProgress.string = "<color=#8A2F01>2.每天观看视频" + totalVideoTimes + "次" + timeProgress + "</>"
  528. if (richBankDailyVideoTimes < totalVideoTimes) {//没有完成视频次数
  529. this.videoTimesNode.getChildByName("label").active = true
  530. this.videoTimesNode.getChildByName("label").getComponent(cc.Label).string = "进行中"
  531. this.videoTimesNode.getChildByName("label").color = cc.color(55, 139, 200)
  532. this.videoTimesNode.getChildByName("gou").active = false
  533. } else {
  534. if (richbank_logindays >= totaldays) {
  535. this.videoTimesNode.getChildByName("label").active = false
  536. this.videoTimesNode.getChildByName("gou").active = true
  537. } else {
  538. this.videoTimesNode.getChildByName("label").active = true
  539. this.videoTimesNode.getChildByName("label").getComponent(cc.Label).string = "今日已完成"
  540. this.videoTimesNode.getChildByName("label").color = cc.color(2, 224, 12)
  541. this.videoTimesNode.getChildByName("gou").active = false
  542. }
  543. }
  544. if (richbank_logindays >= totaldays && richBankDailyVideoTimes >= totalVideoTimes) {
  545. this.completeBtn.active = true
  546. this.tixianzhongNode.getChildByName("tixianLabel").active = false
  547. } else {
  548. this.completeBtn.active = false
  549. this.tixianzhongNode.getChildByName("tixianLabel").active = true
  550. }
  551. //提示完成任务
  552. if (richBankDailyVideoTimes >= totalVideoTimes) {
  553. // totalVid
  554. let lastDateStr = cc.sys.localStorage.getItem("showBankTaskSuccess")
  555. if (lastDateStr != null && lastDateStr != undefined) {
  556. let lastDate = new Number(lastDateStr).valueOf()
  557. if (!this.checkSameDay(lastDate)) {
  558. this.scheduleOnce(() => {
  559. this.showCompleteNode()
  560. }, 0.3)
  561. }
  562. } else {
  563. this.scheduleOnce(() => {
  564. this.showCompleteNode()
  565. }, 0.3)
  566. }
  567. }
  568. //提示任务中断
  569. if (richbank_logindays <= 1) {
  570. //任务中断的情况
  571. let showBankTaskRestart = cc.sys.localStorage.getItem("showBankTaskRestart")
  572. let same = this.checkSameDay(new Number(showBankTaskRestart).valueOf())
  573. let bankTaskStartTime = cc.sys.localStorage.getItem("bankTaskStartTime")
  574. let startTimeSame = this.checkSameDay(new Number(bankTaskStartTime).valueOf())
  575. if (!same && !startTimeSame) {
  576. this.scheduleOnce(() => {
  577. this.showRestartTaskNode()
  578. }, 0.3)
  579. }
  580. }
  581. }
  582. clickRule() {
  583. GameM.audioM.playEffect(AUDIO_TYPE.button)
  584. // if (this.lock) {
  585. // return
  586. // }
  587. this.ruleNode.active = true
  588. let config = this.getBankTaskIndex()
  589. let money = config.money
  590. let showMoney = Math.floor(money / 100) > 0 ? (money / 100) + "" : (money / 100).toFixed(2)
  591. this.rulelabel.string = "2、存入金额达到" + showMoney + "元可开启提现"
  592. }
  593. clickCloseRule() {
  594. GameM.audioM.playEffect(AUDIO_TYPE.button)
  595. this.ruleNode.active = false
  596. }
  597. /**
  598. * 当前时间和目标时间是否是同一天
  599. * @param targetTime 记录的时间戳
  600. */
  601. checkSameDay(targetTime: number): boolean {
  602. let currentDay = new Date().getDate()
  603. let lastData = new Date(targetTime).getDate()
  604. if (currentDay == lastData) {
  605. return true
  606. }
  607. return false
  608. }
  609. showInfoByStep() {
  610. let count = 0
  611. for (let entry of this.taskStartNodeList) {
  612. // entry.opacity= 0
  613. entry.scale = 0
  614. }
  615. let array = new Array<cc.Node>()
  616. for (let i = 0; i < this.taskStartNodeList.length; i++) {
  617. // array.push(this.taskStartNodeList[ i])
  618. array.push(this.taskStartNodeList[this.taskStartNodeList.length - i - 1])
  619. }
  620. this.schedule(() => {
  621. if (cc.isValid(array[count])) {
  622. // this.taskStartNodeList[count].runAction(cc.fadeIn(0.2))
  623. if (array[count].name == "contentnode" || array[count].name == "emptyNode") {
  624. array[count].scale = 1
  625. array[count].opacity = 0
  626. array[count].runAction(cc.fadeIn(1))
  627. } else {
  628. array[count].runAction(cc.sequence(cc.scaleTo(0.15, 1.2), cc.scaleTo(0.1, 1)))
  629. }
  630. }
  631. count++
  632. }, 0.2, array.length)
  633. }
  634. clickBoxShowTip() {
  635. GameM.audioM.playEffect(AUDIO_TYPE.button);
  636. let config = this.getBankTaskIndex()
  637. let money = config.money
  638. let showMoney = Math.floor(money / 100) > 0 ? (money / 100) + "" : (money / 100).toFixed(2)
  639. let str = "存款达到" + showMoney + "元可提现哦"
  640. if (GameM.commonData.currentRichBankCashTaskIndex > 0) {
  641. str = "完成任务可提现,加油哦!"
  642. }
  643. EffectNode.instance.PlayTip(str)
  644. }
  645. showNoPacket() {
  646. this.noPacketTip.getChildByName("taskLabel").active = GameM.commonData.currentRichBankCashTaskIndex > 0
  647. this.noPacketTip.getChildByName("noTaskLabel").active = !(GameM.commonData.currentRichBankCashTaskIndex > 0)
  648. this.noPacketTip.active = true
  649. let moveNode = this.noPacketTip
  650. let x = moveNode.x
  651. let y = moveNode.y
  652. moveNode.runAction(cc.repeatForever(cc.sequence(cc.moveTo(1.5, cc.v2(x, y - 5)), cc.moveTo(1.5, cc.v2(x - 5, y - 5)), cc.moveTo(1.2, cc.v2(x, y + 5)))))
  653. }
  654. clickRedCode() {
  655. GameM.audioM.playEffect(AUDIO_TYPE.button)
  656. UiM.Instance.onPanel(PANEL_NAME.RedCodeNode, false, () => {
  657. UiM.Instance.redCodeNode.getComponent(RedCodeNode).init(4)
  658. })
  659. }
  660. }