// JS字符串截取 . 后面/前面的 内容
function getCaption(obj) {
var index = obj.lastIndexOf("\.");
obj = obj.substring(index + 1, obj.length);
//console.log(obj);
return obj;
}
function getFirst(obj) {
var index = obj.lastIndexOf("\.");
obj = obj.substring(0, index);
//console.log(obj);
return obj;
}
// JS大小转化B KB MB GB的转化方法
function conver(limit) {
var size = "";
if (limit < 0.1 * 1024) { //如果小于0.1KB转化成B
size = limit.toFixed(2) + "B";
} else if (limit < 0.1 * 1024 * 1024) { //如果小于0.1MB转化成KB
size = (limit / 1024).toFixed(2) + "KB";
} else if (limit < 0.1 * 1024 * 1024 * 1024) { //如果小于0.1GB转化成MB
size = (limit / (1024 * 1024)).toFixed(2) + "MB";
} else { //其他转化成GB
size = (limit / (1024 * 1024 * 1024)).toFixed(2) + "GB";
}
var sizestr = size + "";
var len = sizestr.indexOf("\.");
var dec = sizestr.substr(len + 1, 2);
if (dec == "00") { //当小数点后为00时 去掉小数部分
return sizestr.substring(0, len) + sizestr.substr(len + 3, 2);
}
return sizestr;
}
// 字符串 转数组
function stringFun(string) {
if (string.indexOf(',') > -1) {
var arr = string.split(',');
arr.splice(-1,1)
return arr;
} else {
return string;
}
}
// 数组转 字符传
function ArrFun(arr) {
return arr.join(',');
}
let jobList = [{
"id": "fedbcfc66bf4448f8c5205dc529513e2",
"channel": "wap",
"image": "http://res.funyali.top/upload/shopNav/20190918/88220c26d05cc7b576a66d074f6a809e.png",
"title": "佛珠",
"sorting": 1
}, {
"id": "fedbcfc66bf4448f8c5205dc529513e3",
"channel": "wap",
"image": "http://res.funyali.top/upload/shopNav/20190918/596af4699b6e8f8139b6db2002f385c8.png",
"title": "神像",
"sorting": 2
}, {
"id": "fedbcfc66bf4448f8c5205dc529513e4",
"channel": "wap",
"image": "http://res.funyali.top/upload/shopNav/20190918/dfaca68c8cb9571f12b04711af5c97bd.png",
"title": "法器",
"sorting": 3
}, {
"id": "fedbcfc66bf4448f8c5205dc529513e5",
"channel": "wap",
"image": "http://res.funyali.top/upload/shopNav/20190918/cb045c0dee55b173610de1d5cb0fb847.png",
"title": "蜡烛",
"sorting": 4
}]
// 截取 前 几个
var jobList4 = jobList.slice(0, -1)
//截取 最后一个
var jobList1 = jobList.slice(jobList.length - 1)