SafeDepositBox.ts 28 KB

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