HrDetails.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 HTTPS, { NetPost } from "../../Template/HTTPS";
  8. import PopComponet from "../../Template/PopComponet";
  9. import NoticeManger from "../NoticeManger";
  10. const { ccclass, property } = cc._decorator;
  11. @ccclass
  12. export default class HrNotice extends PopComponet {
  13. data: {
  14. Id: number;
  15. Name: string;
  16. Picture: string;
  17. }
  18. protected start(): void {
  19. try {
  20. this.data = JSON.parse(this.Options.Data.Data)
  21. } catch (error) {
  22. }
  23. this.Loadimage()
  24. }
  25. Loadimage() {
  26. if (!this.data) {
  27. return
  28. }
  29. cc.assetManager.loadRemote(this.data.Picture, (err, res: cc.Texture2D) => {
  30. if (!err) {
  31. let image = this.node.getChildByName("Node").getChildByName("mask").getChildByName("image").getComponent(cc.Sprite)
  32. image.spriteFrame = new cc.SpriteFrame(res);
  33. }
  34. })
  35. let Label1 = this.node.getChildByName("Node").getChildByName("str1").getChildByName("Label1").getComponent(cc.Label)
  36. let str2 = this.node.getChildByName("Node").getChildByName("str2").getComponent(cc.Label)
  37. let Label2 = this.node.getChildByName("Node").getChildByName("str2").getChildByName("Label2").getComponent(cc.Label)
  38. Label1.string = `${this.data.Name}`
  39. let sss = ''
  40. if (this.Options.Data.State == 1) {
  41. //获得
  42. sss = `亲爱的同事 :
  43. 由于您昨天旷工,你的职级降级
  44. 为`
  45. } else {
  46. //失去
  47. sss = `亲爱的同事 :
  48. 由于您积极工作,你的职级升级
  49. 为`
  50. }
  51. str2.string = sss
  52. Label2.string = `[ ${this.data.Name} ]`
  53. }
  54. // update (dt) {}
  55. onDestroy(): void {
  56. NoticeManger.getInstance().Pop()
  57. HTTPS.Instance.post(NetPost.EditToBenotified,
  58. { Id: this.Options.Data.Id }).then((resp) => {
  59. })
  60. }
  61. }