group-card.vue 5.4 KB

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