共计 1098 个字符,预计需要花费 3 分钟才能阅读完成。
// 计算字数
dealWordCount(str) {this.isChina(str);
if (this.wordCount > 245) {return true;} else {return false;}
}
// 判断是否是中文
isChina(str) {
this.wordCount = 0;
//let reg = new RegExp('[\\u4E00-\\u9FFF]+');
//reg.test(str) ? (this.wordCount += 2) : (this.wordCount += 1);
for (let i = 0; i < str.length; i++) {str.charCodeAt(i) > 255 ? (this.wordCount += 2) : (this.wordCount += 1);
}
}
res.forEach(element => {if (element.helperDesc) {element.isShowAll = this.dealWordCount(element.helperDesc || '');
element.isOpen = false;
}
});
queryLists() {if (this.isPageRefresh) return;
this.isPageRefresh = true;
let {tabId} = this.props,
{lists} = this.state,
that = this;
comApi
.queryBillHelperPic({id: tabId, pageIndex: that.pageIndex, pageSize: that.pageSize})
.then(res => {
this.isPageRefresh = false;
if (!(res && res.length > 0)) return;
this.isRefreshBottom = res.length >= 10 ? true : false;
res.forEach(element => {if (element.helperDesc) {element.isShowAll = this.dealWordCount(element.helperDesc || '');
element.isOpen = false;
}
});
res = [...lists, ...res];
this.setState({lists: res,});
console.log('helper-lists', lists, tabId, res);
})
.catch(error => {
this.isPageRefresh = false;
this.showToast({title: error.message || ` 服务器卡顿,请稍后再试 `});
});
}
正文完