You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.vue 8.4 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <div class="ui container">
  3. <div class="title">
  4. <div class="title-1"><span>{{ $t('user.inviteFriends') }}</span></div>
  5. <div class="title-2"><span>{{ $t('user.inviteFriendsTips') }}</span></div>
  6. </div>
  7. <div class="content-1">
  8. <div class="img-c">
  9. <img class="img" :src="bannerImg" />
  10. <div class="txt">{{ bannerTitle }}</div>
  11. </div>
  12. <div class="descr">
  13. <span>{{ pageLinkDesc }}</span>
  14. <a :href="pageLink" target="_blank">{{ $t('user.clickToViewTheEventDetails') }}</a>
  15. </div>
  16. </div>
  17. <div class="content-2">
  18. <div class="txt-c">
  19. <div class="txt-1">
  20. <span>{{ pageOpeniDesc }}</span>
  21. </div>
  22. <div class="txt-2"><span>{{ invitationLink + invitationCode }}</span></div>
  23. <div class="txt-3"><span>{{ $t('user.recommender') }}</span><span>{{ invitationCode }}</span></div>
  24. <el-button class="__copy_link_btn__" type="primary">{{ $t('user.copyRegistrationInvitationLink') }}</el-button>
  25. </div>
  26. <div class="qr-code">
  27. <div id="__qr-code__" style="width:120px;height:120px;"></div>
  28. </div>
  29. </div>
  30. <div class="table-container">
  31. <div>
  32. <el-table border :data="tableData" style="width:100%" v-loading="loading" stripe>
  33. <el-table-column prop="ID" :label="$t('user.invitedFriends')" align="left" header-align="center">
  34. <template slot-scope="scope">
  35. <div style="display:flex;align-items:center;padding-left:20px;">
  36. <img :src="scope.row.avatarSrc" alt="" style="height:45px;width:45px;margin-right:10px;" />
  37. <a :href="scope.row.userLink" style="font-weight:500;font-size:15px;">{{ scope.row.userName }}</a>
  38. </div>
  39. </template>
  40. </el-table-column>
  41. <el-table-column prop="statusStr" :label="$t('status')" align="center" header-align="center">
  42. <template slot-scope="scope">
  43. <span :style="{ color: scope.row.statusColor }">{{ scope.row.statusStr }}</span>
  44. </template>
  45. </el-table-column>
  46. <el-table-column prop="regTime" :label="$t('user.registrationTime')" align="center" header-align="center">
  47. </el-table-column>
  48. <template slot="empty">
  49. <span style="font-size: 12px">{{
  50. loading ? $t('loading') : $t('noData')
  51. }}</span>
  52. </template>
  53. </el-table>
  54. </div>
  55. <div class="__r_p_pagination">
  56. <div style="margin-top: 2rem">
  57. <div class="center">
  58. <el-pagination background @current-change="currentChange" :current-page="pageInfo.curpage"
  59. :page-sizes="pageInfo.pageSizes" :page-size="pageInfo.pageSize"
  60. layout="total, sizes, prev, pager, next, jumper" :total="pageInfo.total">
  61. </el-pagination>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import Clipboard from 'clipboard';
  70. import QRCode from 'qrcodejs2';
  71. import { formatDate } from 'element-ui/lib/utils/date-util';
  72. import { getUserInvitationCode } from '~/apis/modules/userinvite';
  73. export default {
  74. data() {
  75. return {
  76. bannerImg: '',
  77. bannerTitle: '',
  78. pageLink: '',
  79. pageLinkDesc: '',
  80. invitationLink: window.origin + '/user/sign_up?sharedUser=',
  81. invitationCode: '',
  82. pageOpeniDesc: '',
  83. loading: false,
  84. tableData: [],
  85. pageInfo: {
  86. curpage: 1,
  87. pageSize: 10,
  88. pageSizes: [10],
  89. total: 0,
  90. },
  91. };
  92. },
  93. components: {},
  94. methods: {
  95. initCopy() {
  96. const clipboard = new Clipboard('.__copy_link_btn__', {
  97. text: () => {
  98. return this.invitationLink + this.invitationCode;
  99. },
  100. });
  101. clipboard.on('success', (e) => {
  102. this.$message({
  103. type: 'success',
  104. message: this.$t('user.theSharedContentHasBeenCopiedToTheClipboard')
  105. });
  106. });
  107. clipboard.on('error', (e) => {
  108. this.$message({
  109. type: 'error',
  110. message: this.$t('user.copyError')
  111. });
  112. });
  113. },
  114. transRowData(item) {
  115. return {
  116. userName: item.Name,
  117. avatarSrc: item.Avatar,
  118. userLink: window.origin + '/' + item.Name,
  119. statusStr: item.IsActive ? this.$t('user.Activated') : this.$t('user.notActive'),
  120. statusColor: item.IsActive ? 'rgb(82, 196, 26)' : 'rgb(245, 34, 45)',
  121. regTime: formatDate(new Date(item.CreatedUnix * 1000), 'yyyy-MM-dd HH:mm:ss'),
  122. }
  123. },
  124. initData() {
  125. getUserInvitationCode({ page: this.pageInfo.curpage, pageSize: this.pageInfo.pageSize }).then(res => {
  126. res = res.data;
  127. if (res) {
  128. this.bannerImg = res.page_banner_img;
  129. this.bannerTitle = res.page_banner_title;
  130. this.pageLink = res.page_link;
  131. this.pageLinkDesc = res.page_link_desc;
  132. this.invitationCode = res.invitation_code;
  133. this.pageOpeniDesc = res.page_openi_desc;
  134. this.tableData = (res.invitation_users || []).map((item, index) => {
  135. return this.transRowData(item);
  136. });
  137. this.pageInfo.total = res.invitation_users_count;
  138. const qrCode = new QRCode("__qr-code__", {
  139. text: this.invitationLink + this.invitationCode,
  140. width: 120,
  141. height: 120,
  142. colorDark: '#000000',
  143. colorLight: '#ffffff',
  144. correctLevel: QRCode.CorrectLevel.H
  145. });
  146. }
  147. }).catch(err => {
  148. console.log(err);
  149. });
  150. },
  151. getTableData() {
  152. const params = {
  153. page: this.pageInfo.curpage,
  154. pageSize: this.pageInfo.pageSize,
  155. };
  156. this.loading = true;
  157. getUserInvitationCode(params).then(res => {
  158. this.loading = false;
  159. res = res.data;
  160. const data = (res.invitation_users || []).map((item, index) => {
  161. return this.transRowData(item);
  162. });
  163. this.tableData = data;
  164. this.pageInfo.total = res.invitation_users_count;
  165. }).catch(err => {
  166. console.log(err);
  167. this.loading = false;
  168. });
  169. },
  170. currentChange(val) {
  171. this.pageInfo.curpage = val;
  172. this.getTableData();
  173. },
  174. },
  175. mounted() {
  176. // this.getTableData();
  177. this.initData();
  178. this.initCopy();
  179. },
  180. beforeDestroy() {
  181. },
  182. };
  183. </script>
  184. <style scoped lang="less">
  185. .title {
  186. margin-top: 15px;
  187. margin-bottom: 15px;
  188. .title-1 {
  189. font-weight: 500;
  190. font-size: 20px;
  191. color: rgba(16, 16, 16, 1);
  192. margin-bottom: 10px;
  193. }
  194. .title-2 {
  195. font-weight: 400;
  196. font-size: 14px;
  197. color: rgba(136, 136, 136, 1);
  198. }
  199. }
  200. .content-1 {
  201. margin-bottom: 32px;
  202. .img-c {
  203. height: 80px;
  204. position: relative;
  205. .img {
  206. width: 100%;
  207. height: 100%;
  208. }
  209. .txt {
  210. position: absolute;
  211. width: 100%;
  212. height: 100%;
  213. left: 0;
  214. top: 0;
  215. line-height: 80px;
  216. padding-left: 25px;
  217. font-weight: 500;
  218. font-size: 24px;
  219. color: rgb(255, 255, 255);
  220. }
  221. }
  222. .descr {
  223. font-weight: 300;
  224. font-size: 16px;
  225. color: rgb(16, 16, 16);
  226. padding: 25px;
  227. border-left: 1px solid rgba(0, 0, 0, 0.1);
  228. border-right: 1px solid rgba(0, 0, 0, 0.1);
  229. border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  230. border-radius: 0px 0px 4px 4px;
  231. }
  232. }
  233. .content-2 {
  234. display: flex;
  235. background-color: rgb(228, 242, 255);
  236. border-color: rgb(228, 242, 255);
  237. border-width: 1px;
  238. border-style: solid;
  239. border-radius: 5px;
  240. padding: 25px;
  241. margin-bottom: 32px;
  242. .txt-c {
  243. flex: 1;
  244. font-weight: 300;
  245. font-size: 16px;
  246. color: rgb(16, 16, 16);
  247. span {
  248. line-height: 24px;
  249. }
  250. div {
  251. margin-bottom: 6px;
  252. }
  253. .txt-3 {
  254. margin-bottom: 15px;
  255. }
  256. }
  257. .qr-code {
  258. width: 150px;
  259. display: flex;
  260. flex-direction: column;
  261. align-items: end;
  262. }
  263. }
  264. .table-container {
  265. margin-bottom: 16px;
  266. /deep/ .el-table__header {
  267. th {
  268. background: rgb(245, 245, 246);
  269. font-size: 12px;
  270. color: rgb(36, 36, 36);
  271. }
  272. }
  273. /deep/ .el-table__body {
  274. td {
  275. font-size: 12px;
  276. }
  277. }
  278. .op-btn {
  279. cursor: pointer;
  280. font-size: 12px;
  281. color: rgb(25, 103, 252);
  282. margin: 0 5px;
  283. }
  284. }
  285. .center {
  286. display: flex;
  287. justify-content: center;
  288. }
  289. </style>