EmployeeReferral.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
  7. import EventName from "../EventName/EventName";
  8. import Sdk from "../SDK/SDK";
  9. import HTTPS, { NetPost } from "../Template/HTTPS";
  10. import PopComponet from "../Template/PopComponet";
  11. const { ccclass, property } = cc._decorator;
  12. @ccclass
  13. export default class EmployeeReferral extends PopComponet {
  14. static RedPoint = 0
  15. start(): void {
  16. console.error(this.Options.Data);
  17. this.initCount()
  18. }
  19. initCount() {
  20. let LabelComp = this.node.getChildByName("Node").getChildByName("yanchang").getChildByName("Label").getComponent(cc.Label)
  21. let temp = 0
  22. if (EmployeeReferral.RedPoint >= 3) {
  23. temp = 3
  24. LabelComp.string = '领取奖励'
  25. } else {
  26. temp = EmployeeReferral.RedPoint
  27. LabelComp.string = '立即邀请'
  28. }
  29. let ProgressBarComp = this.getComponentInChildren(cc.ProgressBar)
  30. ProgressBarComp.progress = temp / 3
  31. ProgressBarComp.getComponentInChildren(cc.Label).string = `邀请人数${temp}/3`
  32. ///
  33. let Label = this.node.getChildByName("Node").getChildByName("image").getChildByName("Label").getComponent(cc.Label)
  34. // this.Options.Data.Reward //装扮 0未获取 1已获取
  35. // this.Options.Data.Reward1 //道具
  36. console.error(this.Options.Data);
  37. if (this.Options.Data.resp.Reward == 0) {
  38. Label.string = `1个装扮${this.Options.Data.resp.Reward1}个游戏道具`
  39. } else {
  40. Label.string = `${this.Options.Data.resp.Reward1}个游戏道具`
  41. }
  42. }
  43. yaoqing() {
  44. if (EmployeeReferral.RedPoint >= 3) {
  45. // LabelComp.string = '领取奖励'
  46. HTTPS.Instance.post(NetPost.ReceiveInvitation, {}).then((resp) => {
  47. if (resp.Code == 200) {
  48. //领取奖励 成功
  49. cc.systemEvent.emit(EventName.UpdateOnce)
  50. this.node.destroy()
  51. }
  52. })
  53. } else {
  54. // LabelComp.string = '立即邀请'
  55. Sdk.getInstance().Share()
  56. }
  57. }
  58. }