group-card.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. setChromeStorage({ groupTabData: JSON.stringify({
  50. deTabVal: 'deGroupTab'
  51. })})
  52. window.open(`https://twitter.com/${detail.value.defaultTwitterAccount}`)
  53. }
  54. })
  55. }
  56. // 重新绑定
  57. const reSetBindTwtterId = (_params = {}) => {
  58. getChromeStorage('userInfo', (_userInfo = {}) => {
  59. if (_userInfo && _userInfo.uid == _params.uid) {
  60. srcPublishSuccess({
  61. params: {
  62. postId: postId,
  63. srcContentId: tweet_Id
  64. }
  65. }).then((res) => {
  66. if (res.code == 0 || res.code == 3003) {
  67. }
  68. })
  69. }
  70. })
  71. }
  72. const getDetail = () => {
  73. getPostDetail({
  74. params: {
  75. postId: postId
  76. }
  77. }).then(res => {
  78. let { data } = res
  79. if (data !== null) {
  80. detail.value = JSON.parse(data.postBizData)
  81. }
  82. })
  83. }
  84. onMounted(() => {
  85. getPostDetail({
  86. params: {
  87. postId: postId
  88. }
  89. }).then(res => {
  90. let { data } = res
  91. if (data !== null) {
  92. detail.value = JSON.parse(data.postBizData)
  93. if (!data.srcContentId) {
  94. reSetBindTwtterId(data)
  95. return
  96. }
  97. }
  98. })
  99. // 登录回调
  100. chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
  101. switch (req.actionType) {
  102. case 'BG_LOGIN_SET_USERINFO_CB':
  103. getDetail();
  104. break;
  105. }
  106. })
  107. })
  108. </script>
  109. <style lang='scss'>
  110. html,
  111. body {
  112. margin: 0;
  113. padding: 0;
  114. user-select: none;
  115. }
  116. .card {
  117. height: 180px;
  118. border-radius: 12px;
  119. background: url('../../../assets/svg/icon-nft-group-pc.svg') no-repeat right bottom #48B1F7;
  120. .padding {
  121. padding: 20px;
  122. .info {
  123. display: flex;
  124. flex-direction: row;
  125. align-items: center;
  126. height: 100px;
  127. .logo {
  128. display: flex;
  129. align-items: center;
  130. justify-content: center;
  131. width: 54px;
  132. height: 54px;
  133. border-radius: 6px;
  134. background: #FFFFFF;
  135. margin-right: 20px;
  136. img {
  137. width: 50px;
  138. height: 50px;
  139. border-radius: 6px;
  140. }
  141. }
  142. .mess {
  143. flex: 1;
  144. .title {
  145. overflow: hidden;
  146. color: #FFFFFF;
  147. font-size: 18px;
  148. line-height: 21px;
  149. text-overflow: ellipsis;
  150. white-space: nowrap;
  151. }
  152. .opt {
  153. color: #FFFFFF;
  154. font-size: 12px;
  155. margin-top: 8px;
  156. label {
  157. margin-right: 18px;
  158. img {
  159. margin-top: -4px;
  160. margin-right: 4px;
  161. vertical-align: middle;
  162. }
  163. }
  164. }
  165. }
  166. }
  167. .join {
  168. display: flex;
  169. align-items: center;
  170. justify-content: center;
  171. height: 40px;
  172. cursor: pointer;
  173. color: #FFFFFF;
  174. font-size: 16px;
  175. font-weight: bold;
  176. background: #101419;
  177. border-radius: 100px;
  178. }
  179. }
  180. }
  181. </style>