You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.8 KiB
69 lines
1.8 KiB
"use strict";
|
|
Component({
|
|
properties: {
|
|
gridname: {
|
|
type: String,
|
|
value: "",
|
|
},
|
|
},
|
|
data: {
|
|
showText: "",
|
|
},
|
|
observers: {
|
|
gridname: function (val) {
|
|
this.computeShowText();
|
|
},
|
|
},
|
|
lifetimes: {
|
|
ready: function () {
|
|
this.init();
|
|
},
|
|
},
|
|
methods: {
|
|
init: function () {
|
|
},
|
|
computeShowText: function () {
|
|
var gridname = this.data.gridname;
|
|
var arr = gridname.split('-');
|
|
var temp = "";
|
|
for (var i = 0; i < arr.length; i++) {
|
|
if (i == (arr.length - 1)) {
|
|
temp += this.substr(i, arr[i]);
|
|
}
|
|
else {
|
|
temp = temp + this.substr(i, arr[i]) + "-";
|
|
}
|
|
}
|
|
this.setData({ showText: temp });
|
|
},
|
|
substr: function (index, str) {
|
|
console.log(index, str);
|
|
var temp = "";
|
|
if (index == 0) {
|
|
if (str.length > 3) {
|
|
temp = str.substring(0, 3) + '...';
|
|
}
|
|
else {
|
|
temp = str;
|
|
}
|
|
}
|
|
else if (index == 1) {
|
|
if (str.length > 5) {
|
|
temp = str.substring(0, 3) + '...' + str.substring(str.length - 2);
|
|
}
|
|
else {
|
|
temp = str;
|
|
}
|
|
}
|
|
else if (index == 2) {
|
|
if (str.length > 5) {
|
|
temp = str.substring(0, 2) + '...' + str.substring(str.length - 3);
|
|
}
|
|
else {
|
|
temp = str;
|
|
}
|
|
}
|
|
return temp;
|
|
}
|
|
},
|
|
});
|
|
|