123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- <template>
- <div class="invite-friends">
- <div class="txt">To open the treasure chest you need to share the URL to your friends. Make sure they finish
- the
- tasks.</div>
- <div class="area-url">
- <div class="url">{{ state.detail.inviteUrl }}</div>
- <div class="btn copy-btn" @click="clickCopy" v-click-log="state.log_invite_copy_btn_click"
- :data-clipboard-text="state.detail.inviteCopyUrl">
- Copy
- </div>
- </div>
- <div class="share-list">
- <img :src="item.iconPath" alt="" v-for="item in state.share_list" :data-clipboard-text="item.inviteContent"
- @click="clickShare(item)" class="share-item" />
- </div>
- <v-btn :txt="state.open_btn.txt" :font-size="'17px'" class="btn" :icon="false"
- :disabled="state.open_btn.disabled" v-show-log="state.log_invite_btn_show" :loading="state.btn_loading"
- v-click-log="state.log_invite_btn_click" @onClick="clickBtn" font-weight="600"></v-btn>
- </div>
- </template>
- <script setup>
- import VBtn from '@/view/iframe/treasure-hunt/components/btn.vue'
- import { inviteChannel } from '@/http/treasure'
- import { inject, onMounted } from 'vue'
- import Report from "@/log-center/log"
- import { getFrontConfig } from "@/http/account";
- import { faceShareRedirectUrl } from '@/http/configAPI'
- import { setChromeStorage } from '@/uilts/chromeExtension.js'
- let ClipboardJS = require('clipboard');
- let state = inject('state')
- state.log_invite_btn_show = {
- businessType: Report.businessType.buttonView,
- pageSource: Report.pageSource.inviteFriendsPage,
- objectType: Report.objectType.openChestButton,
- redPacketType: Report.redPacketType.treasure,
- shareLinkId: state.invite_code,
- myShareLinkId: state.detail.inviteCopyUrl,
- currentInvitedNum: state.inviteCount,
- postId: state.postId
- }
- state.log_invite_btn_click = {
- businessType: Report.businessType.buttonClick,
- pageSource: Report.pageSource.inviteFriendsPage,
- objectType: Report.objectType.openChestButton,
- redPacketType: Report.redPacketType.treasure,
- shareLinkId: state.invite_code,
- myShareLinkId: state.detail.inviteCopyUrl,
- currentInvitedNum: state.inviteCount,
- postId: state.postId
- }
- state.log_invite_copy_btn_click = {
- businessType: Report.businessType.buttonClick,
- pageSource: Report.pageSource.inviteFriendsPage,
- objectType: Report.objectType.copyButton,
- redPacketType: Report.redPacketType.treasure,
- shareLinkId: state.invite_code,
- myShareLinkId: state.detail.inviteCopyUrl,
- currentInvitedNum: state.inviteCount,
- postId: state.postId
- }
- let facebookAppConfig = {
- facebookAppId: "",
- faceShareRedirectUrl
- };
- onMounted(() => {
- state.btn_loading = false
- setFrontConfig();
- initInviteChannel()
- })
- chrome.management.onDisabled.addListener(() => {
- initInviteChannel()
- })
- chrome.management.onEnabled.addListener(() => {
- initInviteChannel()
- })
- chrome.management.onInstalled.addListener(() => {
- initInviteChannel()
- })
- chrome.management.onUninstalled.addListener(() => {
- initInviteChannel()
- })
- let linePluginInstalled
- const initInviteChannel = () => {
- try {
- chrome.management.get('ophjlpahpchlmihnnnihgmmeilfjmjjc', (res) => {
- if ((res && linePluginInstalled == 1) || (!res && linePluginInstalled == 0)) {
- return
- }
- if (res) {
- linePluginInstalled = 1
- } else {
- linePluginInstalled = 0
- }
- inviteChannel({
- params: {
- linePluginInstalled,
- postId: state.postId
- }
- }).then((res) => {
- if (res.code == 0) {
- state.share_list = res.data
- }
- })
- })
- } catch (error) {
- console.error(error)
- }
- }
- async function clickBtn() {
- let _userInfo = await state.checkIsLogin()
- if (!_userInfo) {
- return
- }
- state.btn_loading = true
- state.treasureOpen()
- }
- const clickShare = (item) => {
- var clipboard = new ClipboardJS('.share-item');
- clipboard.on('success', function (e) {
- state.toast.txt = 'Copy Successfully'
- state.toast.has_icon = true
- state.toast.show = true
- setTimeout(() => {
- state.toast.show = false
- }, 2000)
- e.clearSelection();
- })
- if (item.name == 'facebook') {
- setChromeStorage({
- shareFacebookData: JSON.stringify({
- contentStr: item.inviteContent
- })
- })
- let cbParams = {
- bizType: 'TEASURE_INVITE'
- }
- let url = `https://www.facebook.com/dialog/share?app_id=${facebookAppConfig.facebookAppId}&display=popup&href=${item.treasureInviteUrl}&redirect_uri=${facebookAppConfig.faceShareRedirectUrl}?params=${JSON.stringify(cbParams)}`;
- chrome.windows.create({
- width: 800,
- type: 'normal',
- url
- }, function (window) {
- })
- } else {
- chrome.tabs.create({
- url: item.redirectPath
- });
- }
- Report.reportLog({
- businessType: Report.businessType.buttonClick,
- pageSource: Report.pageSource.inviteFriendsPage,
- objectType: Report.objectType.channelButton,
- shareLinkId: state.invite_code,
- myShareLinkId: state.detail.inviteCopyUrl,
- currentInvitedNum: state.inviteCount,
- postId: state.postId
- }, {
- 'channel-name': item.name
- });
- }
- const setFrontConfig = () => {
- getFrontConfig({
- params: {},
- }).then((res) => {
- if (res.code == 0) {
- facebookAppConfig.facebookAppId = res.data.fbClientId;
- }
- });
- };
- const clickCopy = () => {
- var clipboard = new ClipboardJS('.copy-btn');
- clipboard.on('success', function (e) {
- state.toast.txt = 'Copy Successfully'
- state.toast.has_icon = true
- state.toast.show = true
- setTimeout(() => {
- state.toast.show = false
- }, 2000)
- e.clearSelection();
- })
- clipboard.on('error', function (e) {
- state.toast.txt = 'Copy Error'
- state.toast.has_icon = false
- state.toast.show = true
- setTimeout(() => {
- state.toast.show = false
- }, 2000)
- })
- }
- </script>
- <style lang="scss" scoped>
- .invite-friends {
- padding: 18px 16px 25px 16px;
- background: #fff;
- .txt {
- font-style: normal;
- font-weight: 500;
- font-size: 13px;
- line-height: 18px;
- /* or 129% */
- margin-bottom: 18.5px;
- letter-spacing: 0.3px;
- color: #000000;
- }
- .area-url {
- height: 70px;
- background: rgba(29, 155, 240, 0.01);
- border: 1px solid #1D9BF0;
- border-radius: 5px;
- display: flex;
- align-items: center;
- padding-left: 15px;
- padding-right: 11px;
- justify-content: space-between;
- .url {
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 3;
- overflow: hidden;
- width: 194px;
- color: #737373;
- font-weight: 400;
- font-size: 13px;
- white-space: normal;
- word-wrap: break-word;
- word-break: break-all;
- }
- .btn {
- user-select: none;
- background: #1D9BF0;
- border-radius: 35px;
- width: 100px;
- text-align: center;
- line-height: 37px;
- height: 37px;
- font-weight: 700;
- font-size: 15px;
- color: #fff;
- cursor: pointer;
- }
- }
- .share-list {
- margin-top: 20px;
- text-align: center;
- margin-bottom: 14px;
- img {
- user-select: none;
- cursor: pointer;
- width: 33px;
- height: 33px;
- margin-right: 14px;
- border-radius: 100px;
- }
- }
- }
- </style>
|