SafeDepositBox.ts 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  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. mk.guide.open(5);
  403. } else {
  404. console.log("checkCurrentCanStartTask minConfig.index: money < minMoney")
  405. this.readyTixianBtn.node.getComponent(cc.Sprite).spriteFrame = this.spriteFrameList[1]
  406. outLine.color = cc.Color.GRAY
  407. }
  408. this.readyTixianBtn.node.getChildByName("btnLabel").getComponent(cc.Label).string = "提现" + showMoney + "元"
  409. }
  410. async clickLingqu() {
  411. mk.audio.playEffect('button');
  412. let config = gData.safeDepositBoxData.getBankTaskIndex()
  413. this.labMoeny.string = "¥" + (config.money * 0.01).toFixed(2)
  414. if (this.test) {
  415. this.updateBankCash(null)
  416. } else {
  417. this.loadPart.active = true
  418. this.spot1.play('load', 0);
  419. let response = await mk.http.sendData('richbank/richbankcash', {
  420. "index": config.index,
  421. 'appVersion': gData.appData.appVersion
  422. });
  423. if (response) {
  424. if (response.errcode == 0) {
  425. this.updateBankCash(response.data);
  426. }
  427. else {
  428. this.loadPart.active = false;
  429. if (response.data.count) {
  430. gData.tipPanelData.openCashFailTip(response.data.count);
  431. }
  432. else {
  433. mk.tip.pop('提现排队中,多看视频优先提现');
  434. }
  435. }
  436. }
  437. }
  438. }
  439. updateBankCash(data) {
  440. mk.console.logSingle("updateBankCash", data)
  441. let cashMoney = 0
  442. let len = gData.safeDepositBoxData.richBankConfig.length
  443. for (var i = 0; i < len; i++) {
  444. if (gData.safeDepositBoxData.richBankConfig[i].index == gData.safeDepositBoxData.currentRichBankCashTaskIndex) {
  445. cashMoney = Number((gData.safeDepositBoxData.richBankConfig[i].money * 0.01).toFixed(2))
  446. break
  447. }
  448. }
  449. gData.safeDepositBoxData.currentRichBankCashTaskIndex = 0
  450. gData.safeDepositBoxData.richbankLoginDays = 1
  451. gData.safeDepositBoxData.richBankDailyVideoTimes = 0
  452. //计算提现后,银行内剩余的
  453. let currentConfig = gData.safeDepositBoxData.getBankTaskIndex()
  454. gData.safeDepositBoxData.richBankCashAmount = gData.safeDepositBoxData.richBankCashAmount - currentConfig.money
  455. if (gData.safeDepositBoxData.richBankCashAmount < 0) {
  456. gData.safeDepositBoxData.richBankCashAmount = 0
  457. }
  458. mk.data.sendDataEvent("Bank", "银行-任务全部完成")
  459. this.tixianSuccess(true);
  460. gData.safeDepositBoxData.updateQipao();
  461. //累计成功提现次数
  462. mk.data.setTAEventUser(1, 'cash_time', 1);
  463. //累计提现金额
  464. mk.data.setTAEventUser(1, 'cash_total', cashMoney);
  465. // if (data.CashMode == 2) {
  466. // gData.redCodeData.openRedCode(cashMoney, data.withdrawalCode);
  467. // mk.data.sendDataEvent('Bank', '公众号提现-富翁银行')
  468. // }
  469. }
  470. tixianSuccess(showPro) {
  471. this.loadPart.active = false
  472. if (showPro) {
  473. this.cashPro.active = true
  474. gData.adData.checkShowFullInter(1);
  475. }
  476. this.initView()
  477. }
  478. tixianFail() {
  479. this.loadPart.active = false
  480. mk.ui.hideUI(this.cashPro);
  481. }
  482. hideTixianNode() {
  483. mk.audio.playEffect('button');
  484. mk.ui.hideUI(this.cashPro);
  485. }
  486. closeTixianNode() {
  487. mk.audio.playEffect('button');
  488. mk.ui.hideUI(this.cashPro);
  489. }
  490. setTaskProgress() {
  491. let richBankDailyVideoTimes = gData.safeDepositBoxData.richBankDailyVideoTimes
  492. let richbankLoginDays = gData.safeDepositBoxData.richbankLoginDays
  493. let currentConfig = gData.safeDepositBoxData.getBankTaskIndex()
  494. if (currentConfig == null || currentConfig == undefined) {
  495. return
  496. }
  497. let totaldays = currentConfig.loginTimes
  498. let progress = "(" + richbankLoginDays + "/" + totaldays + ")"
  499. this.labDes.string = `连续完成${totaldays}日的每日任务即可提现\n任意一日未完成将重置提现进度`;
  500. this.loginProgress.string = "<color=#a87921>1.登陆游戏</>"
  501. if (richbankLoginDays < totaldays) {
  502. this.logDaysNode.getChildByName("labelNode").active = true
  503. this.logDaysNode.getChildByName("gou").active = false
  504. } else {
  505. this.logDaysNode.getChildByName("labelNode").active = false
  506. this.logDaysNode.getChildByName("gou").active = true
  507. }
  508. let totalVideoTimes = gData.safeDepositBoxData.richBankDailyTotelVideoTimes;
  509. let timeProgress = "(" + richBankDailyVideoTimes + "/" + totalVideoTimes + ")"
  510. this.playVideoProgress.string = "<color=#a87921>2.今日观看视频" + totalVideoTimes + "次" + timeProgress + "</>"
  511. if (richBankDailyVideoTimes < totalVideoTimes) {//没有完成视频次数
  512. this.videoTimesNode.getChildByName("label").active = true
  513. this.videoTimesNode.getChildByName("label").getComponent(cc.Label).string = "进行中"
  514. this.videoTimesNode.getChildByName("label").color = cc.Color.GRAY
  515. this.videoTimesNode.getChildByName("gou").active = false
  516. } else {
  517. if (richbankLoginDays >= totaldays) {
  518. this.videoTimesNode.getChildByName("label").active = false
  519. this.videoTimesNode.getChildByName("gou").active = true
  520. } else {
  521. this.videoTimesNode.getChildByName("label").active = true
  522. this.videoTimesNode.getChildByName("label").getComponent(cc.Label).string = "今日已完成"
  523. this.videoTimesNode.getChildByName("label").color = cc.color(27, 188, 50)
  524. this.videoTimesNode.getChildByName("gou").active = false
  525. }
  526. }
  527. if (richbankLoginDays >= totaldays && richBankDailyVideoTimes >= totalVideoTimes) {
  528. this.completeBtn.active = true
  529. this.tixianzhongNode.getChildByName("tixianLabel").active = false
  530. this.tixianzhongNode.getChildByName("labPro").active = false
  531. } else {
  532. this.completeBtn.active = false
  533. this.tixianzhongNode.getChildByName("tixianLabel").active = true
  534. this.tixianzhongNode.getChildByName("labPro").active = true
  535. }
  536. this.tixianzhongNode.getChildByName("labPro").getComponent(cc.Label).string = progress
  537. this.tixianzhongNode.getChildByName("spPro").getComponent(cc.Sprite).fillRange = richbankLoginDays / totaldays
  538. //提示完成任务
  539. if (richBankDailyVideoTimes >= totalVideoTimes) {
  540. // totalVid
  541. let lastDateStr = mk.storage.getStorage("showBankTaskSuccess")
  542. if (lastDateStr != null && lastDateStr != undefined) {
  543. let lastDate = new Number(lastDateStr).valueOf()
  544. if (!this.checkSameDay(lastDate)) {
  545. this.scheduleOnce(() => {
  546. this.showCompleteNode()
  547. }, 0.3)
  548. }
  549. } else {
  550. this.scheduleOnce(() => {
  551. this.showCompleteNode()
  552. }, 0.3)
  553. }
  554. }
  555. //提示任务中断
  556. if (richbankLoginDays <= 1) {
  557. //任务中断的情况
  558. let showBankTaskRestart = mk.storage.getStorage("showBankTaskRestart")
  559. let same = this.checkSameDay(new Number(showBankTaskRestart).valueOf())
  560. let bankTaskStartTime = mk.storage.getStorage("bankTaskStartTime")
  561. let startTimeSame = this.checkSameDay(new Number(bankTaskStartTime).valueOf())
  562. if (!same && !startTimeSame) {
  563. this.scheduleOnce(() => {
  564. this.showRestartTaskNode()
  565. }, 0.3)
  566. }
  567. }
  568. }
  569. clickRule() {
  570. mk.audio.playEffect('button');
  571. // if (this.lock) {
  572. // return
  573. // }
  574. this.ruleNode.active = true
  575. let config = gData.safeDepositBoxData.getBankTaskIndex()
  576. let money = config.money
  577. let showMoney = Math.floor(money / 100) > 0 ? (money / 100) + "" : (money / 100).toFixed(2)
  578. this.rulelabel.string = "2、存入金额达到" + showMoney + "元可开启提现"
  579. }
  580. clickCloseRule() {
  581. mk.audio.playEffect('button');
  582. this.ruleNode.active = false
  583. }
  584. /**
  585. * 当前时间和目标时间是否是同一天
  586. * @param targetTime 记录的时间戳
  587. */
  588. checkSameDay(targetTime: number): boolean {
  589. let currentDay = new Date().getDate()
  590. let lastData = new Date(targetTime).getDate()
  591. if (currentDay == lastData) {
  592. return true
  593. }
  594. return false
  595. }
  596. showInfoByStep() {
  597. let count = 0
  598. for (let entry of this.taskStartNodeList) {
  599. // entry.opacity= 0
  600. entry.scale = 0
  601. }
  602. let array = new Array<cc.Node>()
  603. for (let i = 0; i < this.taskStartNodeList.length; i++) {
  604. array.push(this.taskStartNodeList[this.taskStartNodeList.length - i - 1])
  605. }
  606. this.schedule(() => {
  607. if (cc.isValid(array[count])) {
  608. if (array[count].name == "contentnode" || array[count].name == "emptyNode") {
  609. array[count].scale = 1
  610. array[count].opacity = 0
  611. array[count].runAction(cc.fadeIn(1))
  612. } else {
  613. array[count].runAction(cc.sequence(cc.scaleTo(0.15, 1.2), cc.scaleTo(0.1, 1)))
  614. }
  615. }
  616. count++
  617. }, 0.2, array.length)
  618. }
  619. clickBoxShowTip() {
  620. mk.audio.playEffect('button');
  621. let config = gData.safeDepositBoxData.getBankTaskIndex()
  622. let money = config.money
  623. let showMoney = Math.floor(money / 100) > 0 ? (money / 100) + "" : (money / 100).toFixed(2)
  624. let str = "存款达到" + showMoney + "元可提现哦"
  625. if (gData.safeDepositBoxData.currentRichBankCashTaskIndex > 0) {
  626. str = "完成任务可提现,加油哦!"
  627. }
  628. mk.tip.pop(str)
  629. }
  630. showNoPacket() {
  631. this.noPacketTip.getChildByName("taskLabel").active = gData.safeDepositBoxData.currentRichBankCashTaskIndex > 0
  632. this.noPacketTip.getChildByName("noTaskLabel").active = !(gData.safeDepositBoxData.currentRichBankCashTaskIndex > 0)
  633. this.noPacketTip.active = true
  634. let moveNode = this.noPacketTip
  635. let x = moveNode.x
  636. let y = moveNode.y
  637. 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)))))
  638. }
  639. }