SafeDepositBox.ts 31 KB

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