123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- <template>
- <div id="denet_group_tip" v-if="state.data" style="display: flex;z-index: 100; background-color: #356789;">
- <div style="flex:1; display: flex; align-items: center;">
- <div>
- <img :src="state.data.linkImagePath" style="width:54px;height:54px; margin: 0 20px;" alt="" />
- </div>
- <div>
- <p style="font-weight: 700; font-size: 18px; color: #fff; margin: 0; padding: 0; margin-bottom: 11px;">
- {{ state.data.nftGroupName }}
- </p>
- <div style="display: flex; ">
- <div style="display: flex; align-items: center;">
- <img :src="require('@/assets/img/icon-user.png')"
- style="width:16px;height:16px; margin-right: 5px;" alt="" />
- <span style="color: #fff;">{{ state.data.postCount }} Posts</span>
- </div>
- <div style="display: flex; align-items: center; margin-left: 17px;">
- <img :src="require('@/assets/img/icon-messgae.png')"
- style="width:16px;height:16px; margin-right: 5px;" alt="" />
- <span style="color: #fff;">{{ state.data.memberCount }} Member</span>
- </div>
- </div>
- </div>
- </div>
- <div
- style="width: 180px;height: 100%; display: flex; align-items: center; justify-content: center; position: relative;">
- <div v-show="state.show == 'post'" style="width: 140px; height: 40px; display:flex; align-items: center; justify-content: center; background: #1D9BF0; border-radius: 50px;
- cursor: pointer;
- " @click="clickPost">
- <img :src="require('@/assets/img/icon-messgae.png')" style="width:16px;height:16px;" alt="">
- <span style="margin-left: 7px; font-size: 15px;font-weight: 700; color: #fff; ">Post</span>
- </div>
- <div v-show="state.show == 'join'"
- style="width: 140px; height: 40px; display:flex; align-items: center; justify-content: center; background: #1D9BF0; border-radius: 50px; cursor: pointer;"
- @click="clickJoin">
- <span style="margin-left: 7px; font-size: 15px;font-weight: 700; color: #fff; ">Join Now</span>
- </div>
- <svg @click="clickArrow" v-show="state.show == 'arrow'" id="denet_tip_group_arrow"
- style="position: absolute; right: 20px;" width="40" height="40" viewBox="0 0 40 40" fill="none"
- xmlns="http://www.w3.org/2000/svg">
- <path d="M15 10L26 19.6875L15 29.375" stroke="white" stroke-width="2" />
- </svg>
- </div>
- </div>
- </template>
- <script setup>
- import { reactive, onMounted } from 'vue'
- import { getTwitterNftGroupInfo, getTwitterNftPostPre } from "@/http/group";
- import { getQueryString } from '@/uilts/help.js';
- import { sendChromeTabMessage, checkIsLogin } from '@/uilts/chromeExtension.js';
- let state = reactive({
- show: 'post', //join
- show2: '',
- data: {},
- twitterAccount: ''
- })
- // 显示加入小组弹框
- const clickJoin = () => {
- sendChromeTabMessage({
- actionType: "IFRAME_SHOW_JOIN_DIALOG",
- data: {
- type: 'join',
- buy_nft_status: state.data.buyNftStatus,
- nft_group_Id: state.data.nftGroupId
- }
- })
- }
- const init = (callback) => {
- getTwitterNftGroupInfo({
- params: {
- twitterAccount: state.twitterAccount
- }
- }).then((res) => {
- if (res.code == 0) {
- state.data = res.data
- if (state.data) {
- // 未加入
- if (res.data.joinStatus == 0) {
- state.show2 = 'join'
- state.show = 'join'
- // 已加入
- } else if (res.data.joinStatus == 1) {
- state.show2 = 'post'
- state.show = 'post'
- }
- callback()
- }
- }
- sendMessageToContent({
- actionType: 'IFRAME_GROUP_BANNER_GROUP_INFO',
- data: res.data || {}
- })
- })
- }
- chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
- sendResponse('')
- switch (req.actionType) {
- case 'FINISH_GROUP_BANNNER':
- init()
- break
- case 'SWITCH_GROUP_BANNER_STATUS':
- if (req.data.type == 'arrow') {
- state.show = 'arrow'
- } else {
- state.show = state.show2
- }
- break
- }
- })
- const sendMessageToContent = (params) => {
- let { actionType, data } = params || {};
- chrome.tabs.getCurrent((tab) => {
- chrome.tabs.sendMessage(tab.id, {
- actionType,
- data,
- }, (res) => { console.log(res) });
- })
- }
- const clickArrow = () => {
- sendChromeTabMessage({ actionType: "SWITCH_GROUP_STATUS" }, () => { })
- }
- async function clickPost() {
- // getTwitterNftPostPre({
- // params:{
- // groupId:''
- // }
- // }).then((res)=>{
- // })
- let _userInfo = await checkIsLogin()
- if (_userInfo) {
- sendChromeTabMessage({
- actionType: "IFRAME_SHOW_POST_DIALOG",
- data: {
- groupId: state.data.nftGroupId
- }
- })
- }
- // 没有购买过
- // if (state.data.buyNftStatus == 0) {
- // sendChromeTabMessage({
- // actionType: "IFRAME_SHOW_JOIN_DIALOG",
- // data: {
- // type: 'buy',
- // buy_nft_status: state.data.buyNftStatus,
- // nft_group_Id: state.data.nftGroupId
- // }
- // })
- // // 购买过
- // } else if (state.data.buyNftStatus == 1) {
- // sendChromeTabMessage({
- // actionType: "IFRAME_SHOW_POST_DIALOG",
- // data: {
- // groupId: state.data.nftGroupId
- // }
- // })
- // }
- }
- onMounted(() => {
- state.twitterAccount = getQueryString('twitterAccount') || ''
- init(() => {
- sendChromeTabMessage({ actionType: "IFRAME_SHOW_GROUP_TIP" })
- })
- })
- </script>
- <style lang='scss'>
- html,
- body,
- #app {
- margin: 0;
- padding: 0;
- width: 100%;
- height: 100%;
- }
- #denet_group_tip {
- width: 100%;
- height: 100%;
- }
- </style>
|