SafeDepositBox.ts 29 KB

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