IDcard.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 { PopName } from "../EventName/EventName";
  8. import Sdk from "../SDK/SDK";
  9. import HTTPS, { NetPost } from "../Template/HTTPS";
  10. import PopComponet from "../Template/PopComponet";
  11. import CollectManger from "./CollectManger";
  12. import PopManger from "./PopManger";
  13. export enum IDcardType {
  14. My = 0,
  15. Firend = 1,
  16. }
  17. interface UserData {
  18. Name: string | null;
  19. Tel: string | null;
  20. Picture: string | null;
  21. CollectId: number;
  22. Collect: string;
  23. PositionLevelId: number;
  24. PositionLevelName: string;
  25. Area: string | null;
  26. Day: number;
  27. }
  28. const { ccclass, property } = cc._decorator;
  29. @ccclass
  30. export default class IDcard extends PopComponet {
  31. TitleArray = ['我的工卡', '大鹅公司']
  32. @property(cc.Label)
  33. Title: cc.Label = null
  34. @property(cc.Sprite)
  35. image: cc.Sprite = null
  36. @property(cc.Label)
  37. name1: cc.Label = null
  38. @property(cc.Label)
  39. level: cc.Label = null
  40. @property(cc.Label)
  41. succeedWork: cc.Label = null
  42. start(): void {
  43. let res = <UserData>this.Options.Data.resp
  44. //title
  45. this.Title.string = this.TitleArray[this.Options.Data.IDcardType]
  46. let UserINfo = this.node.getChildByName("Node").getChildByName("UserINfo")
  47. if (res.Name || res.Picture) {
  48. //授权了
  49. this.name1.string = res.Name
  50. UserINfo.active = false
  51. } else {
  52. UserINfo.active = true
  53. //没授权
  54. this.name1.string = '待授权'
  55. }
  56. this.level.string = res.PositionLevelName
  57. this.succeedWork.string = `累计成功上班 ${res.Day}次`
  58. if (res.Collect) {
  59. cc.assetManager.loadRemote(res.Collect, (err, res: cc.Texture2D) => {
  60. if (!err) {
  61. this.image.spriteFrame = new cc.SpriteFrame(res)
  62. }
  63. })
  64. }
  65. }
  66. click() {
  67. HTTPS.Instance.post(NetPost.GetUserCollectList, {}).then((resp) => {
  68. CollectManger.getInstance().init(resp)
  69. PopManger.getInstance().Pop(PopName.Collect)
  70. })
  71. }
  72. shouquan() {
  73. Sdk.getInstance().ShouQuan()
  74. }
  75. }