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.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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>{{ $t('user.registrationAdress') }}</span><span>{{ invitationLink + invitationCode
  23. }}</span></div>
  24. <div class="txt-3"><span>{{ $t('user.recommender') }}</span><span>{{ invitationCode }}</span></div>
  25. <el-button class="__copy_link_btn__" type="primary">{{ $t('user.copyRegistrationInvitationLink') }}</el-button>
  26. </div>
  27. <div class="qr-code">
  28. <div id="__qr-code__" style="width:120px;height:120px;"></div>
  29. </div>
  30. </div>
  31. <div class="table-container">
  32. <div>
  33. <el-table border :data="tableData" style="width:100%" v-loading="loading" stripe>
  34. <el-table-column prop="ID" :label="$t('user.invitedFriends')" align="left" header-align="center">
  35. <template slot-scope="scope">
  36. <div style="display:flex;align-items:center;padding-left:20px;">
  37. <img :src="scope.row.avatarSrc" alt="" style="height:45px;width:45px;margin-right:10px;" />
  38. <a :href="scope.row.userLink" style="font-weight:500;font-size:15px;">{{ scope.row.userName }}</a>
  39. </div>
  40. </template>
  41. </el-table-column>
  42. <el-table-column prop="statusStr" :label="$t('status')" align="center" header-align="center">
  43. <template slot-scope="scope">
  44. <span :style="{ color: scope.row.statusColor }">{{ scope.row.statusStr }}</span>
  45. </template>
  46. </el-table-column>
  47. <el-table-column prop="regTime" :label="$t('user.registrationTime')" align="center" header-align="center">
  48. </el-table-column>
  49. <template slot="empty">
  50. <span>{{
  51. loading ? $t('loading') : $t('noData')
  52. }}</span>
  53. </template>
  54. </el-table>
  55. </div>
  56. <div class="__r_p_pagination">
  57. <div style="margin-top: 2rem">
  58. <div class="center">
  59. <el-pagination background @current-change="currentChange" :current-page="pageInfo.curpage"
  60. :page-sizes="pageInfo.pageSizes" :page-size="pageInfo.pageSize"
  61. layout="total, sizes, prev, pager, next, jumper" :total="pageInfo.total">
  62. </el-pagination>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </template>
  69. <script>
  70. import Clipboard from 'clipboard';
  71. import QRCode from 'qrcodejs2';
  72. import { formatDate } from 'element-ui/lib/utils/date-util';
  73. import { getUserInvitationCode } from '~/apis/modules/userinvite';
  74. export default {
  75. data() {
  76. return {
  77. bannerImg: '',
  78. bannerTitle: '',
  79. pageLink: '',
  80. pageLinkDesc: '',
  81. invitationLink: window.origin + '/user/sign_up?sharedUser=',
  82. invitationCode: '',
  83. pageOpeniDesc: '',
  84. loading: false,
  85. tableData: [],
  86. pageInfo: {
  87. curpage: 1,
  88. pageSize: 10,
  89. pageSizes: [10],
  90. total: 0,
  91. },
  92. };
  93. },
  94. components: {},
  95. methods: {
  96. initCopy() {
  97. const clipboard = new Clipboard('.__copy_link_btn__', {
  98. text: () => {
  99. return `${this.pageOpeniDesc}\n${this.$t('user.registrationAdress')}${this.invitationLink + this.invitationCode}\n${this.$t('user.recommender')}${this.invitationCode}`;
  100. },
  101. });
  102. clipboard.on('success', (e) => {
  103. this.$message({
  104. type: 'success',
  105. message: this.$t('user.theSharedContentHasBeenCopiedToTheClipboard')
  106. });
  107. });
  108. clipboard.on('error', (e) => {
  109. this.$message({
  110. type: 'error',
  111. message: this.$t('user.copyError')
  112. });
  113. });
  114. },
  115. transRowData(item) {
  116. return {
  117. userName: item.Name,
  118. avatarSrc: item.Avatar,
  119. userLink: window.origin + '/' + item.Name,
  120. statusStr: item.IsActive ? this.$t('user.Activated') : this.$t('user.notActive'),
  121. statusColor: item.IsActive ? 'rgb(82, 196, 26)' : 'rgb(245, 34, 45)',
  122. regTime: formatDate(new Date(item.CreatedUnix * 1000), 'yyyy-MM-dd HH:mm:ss'),
  123. }
  124. },
  125. initData() {
  126. getUserInvitationCode({ page: this.pageInfo.curpage, pageSize: this.pageInfo.pageSize }).then(res => {
  127. res = res.data;
  128. if (res) {
  129. this.bannerImg = res.page_banner_img;
  130. this.bannerTitle = res.page_banner_title;
  131. this.pageLink = res.page_link;
  132. this.pageLinkDesc = res.page_link_desc;
  133. this.invitationCode = res.invitation_code;
  134. this.pageOpeniDesc = res.page_openi_desc;
  135. this.tableData = (res.invitation_users || []).map((item, index) => {
  136. return this.transRowData(item);
  137. });
  138. this.pageInfo.total = res.invitation_users_count;
  139. const qrCode = new QRCode("__qr-code__", {
  140. text: this.invitationLink + this.invitationCode,
  141. width: 120,
  142. height: 120,
  143. colorDark: '#000000',
  144. colorLight: '#ffffff',
  145. correctLevel: QRCode.CorrectLevel.H
  146. });
  147. }
  148. }).catch(err => {
  149. console.log(err);
  150. });
  151. },
  152. getTableData() {
  153. const params = {
  154. page: this.pageInfo.curpage,
  155. pageSize: this.pageInfo.pageSize,
  156. };
  157. this.loading = true;
  158. getUserInvitationCode(params).then(res => {
  159. this.loading = false;
  160. res = res.data;
  161. const data = (res.invitation_users || []).map((item, index) => {
  162. return this.transRowData(item);
  163. });
  164. this.tableData = data;
  165. this.pageInfo.total = res.invitation_users_count;
  166. }).catch(err => {
  167. console.log(err);
  168. this.loading = false;
  169. });
  170. },
  171. currentChange(val) {
  172. this.pageInfo.curpage = val;
  173. this.getTableData();
  174. },
  175. },
  176. mounted() {
  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. .__copy_link_btn__ {
  258. font-size: 14px;
  259. padding: 11px 15px;
  260. background: rgb(21, 114, 255);
  261. border-radius: 0;
  262. }
  263. .qr-code {
  264. width: 150px;
  265. display: flex;
  266. flex-direction: column;
  267. align-items: end;
  268. }
  269. }
  270. .table-container {
  271. margin-bottom: 16px;
  272. /deep/ .el-table__header {
  273. th {
  274. background: rgb(245, 245, 246);
  275. font-size: 14px;
  276. color: rgb(36, 36, 36);
  277. font-weight: 400;
  278. }
  279. }
  280. /deep/ .el-table__body {
  281. td {
  282. font-size: 14px;
  283. }
  284. }
  285. .op-btn {
  286. cursor: pointer;
  287. font-size: 12px;
  288. color: rgb(25, 103, 252);
  289. margin: 0 5px;
  290. }
  291. }
  292. .center {
  293. display: flex;
  294. justify-content: center;
  295. }
  296. </style>