| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- cc.Class({
- extends: cc.Component,
- properties: {
- //土地id
- landId: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- //单价
- price: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- //租期
- date: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- //开始时间
- startTime: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- //结束
- endTime: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- //介绍
- describe: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- //输入节点
- inputContainer: {
- default: null,
- type: cc.Node,
- serializable: true
- },
- inputValue: {
- default: 0,
- visible: false,
- serializable: false
- },
- _landId: {
- default: 0,
- visible: false,
- serializable: false
- },
- _leaseAnimalInfoScript:null,
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {},
- // start () {
- // },
- setInfo(id, price, date, start, end, multiple, describe,leaseAnimalInfoScript) {
- this.landId.string = id + " 号";
- this._landId = id;
- this.price.string = price + " CNT";
- this.date.string = date;
- this.startTime.string = start;
- this.endTime.string = end;
- this.inputContainer.getComponent(cc.EditBox).string = multiple;
- this.inputValue = multiple;
- this.describe.string = describe;
- this._leaseAnimalInfoScript = leaseAnimalInfoScript;
- },
- inputEditValue(value, e) {
- var numberTemp = new RegExp("^[A-Za-z0-9]+$");
- let limitValue = 100;
- //动态设置一个上限
- if (numberTemp.test(value)) {
- if (Number(value) >= 1 && Number(value) <= limitValue) {
- this.inputValue = Number(value);
- } else if (Number(value) > limitValue) {
- //限制只能输入100
- this.inputValue = limitValue;
- this.inputContainer.getComponent(cc.EditBox).string = this.inputValue;
- } else {
- this.inputValue = 1;
- this.inputContainer.getComponent(cc.EditBox).string = this.inputValue;
- }
- } else {
- this.inputValue = 1;
- this.inputContainer.getComponent(cc.EditBox).string = this.inputValue;
- console.log("请输入整数的倍数", this.inputValue);
- }
- },
- onUpdateMultiple() {
- GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "修改倍数中..", 2);
- let data = { configLandId: this._landId, multiple: Number(this.inputValue) }
- GlobalD.GameData.onMultipleAnimalLand(data, (value) => {
- GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "修改倍数成功!", 1);
- //刷新倍数
- this.inputContainer.getComponent(cc.EditBox).string = value.data.leaseMultiple;
- //修改对象的倍数显示
- this._leaseAnimalInfoScript.leaseLandInfo.leaseMultiple = value.data.leaseMultiple;
- })
- },
- onclose() {
- this.node.destroy();
- }
- });
|