relateGroup.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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="pub-loading" v-if="isLoadingRoom"></div>
  8. <div class="box-bd pub-scroll-box" v-else>
  9. <h2>{{$t('group.needRelateTelegram')}}:<span>{{tgGroupTitle}}</span></h2>
  10. <ul class="list-group" v-if="isBind">
  11. <li class="group-item" v-for="(item,index) in groups" :key="index">
  12. <h3>{{item.group_title}}</h3>
  13. <p>{{`https://mee.chat/s/${item.group_id}`}}</p>
  14. <p>{{$t('group.groupId')}}:{{item.group_id}}</p>
  15. <el-button type="primary" class="btn-relate" @click="doSync(index)">{{$t('group.relate')}}</el-button>
  16. </li>
  17. <li class="group-item ext-add" @click="createAndSync()">
  18. <h3>{{$t('group.createGroupToRelate')}}</h3>
  19. <i class="el-icon-plus"></i>
  20. </li>
  21. </ul>
  22. <div class="no-data" v-else>
  23. <h3>{{$t('group.needRelateTip')}}</h3>
  24. <i class="icon-tele"></i>
  25. <el-button type="primary" class="btn-relate" @click="bindTg">{{$t('group.clickBind')}}</el-button>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. import Vue from 'vue'
  33. import { Button } from 'element-ui'
  34. import api from '@/api'
  35. import { getMeechatType } from '@/util/util'
  36. import { bindAccountMixins } from '@/mixins/user'
  37. Vue.component(Button.name, Button)
  38. export default {
  39. name: 'relateGroup',
  40. mixins: [bindAccountMixins],
  41. components: {
  42. },
  43. data () {
  44. return {
  45. params: {},
  46. isLoadingRoom: true,
  47. isLoading: false,
  48. isBind: false,
  49. tgGroupTitle: '',
  50. tgGroupId: 0,
  51. winHandler: null,
  52. groups: [],
  53. timeoutHandler: 0,
  54. meechatType: getMeechatType()
  55. }
  56. },
  57. async created () {
  58. let search = location.hash.replace('#/relateGroup?', '')
  59. let searchArgs = search.split('&')
  60. let params = {}
  61. searchArgs.forEach((item) => {
  62. let arr = item.split('=')
  63. params[arr[0]] = arr[1]
  64. })
  65. this.params = params
  66. this.getSyncInfo(this.params)
  67. },
  68. methods: {
  69. getSyncInfo (params) {
  70. api.tg.getSyncInfo(params).then(({ data }) => {
  71. this.groups = data.data.groups
  72. this.isBind = !!data.data.userId
  73. this.tgGroupTitle = decodeURI(data.data.tgGroupTitle)
  74. this.tgGroupId = data.data.tgGroupId
  75. this.isLoadingRoom = false
  76. }).catch(e => {
  77. this.isLoadingRoom = false
  78. })
  79. },
  80. async doSync (index) {
  81. this.isLoading = true
  82. let groupId = this.groups[index].group_id
  83. api.tg.doSync({
  84. group_id: groupId,
  85. tg_group_id: this.tgGroupId
  86. }).then(() => {
  87. this.isLoading = false
  88. this.$router.replace(`/group/${groupId}`)
  89. }).catch(error => {
  90. this.isLoading = false
  91. console.log(error)
  92. })
  93. },
  94. createAndSync () {
  95. if (this.meechatType == 'h5') {
  96. this.$router.push(`/invite/1?tgGroupId=${this.tgGroupId}`)
  97. } else {
  98. this.$showInvite(1, {
  99. tgGroupId: this.tgGroupId
  100. })
  101. }
  102. }
  103. }
  104. }
  105. </script>
  106. <style lang="scss" scoped>
  107. @import "./relateGroup.scss";
  108. </style>