invite.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <div class="user-info py-10 px-20 w-full h-full overflow-auto">
  3. <div class=" w-full rounded-xl w-full p-4 bg-white mb-4">
  4. <div class=" text-lg flex items-center">
  5. 邀请链接:<span class=" text-indigo-600" id="code">{{ url }}{{ code }}</span>
  6. <el-button class=" ml-2" size="mini" @click="copy">复制</el-button>
  7. </div>
  8. </div>
  9. <div class=" w-full rounded-xl w-full overflow-hidden">
  10. <div class="p-6 bg-white form">
  11. <div class=" text-lg mb-4">已邀请用户</div>
  12. <el-table
  13. :data="tableData"
  14. style="width: 100%"
  15. height="540"
  16. >
  17. <el-table-column
  18. prop="createTime"
  19. label="时间"
  20. >
  21. </el-table-column>
  22. <el-table-column
  23. prop="userId"
  24. label="用户ID"
  25. >
  26. </el-table-column>
  27. </el-table>
  28. <div class="w-full pt-4 flex justify-center">
  29. <el-pagination
  30. background
  31. layout="prev, pager, next"
  32. :total="total"
  33. @current-change="currentChange"
  34. >
  35. </el-pagination>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. import { getInfo } from '@/api/login'
  43. import { queryRecordApi, getInviteUserListApi } from '@/api/user'
  44. import {
  45. getModelListApi,
  46. } from "@/api/chat.js"
  47. export default {
  48. data() {
  49. return {
  50. url: 'http://192.168.0.114:8088/#/home?code=',
  51. code: '',
  52. params: {
  53. pageNum: 1,
  54. pageSize: 10,
  55. startTime: null,
  56. endTime: null,
  57. modelId: null,
  58. },
  59. modelList: [],
  60. times: [],
  61. total: 0,
  62. tableData: []
  63. }
  64. },
  65. mounted() {
  66. getInfo().then(res => {
  67. console.log(res, 'getInfo')
  68. this.code = res.data.id
  69. })
  70. this.queryRecord()
  71. this.getModelList()
  72. },
  73. methods: {
  74. async copy() {
  75. try {
  76. // 获取源DOM元素
  77. const sourceElement = document.getElementById('code');
  78. // 读取文本内容
  79. const textContent = sourceElement.textContent;
  80. // let url = 'http://192.168.0.114:8088/#/home?code=' + this.code
  81. const textarea = document.createElement('textarea');
  82. textarea.value = textContent;
  83. document.body.appendChild(textarea);
  84. textarea.select();
  85. if (document.execCommand('copy')) {
  86. document.execCommand('copy');
  87. }
  88. document.body.removeChild(textarea);
  89. this.$message({
  90. message: '复制成功',
  91. type: 'success'
  92. });
  93. } catch (err) {
  94. this.$message({
  95. message: '复制失败',
  96. type: 'error'
  97. });
  98. }
  99. },
  100. reset() {
  101. this.params = {
  102. pageNum: 1,
  103. pageSize: 10,
  104. startTime: null,
  105. endTime: null,
  106. modelId: null,
  107. }
  108. this.queryRecord()
  109. },
  110. getModelList() {
  111. getModelListApi().then(res => {
  112. console.log(res, '模型列表');
  113. this.modelList = res.data
  114. })
  115. },
  116. currentChange(value) {
  117. this.params.pageNum = value
  118. this.queryRecord()
  119. },
  120. search() {
  121. if(this.times.length > 0) {
  122. this.params.startTime = this.times[0]
  123. this.params.endTime = this.times[1]
  124. } else {
  125. this.params.startTime = null
  126. this.params.endTime = null
  127. }
  128. this.queryRecord()
  129. },
  130. queryRecord() {
  131. getInviteUserListApi(this.params).then(res => {
  132. console.log(res, 'getInviteUserListApi')
  133. this.tableData = res.rows
  134. this.total = res.total
  135. })
  136. }
  137. }
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. .top {
  142. background: linear-gradient(rgba(0, 0, 0, 0) 23.28%, rgba(0, 0, 0, 0.72) 100%), url(https://cdn-az.rochat.tech/avatar/131__c9103616-e103-11ee-bef2-66a40ff97e79.png) center center / cover no-repeat;
  143. }
  144. </style>
  145. <style scoped>
  146. </style>