复制按钮调用copyMes,handleText处理复制出去的信息格式
javascript
//处理待复制文本
handleText = (item) => {
let bankOfDeposit = "",
bankAccount = "",
companyAddress = "",
companyTelephone = "",
taxNumber = "",
titleName = "";
if (item) {
titleName = item?.titleName;
taxNumber = item?.taxNumber;
companyAddress = item?.companyAddress;
companyTelephone = item?.companyTelephone;
bankOfDeposit = item?.bankOfDeposit;
bankAccount = item?.bankAccount;
}
let results =
"名称:" +
titleName +
`\n` +
"纳税人识别号:" +
taxNumber +
`\n` +
"地址:" +
companyAddress +
`\n` +
"电话:" +
companyTelephone +
`\n` +
"开户行:" +
bankOfDeposit +
`\n` +
"账号:" +
bankAccount;
return results;
};
copyMes = () => {
const { invoiceTemplates } = this.props;
Taro.setClipboardData({
data: this.handleText(invoiceTemplates),
success: function () {
Taro.getClipboardData({
success: () => {
Taro.showToast({
title: "复制成功",
});
},
});
},
});
};