DrawRedRecordItem.js 850 B

1234567891011121314151617181920212223242526272829303132333435
  1. // const DWTool = require("../utils/DWTool");
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. titltRicheText: cc.RichText,
  6. },
  7. // LIFE-CYCLE CALLBACKS:
  8. // onLoad () {},
  9. start () {
  10. },
  11. //createTime 获取红包的时间
  12. // 是 [long] 查看hb
  13. init(redData) {
  14. var date = new Date(redData.createTime);
  15. let Y = date.getFullYear() + '-';
  16. let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1 ) : date.getMonth() +1 ) + '-';
  17. let D = date.getDate() + ' ';
  18. let h = date.getHours() + ':';
  19. let m = date.getMinutes();
  20. let hb = (redData.hb / 100).toFixed(2);
  21. let string = Y+M+D+h+m + ' ' + `红包+ ${hb}`;
  22. this.titltRicheText.string = `<b><color=#613f16>${string}</c></b>`;
  23. },
  24. // update (dt) {},
  25. });