VillageReceivesSNBView.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. snbDaysLabel: {
  5. default: null,
  6. type: cc.Label,
  7. serializable: true,
  8. },
  9. receivesSnbLabel: {
  10. default: null,
  11. type: cc.Label,
  12. serializable: true,
  13. },
  14. snbProgressBar: {
  15. default: null,
  16. type: cc.ProgressBar,
  17. serializable: true,
  18. }
  19. },
  20. // LIFE-CYCLE CALLBACKS:
  21. // onLoad () {},
  22. start() {
  23. },
  24. //设置领取snb信息
  25. /**
  26. * beginTime: "2022-03-01 00:00:00"
  27. id: 163
  28. receivedDay: 0
  29. receivedQuantity: 0
  30. status: 1
  31. totalDay: 100
  32. totalQuantity: 155570
  33. unitQuantity: 1555.7
  34. userId: "4"
  35. * @param {*} data
  36. */
  37. setVillageReceivesSnbInfo(data) {
  38. // this.snbDaysLabel.string = data.receivedDay + '/' + data.totalDay;
  39. this.snbDaysLabel.string = data.receivedQuantity + '/' + data.totalQuantity;
  40. if(0 != data.totalDay){
  41. this.receivesSnbLabel.string = 'x' + data.totalQuantity/data.totalDay;
  42. }
  43. if (0 != data.totalQuantity) {
  44. // this.snbProgressBar.progress = data.receivedDay / data.totalDay;
  45. this.snbProgressBar.progress = data.receivedQuantity / data.totalQuantity;
  46. }
  47. },
  48. //获取一个收入
  49. onGetReceivesSnbEvent() {
  50. GlobalD.GameData.onReceiveCntToSnb((value) => {
  51. //领取一个收入状态
  52. // todo 后面完善提示
  53. GlobalD.GameData.showToast(cc.find('Canvas/UICamera'), value.msg, 1);
  54. //重新获取一下snb,会自动更新到面板
  55. GlobalD.GameData.onGetUserSnb()
  56. GlobalD.GameData.onGetCntToSnb((value) => {
  57. console.log("当前用户转换的snb", value);
  58. if (value.data != null) {
  59. this.setVillageReceivesSnbInfo(value.data);
  60. }
  61. })
  62. });
  63. }
  64. // update (dt) {},
  65. });