LandAnimalTextInfo.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. //土地id
  5. landId: {
  6. default: null,
  7. type: cc.Label,
  8. serializable: true,
  9. },
  10. //单价
  11. price: {
  12. default: null,
  13. type: cc.Label,
  14. serializable: true,
  15. },
  16. //租期
  17. date: {
  18. default: null,
  19. type: cc.Label,
  20. serializable: true,
  21. },
  22. //开始时间
  23. startTime: {
  24. default: null,
  25. type: cc.Label,
  26. serializable: true,
  27. },
  28. //结束
  29. endTime: {
  30. default: null,
  31. type: cc.Label,
  32. serializable: true,
  33. },
  34. //介绍
  35. describe: {
  36. default: null,
  37. type: cc.Label,
  38. serializable: true,
  39. },
  40. //输入节点
  41. inputContainer: {
  42. default: null,
  43. type: cc.Node,
  44. serializable: true
  45. },
  46. inputValue: {
  47. default: 0,
  48. visible: false,
  49. serializable: false
  50. },
  51. _landId: {
  52. default: 0,
  53. visible: false,
  54. serializable: false
  55. },
  56. _leaseAnimalInfoScript:null,
  57. },
  58. // LIFE-CYCLE CALLBACKS:
  59. // onLoad () {},
  60. // start () {
  61. // },
  62. setInfo(id, price, date, start, end, multiple, describe,leaseAnimalInfoScript) {
  63. this.landId.string = id + " 号";
  64. this._landId = id;
  65. this.price.string = price + " CNT";
  66. this.date.string = date;
  67. this.startTime.string = start;
  68. this.endTime.string = end;
  69. this.inputContainer.getComponent(cc.EditBox).string = multiple;
  70. this.inputValue = multiple;
  71. this.describe.string = describe;
  72. this._leaseAnimalInfoScript = leaseAnimalInfoScript;
  73. },
  74. inputEditValue(value, e) {
  75. var numberTemp = new RegExp("^[A-Za-z0-9]+$");
  76. let limitValue = 100;
  77. //动态设置一个上限
  78. if (numberTemp.test(value)) {
  79. if (Number(value) >= 1 && Number(value) <= limitValue) {
  80. this.inputValue = Number(value);
  81. } else if (Number(value) > limitValue) {
  82. //限制只能输入100
  83. this.inputValue = limitValue;
  84. this.inputContainer.getComponent(cc.EditBox).string = this.inputValue;
  85. } else {
  86. this.inputValue = 1;
  87. this.inputContainer.getComponent(cc.EditBox).string = this.inputValue;
  88. }
  89. } else {
  90. this.inputValue = 1;
  91. this.inputContainer.getComponent(cc.EditBox).string = this.inputValue;
  92. console.log("请输入整数的倍数", this.inputValue);
  93. }
  94. },
  95. onUpdateMultiple() {
  96. GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "修改倍数中..", 2);
  97. let data = { configLandId: this._landId, multiple: Number(this.inputValue) }
  98. GlobalD.GameData.onMultipleAnimalLand(data, (value) => {
  99. GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "修改倍数成功!", 1);
  100. //刷新倍数
  101. this.inputContainer.getComponent(cc.EditBox).string = value.data.leaseMultiple;
  102. //修改对象的倍数显示
  103. this._leaseAnimalInfoScript.leaseLandInfo.leaseMultiple = value.data.leaseMultiple;
  104. })
  105. },
  106. onclose() {
  107. this.node.destroy();
  108. }
  109. });