一分钟后复制

This commit is contained in:
“wanyongkang”
2022-01-24 18:02:54 +08:00
parent 71e1243c11
commit a90841d9b9

View File

@@ -180,7 +180,7 @@
:visible.sync="userinfo_fall" :visible.sync="userinfo_fall"
width="30%"> width="30%">
<el-card class="box-card"> <el-card class="box-card">
<p oncopy="return false;">电话{{user_info.UserName}}</p> <p oncopy="return false;">电话{{user_info.UserName}} &nbsp;&nbsp; <span style="color:#409EFF;cursor:pointer;" @click="copy_op(user_info.UserName)">复制</span></p>
<p>微信{{user_info.Wx}}</p> <p>微信{{user_info.Wx}}</p>
<p>QQ{{user_info.QQ}}</p> <p>QQ{{user_info.QQ}}</p>
</el-card> </el-card>
@@ -424,6 +424,31 @@ export default {
}, },
dataExport () { dataExport () {
this.$api.getDownloadFile('/course/v1/order/ExportUserConsumeStatistics', this.searchModel) this.$api.getDownloadFile('/course/v1/order/ExportUserConsumeStatistics', this.searchModel)
},
copy_op(str) {
let copy = localStorage.getItem('copy');
let now = parseInt(new Date().getTime()/1000);
let time = (now - copy);
if (time<60) {
this.$message({
message: time+'秒后再复制',
type: 'warning'
})
return false
} else {
const save = (e) => {
e.clipboardData.setData('text/plain', str)
e.preventDefault()
}
document.addEventListener('copy', save)
document.execCommand('copy')
document.removeEventListener('copy', save)
localStorage.setItem('copy', now);
this.$message({
message: '复制成功',
type: 'success'
})
}
} }
} }
} }