123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- <!-- 发布器-预览卡片 -->
- <template>
- <div class="wrapper">
- <div class="card-container">
- <!-- 安装之后的卡片样式 -->
- <div v-show="installStatus" class="left" :style="{'width': reviewCanvasParams.width+ 'px'}">
- <div class="head" :style="{'zoom': reviewCanvasParams.zoom}">
- <img :src="userInfo.avatarUrl"
- class="avatar"/>
- <div class="article-wrapper">
- <div class="nickname">
- {{userInfo.name}}
- </div>
- <div class="name">
- @{{userInfo.nickName}}
- </div>
- </div>
- </div>
- <div class="after-cover-wrapper-parent" :style="{'zoom': reviewCanvasParams.zoom}">
- <div class="after-cover-wrapper">
- <custom-card-cover :data="{
- totalCount: baseFormData.totalCount,
- amountValue: baseFormData.amountValue,
- usdEstimateOrderAmount: baseFormData.usdEstimateOrderAmount,
- tokenSymbol: currentCurrencyInfo.tokenSymbol,
- currencyCode: currentCurrencyInfo.currencyCode,
- currencyIconUrl: currentCurrencyInfo.iconPath,
- type: baseFormData.type,
- validityDuration: baseFormData.validityDuration,
- customPosterUrl: customPosterInfo && customPosterInfo.after && customPosterInfo.after.imagePath || '',
- userInfo: {
- nickName: userInfo.nickName,
- avatarUrl: userInfo.avatarUrl
- },
- rewardType: baseFormData.rewardType,
- customizedReward: baseFormData.customizedReward,
- upGainAmountUsdValue: upGainAmountUsdValue
- }"
- :show="installStatus"></custom-card-cover>
- </div>
- </div>
- </div>
- <!-- 安装之前的卡片样式 -->
- <div class="content-before"
- v-show="!installStatus"
- :style="{'width': (baseFormData.rewardType === RewardType.money) ? `${reviewCanvasParams.width}px` : '100%'}">
- <div class="head"
- :style="{'zoom': reviewCanvasParams.zoom}">
- <img :src="userInfo.avatarUrl"
- class="avatar"/>
- <div class="article-wrapper">
- <div class="nickname">
- {{userInfo.name}}
- </div>
- <div class="name">
- @{{userInfo.nickName}}
- </div>
- </div>
- </div>
- <div
- :style="{'zoom': baseFormData.rewardType === RewardType.money ? reviewCanvasParams.zoom : 1}">
- <custom-card-horizontal-cover
- :class="baseFormData.rewardType === RewardType.money ? '' : 'custom-prize-card-wrapper'"
- :data="{
- totalCount: baseFormData.totalCount,
- amountValue: baseFormData.amountValue,
- usdEstimateOrderAmount: baseFormData.usdEstimateOrderAmount,
- tokenSymbol: currentCurrencyInfo.tokenSymbol,
- currencyCode: currentCurrencyInfo.currencyCode,
- currencyIconUrl: currentCurrencyInfo.iconPath,
- type: baseFormData.type,
- validityDuration: baseFormData.validityDuration,
- customPosterUrl: customPosterInfo && customPosterInfo.before && customPosterInfo.before.imagePath || '',
- addFans: baseFormData.addFans,
- userInfo: {
- nickName: userInfo.nickName,
- avatarUrl: userInfo.avatarUrl
- },
- rewardType: baseFormData.rewardType,
- customizedReward: baseFormData.customizedReward,
- upGainAmountUsdValue: upGainAmountUsdValue
- }">
- </custom-card-horizontal-cover>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script setup>
- import { ref, defineProps, onMounted, nextTick, watch, reactive, inject, onUnmounted } from "vue";
- import customCardCover from '@/view/components/custom-card-cover.vue'
- import customCardHorizontalCover from '@/view/components/custom-card-horizontal-cover.vue'
- import {getChromeStorage} from "@/uilts/chromeExtension"
- import { getUser } from "@/http/publishApi"
- import { RewardType } from '@/types';
- let userInfo = ref({});
- let reviewCanvasParams = reactive({
- width: 396,
- zoom: 1
- });
- let timer = ref(null);
- let installStatus = inject('installStatus');
- defineProps({
- postData: {
- type: Object,
- default: () => {
- return {
- }
- }
- },
- baseFormData: {
- type: Object,
- default: () => {
- return {
- }
- }
- },
- currentCurrencyInfo: {
- type: Object,
- default: () => {
- return {
- }
- }
- },
- amountFontSize: {
- type: Number,
- default: '56'
- },
- customPosterInfo: {
- type: Object,
- default: () => {
- return {
- }
- }
- },
- upGainAmountUsdValue: {
- type: String,
- default: ''
- }
- })
- const getUserInfo = (cb) => {
- getChromeStorage('userInfo', (res) => {
- if(res) {
- userInfo.value = res;
- }
- cb && cb(res);
- })
- }
- const getUserName = (screenName) => {
- getUser({
- params:{
- screenName
- }
- }).then(res => {
- console.log(res);
- if(res.code == 0) {
- userInfo.value.name = res.data.name || ''
- }
- });
- }
- const calcPreviewCanvasParams = () => {
- nextTick(() => {
- let containerDom = document.querySelector('.card-container');
- let domHeight = containerDom && containerDom.offsetHeight || 500;
- const canvasHeight = 820, canvasWidth = 600;
- if(domHeight < canvasHeight) {
- //比例: 高 / 宽
- let hWRatio = canvasHeight / canvasWidth;
- //缩小宽度 = 高度 / 比例
- let width = domHeight / hWRatio;
- if(width > canvasWidth) {
- width = canvasWidth;
- }
- //缩小比例
- let zoom = width / canvasWidth;
- if(zoom > 1) {
- zoom = 1;
- }
- reviewCanvasParams.width = width;
- reviewCanvasParams.zoom = zoom;
- } else {
- reviewCanvasParams.width = canvasWidth;
- reviewCanvasParams.zoom = 1;
- }
- });
- }
- onMounted(() => {
- calcPreviewCanvasParams();
- getUserInfo((res) => {
- if(res) {
- getUserName(res.nickName);
- }
- clearInterval(timer.value);
- timer.value = setInterval(() => {
- installStatus.value = !installStatus.value;
- }, 3000)
- });
- window.addEventListener('resize',function () {
- calcPreviewCanvasParams();
- })
- })
- onUnmounted(() => {
- clearInterval(timer.value);
- })
- </script>
- <style lang="scss" scoped>
- .wrapper {
- width: 100%;
- height: 100%;
- box-sizing: border-box;
- overflow-y: auto;
- display: flex;
- &::-webkit-scrollbar {
- display: none;
- }
- .card-container {
- width: 100%;
- height: 100%;
- background: #ffffff;
- box-sizing: border-box;
- border-radius: 20px;
- display: flex;
- align-items: center;
- .preview-txt {
- width: 238px;
- font-weight: 600;
- font-size: 22px;
- span {
- color: #1D9BF0;
- }
- }
- .head {
- position: absolute;
- z-index: 1100;
- top: 132px;
- left: 17px;
- display: flex;
- .avatar {
- width: 47px;
- height: 47px;
- border-radius: 50%;
- object-fit: cover;
- margin-right: 13px;
- }
- .article-wrapper {
- display: flex;
- .nickname {
- font-weight: 500;
- }
- .nickname, .name {
- font-size: 15px;
- }
- .name {
- color: #566370;
- margin-left: 7px;
- }
- .desc {
- margin-top: 8px;
- }
- }
- }
- .left {
- background: url('@/assets/img/img-preview-bg-after.png');
- width: 387px;
- height: 100%;
- background-size: contain;
- background-repeat: no-repeat;
- .tips {
- right: 15px !important;
- }
- }
- .after-cover-wrapper-parent {
- position: absolute;
- z-index: 100;
- top: 223px;
- left: 78px;
- }
- .after-cover-wrapper {
- position:relative;
- width:375px;
- .icon-gif {
- position: absolute;
- left: 50%;
- bottom: 80px;
- transform: translateX(-50%);
- width: 160px;
- height: 190px;
- }
- .content-after {
- width: 350px;
- border-radius: 16px;
- display: block;
- object-fit: contain;
- }
- }
- .content-before {
- background: url('@/assets/img/img-preview-bg-before.png');
- background-size: contain;
- background-repeat: no-repeat;
- height: 100%;
- .custom-prize-card-wrapper {
- width: 370px;
- left: 56px;
- top: 170px;
- }
- }
- .left, .content-before {
- position: relative;
- }
- }
- .select-btn-wrapper {
- padding-right: 16px;
- box-sizing: border-box;
- .title {
- font-size: 14px;
- margin-bottom: 15px;
- }
- .select-btn {
- margin-bottom: 16px;
- box-sizing: border-box;
- cursor: pointer;
- .icon {
- width: 14px;
- height: 14px;
- margin-right: 8px;
- }
- .text {
- font-size: 14px;
- display: flex;
- align-items: center;
- }
- .desc {
- white-space: nowrap;
- font-weight: 500;
- font-size: 13px;
- margin-left: 22px;
- }
- }
- .active {
- color: #000;
- }
- }
- }
- </style>
|