relateGroup.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <div class="c-view" v-loading="isLoading">
  3. <div class="box">
  4. <div class="box-hd">
  5. <div class="title-wrap">{{$t('group.relateTelegram')}}</div>
  6. </div>
  7. <div class="box-bd pub-scroll-box">
  8. <h2>{{$t('group.needRelateTelegram')}}:<span>{{tgGroupTitle}}</span></h2>
  9. <ul class="list-group" v-if="isBind">
  10. <li class="group-item" v-for="(item,index) in groups" :key="index">
  11. <h3>{{item.group_title}}</h3>
  12. <p>{{`https://mee.chat/s/${item.group_id}`}}</p>
  13. <p>{{$t('group.groupId')}}:{{item.group_id}}</p>
  14. <el-button type="primary" class="btn-relate" @click="doSync(index)">{{$t('group.relate')}}</el-button>
  15. </li>
  16. <li class="group-item ext-add">
  17. <h3>{{$t('group.createGroupToRelate')}}</h3>
  18. <i class="el-icon-plus"></i>
  19. </li>
  20. </ul>
  21. <div class="no-data" v-else>
  22. <h3>目前你还没有绑定Telegram账号,需绑定后进行后续操作</h3>
  23. <i class="icon-tele"></i>
  24. <el-button type="primary" class="btn-relate">点击绑定</el-button>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. import Vue from 'vue'
  32. import { Button } from 'element-ui'
  33. import api from '@/api'
  34. Vue.component(Button.name, Button)
  35. export default {
  36. name: 'relateGroup',
  37. components: {
  38. },
  39. data () {
  40. return {
  41. isLoading: false,
  42. isBind: false,
  43. tgGroupTitle: '',
  44. tgGroupId: 0,
  45. winHandler: null,
  46. groups: []
  47. }
  48. },
  49. async created () {
  50. let search = location.hash.replace('#/relateGroup?', '')
  51. let searchArgs = search.split('&')
  52. let params = {}
  53. searchArgs.forEach((item) => {
  54. let arr = item.split('=')
  55. params[arr[0]] = arr[1]
  56. })
  57. let { data } = await api.tg.getSyncInfo(params)
  58. this.groups = data.data.groups
  59. this.isBind = !!data.data.userId
  60. this.tgGroupTitle = decodeURI(data.data.tgGroupTitle)
  61. this.tgGroupId = data.data.tgGroupId
  62. },
  63. methods: {
  64. async doSync (index) {
  65. this.isLoading = true
  66. let groupId = this.groups[index].group_id
  67. api.tg.doSync({
  68. group_id: groupId,
  69. tg_group_id: this.tgGroupId
  70. }).then(() => {
  71. this.isLoading = false
  72. this.$router.replace(`/group/${groupId}`)
  73. }).catch(error => {
  74. this.isLoading = false
  75. console.log(error)
  76. })
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. @import "./relateGroup.scss";
  83. </style>