group-card.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <div class="card">
  3. <div class="padding" v-if="detail">
  4. <div class="info">
  5. <div class="logo">
  6. <img :src="detail.groupIcon" />
  7. </div>
  8. <div class="mess">
  9. <div class="title">
  10. {{ detail.groupName }}
  11. </div>
  12. <div class="opt">
  13. <label>
  14. <img src="../../../assets/svg/icon-nft-member.svg" />
  15. <span>{{ detail.memberCount }} Members</span>
  16. </label>
  17. <label>
  18. <img src="../../../assets/svg/icon-nft-post.svg" />
  19. <span>{{ detail.postCount }} Posts</span>
  20. </label>
  21. </div>
  22. </div>
  23. </div>
  24. <div class="join" @click="jumpUserPage">
  25. {{ detail.joinStatus === 0 ? 'Join Now' : 'View' }}
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script setup>
  31. import { onBeforeMount, onMounted, ref } from 'vue';
  32. import { getPostDetail } from '@/http/redPacket';
  33. import { getQueryString } from '@/uilts/help.js'
  34. import { srcPublishSuccess } from '@/http/publishApi'
  35. import { getChromeStorage, setChromeStorage } from '@/uilts/chromeExtension.js'
  36. let postId = getQueryString('projectId');
  37. let tweet_Id = getQueryString('tweet_Id')
  38. let detail = ref(null);
  39. const jumpUserPage = () => {
  40. getChromeStorage('userInfo', (_userInfo) => {
  41. if (!_userInfo) {
  42. chrome.runtime.sendMessage(
  43. { actionType: "POPUP_LOGIN", data: "" },
  44. (response) => {
  45. console.log("res", response);
  46. }
  47. )
  48. } else {
  49. window.open(`https://twitter.com/${detail.value.defaultTwitterAccount}#selectDeNftGroupTab`)
  50. }
  51. })
  52. }
  53. // 重新绑定
  54. const reSetBindTwtterId = (_params = {}) => {
  55. getChromeStorage('userInfo', (_userInfo = {}) => {
  56. if (_userInfo && _userInfo.uid == _params.uid) {
  57. srcPublishSuccess({
  58. params: {
  59. postId: postId,
  60. srcContentId: tweet_Id
  61. }
  62. }).then((res) => {
  63. if (res.code == 0 || res.code == 3003) {
  64. }
  65. })
  66. }
  67. })
  68. }
  69. const getDetail = () => {
  70. getPostDetail({
  71. params: {
  72. postId: postId
  73. }
  74. }).then(res => {
  75. let { data } = res
  76. if (data !== null) {
  77. detail.value = JSON.parse(data.postBizData)
  78. }
  79. })
  80. }
  81. onMounted(() => {
  82. getPostDetail({
  83. params: {
  84. postId: postId
  85. }
  86. }).then(res => {
  87. let { data } = res
  88. if (data !== null) {
  89. detail.value = JSON.parse(data.postBizData)
  90. if (!data.srcContentId) {
  91. reSetBindTwtterId(data)
  92. return
  93. }
  94. }
  95. })
  96. // 登录回调
  97. chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
  98. switch (req.actionType) {
  99. case 'BG_LOGIN_SET_USERINFO_CB':
  100. getDetail();
  101. break;
  102. }
  103. })
  104. })
  105. </script>
  106. <style lang='scss'>
  107. html,
  108. body {
  109. margin: 0;
  110. padding: 0;
  111. user-select: none;
  112. }
  113. .card {
  114. height: 180px;
  115. border-radius: 12px;
  116. background: url('../../../assets/svg/icon-nft-group-pc.svg') no-repeat right bottom #48B1F7;
  117. .padding {
  118. padding: 20px;
  119. .info {
  120. display: flex;
  121. flex-direction: row;
  122. align-items: center;
  123. height: 100px;
  124. .logo {
  125. display: flex;
  126. align-items: center;
  127. justify-content: center;
  128. width: 54px;
  129. height: 54px;
  130. border-radius: 6px;
  131. background: #FFFFFF;
  132. margin-right: 20px;
  133. img {
  134. width: 50px;
  135. height: 50px;
  136. border-radius: 6px;
  137. }
  138. }
  139. .mess {
  140. flex: 1;
  141. .title {
  142. overflow: hidden;
  143. color: #FFFFFF;
  144. font-size: 18px;
  145. line-height: 21px;
  146. text-overflow: ellipsis;
  147. white-space: nowrap;
  148. }
  149. .opt {
  150. color: #FFFFFF;
  151. font-size: 12px;
  152. margin-top: 8px;
  153. label {
  154. margin-right: 18px;
  155. img {
  156. margin-top: -4px;
  157. margin-right: 4px;
  158. vertical-align: middle;
  159. }
  160. }
  161. }
  162. }
  163. }
  164. .join {
  165. display: flex;
  166. align-items: center;
  167. justify-content: center;
  168. height: 40px;
  169. cursor: pointer;
  170. color: #FFFFFF;
  171. font-size: 16px;
  172. font-weight: bold;
  173. background: #101419;
  174. border-radius: 100px;
  175. }
  176. }
  177. }
  178. </style>