card.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <div id="denet_group_tip" v-if="state.data" style="display: flex;z-index: 100; background-color: #356789;">
  3. <div style="flex:1; display: flex; align-items: center;">
  4. <div>
  5. <img :src="state.data.linkImagePath" style="width:54px;height:54px; margin: 0 20px;" alt="" />
  6. </div>
  7. <div>
  8. <p style="font-weight: 700; font-size: 18px; color: #fff; margin: 0; padding: 0; margin-bottom: 11px;">
  9. {{ state.data.nftGroupName }}
  10. </p>
  11. <div style="display: flex; ">
  12. <div style="display: flex; align-items: center;">
  13. <img :src="require('@/assets/img/icon-user.png')"
  14. style="width:16px;height:16px; margin-right: 5px;" alt="" />
  15. <span style="color: #fff;">{{ state.data.postCount }} Posts</span>
  16. </div>
  17. <div style="display: flex; align-items: center; margin-left: 17px;">
  18. <img :src="require('@/assets/img/icon-messgae.png')"
  19. style="width:16px;height:16px; margin-right: 5px;" alt="" />
  20. <span style="color: #fff;">{{ state.data.memberCount }} Member</span>
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. <div
  26. style="width: 180px;height: 100%; display: flex; align-items: center; justify-content: center; position: relative;">
  27. <div v-show="state.show == 'post'" style="width: 140px; height: 40px; display:flex; align-items: center; justify-content: center; background: #1D9BF0; border-radius: 50px;
  28. cursor: pointer;
  29. " @click="clickPost">
  30. <img :src="require('@/assets/img/icon-messgae.png')" style="width:16px;height:16px;" alt="">
  31. <span style="margin-left: 7px; font-size: 15px;font-weight: 700; color: #fff; ">Post</span>
  32. </div>
  33. <div v-show="state.show == 'join'"
  34. style="width: 140px; height: 40px; display:flex; align-items: center; justify-content: center; background: #1D9BF0; border-radius: 50px; cursor: pointer;"
  35. @click="clickJoin">
  36. <span style="margin-left: 7px; font-size: 15px;font-weight: 700; color: #fff; ">Join Now</span>
  37. </div>
  38. <svg @click="clickArrow" v-show="state.show == 'arrow'" id="denet_tip_group_arrow"
  39. style="position: absolute; right: 20px;" width="40" height="40" viewBox="0 0 40 40" fill="none"
  40. xmlns="http://www.w3.org/2000/svg">
  41. <path d="M15 10L26 19.6875L15 29.375" stroke="white" stroke-width="2" />
  42. </svg>
  43. </div>
  44. </div>
  45. </template>
  46. <script setup>
  47. import { reactive, onMounted } from 'vue'
  48. import { getTwitterNftGroupInfo, getTwitterNftPostPre } from "@/http/group";
  49. import { getQueryString } from '@/uilts/help.js';
  50. import { sendChromeTabMessage, checkIsLogin } from '@/uilts/chromeExtension.js';
  51. let state = reactive({
  52. show: 'post', //join
  53. show2: '',
  54. data: {},
  55. twitterAccount: ''
  56. })
  57. // 显示加入小组弹框
  58. const clickJoin = () => {
  59. sendChromeTabMessage({
  60. actionType: "IFRAME_SHOW_JOIN_DIALOG",
  61. data: {
  62. type: 'join',
  63. buy_nft_status: state.data.buyNftStatus,
  64. nft_group_Id: state.data.nftGroupId
  65. }
  66. })
  67. }
  68. const init = (callback) => {
  69. getTwitterNftGroupInfo({
  70. params: {
  71. twitterAccount: state.twitterAccount
  72. }
  73. }).then((res) => {
  74. if (res.code == 0) {
  75. state.data = res.data
  76. if (state.data) {
  77. // 未加入
  78. if (res.data.joinStatus == 0) {
  79. state.show2 = 'join'
  80. state.show = 'join'
  81. // 已加入
  82. } else if (res.data.joinStatus == 1) {
  83. state.show2 = 'post'
  84. state.show = 'post'
  85. }
  86. callback()
  87. }
  88. }
  89. sendMessageToContent({
  90. actionType: 'IFRAME_GROUP_BANNER_GROUP_INFO',
  91. data: res.data || {}
  92. })
  93. })
  94. }
  95. chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
  96. sendResponse('')
  97. switch (req.actionType) {
  98. case 'FINISH_GROUP_BANNNER':
  99. init()
  100. break
  101. case 'SWITCH_GROUP_BANNER_STATUS':
  102. if (req.data.type == 'arrow') {
  103. state.show = 'arrow'
  104. } else {
  105. state.show = state.show2
  106. }
  107. break
  108. }
  109. })
  110. const sendMessageToContent = (params) => {
  111. let { actionType, data } = params || {};
  112. chrome.tabs.getCurrent((tab) => {
  113. chrome.tabs.sendMessage(tab.id, {
  114. actionType,
  115. data,
  116. }, (res) => { console.log(res) });
  117. })
  118. }
  119. const clickArrow = () => {
  120. sendChromeTabMessage({ actionType: "SWITCH_GROUP_STATUS" }, () => { })
  121. }
  122. async function clickPost() {
  123. // getTwitterNftPostPre({
  124. // params:{
  125. // groupId:''
  126. // }
  127. // }).then((res)=>{
  128. // })
  129. let _userInfo = await checkIsLogin()
  130. if (_userInfo) {
  131. sendChromeTabMessage({
  132. actionType: "IFRAME_SHOW_POST_DIALOG",
  133. data: {
  134. groupId: state.data.nftGroupId
  135. }
  136. })
  137. }
  138. // 没有购买过
  139. // if (state.data.buyNftStatus == 0) {
  140. // sendChromeTabMessage({
  141. // actionType: "IFRAME_SHOW_JOIN_DIALOG",
  142. // data: {
  143. // type: 'buy',
  144. // buy_nft_status: state.data.buyNftStatus,
  145. // nft_group_Id: state.data.nftGroupId
  146. // }
  147. // })
  148. // // 购买过
  149. // } else if (state.data.buyNftStatus == 1) {
  150. // sendChromeTabMessage({
  151. // actionType: "IFRAME_SHOW_POST_DIALOG",
  152. // data: {
  153. // groupId: state.data.nftGroupId
  154. // }
  155. // })
  156. // }
  157. }
  158. onMounted(() => {
  159. state.twitterAccount = getQueryString('twitterAccount') || ''
  160. init(() => {
  161. sendChromeTabMessage({ actionType: "IFRAME_SHOW_GROUP_TIP" })
  162. })
  163. })
  164. </script>
  165. <style lang='scss'>
  166. html,
  167. body,
  168. #app {
  169. margin: 0;
  170. padding: 0;
  171. width: 100%;
  172. height: 100%;
  173. }
  174. #denet_group_tip {
  175. width: 100%;
  176. height: 100%;
  177. }
  178. </style>