123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684 |
- <template>
- <div class="content">
- <!-- open -->
- <div v-if="data.status == 'opened'" class="opened">
- <div class="header">
- <div class="title">Awesome! You Will Get</div>
- <div class="money">
- <img :src="require('../assets/svg/icon-dollar.svg')" alt />
- <span class="big">{{ data.money / 100 }}</span>
- <span class="small">{{ data.detail.amountCurrencyCode || '' }}</span>
- </div>
- </div>
- <div class="list">
- <div class="item" v-for="item, i in data.detail.taskCondition" v-bind:key="i">
- <template v-if="item.type == 1">
- <img :src="require('../assets/svg/icon-follow.svg')" alt />
- <div class="item-content">
- <div class="item-title">Follow</div>
- <span v-for="item2, i in item.relatedUsers" v-bind:key="i">@{{ item2.name }}</span>
- </div>
- <div class="btn">Follow</div>
- </template>
- <template v-if="item.type == 2">
- <img :src="require('../assets/svg/icon-like.svg')" alt />
- <div class="item-content">
- <div class="item-title">Like</div>
- </div>
- <div class="btn">Like</div>
- </template>
- <template v-if="item.type == 3">
- <img :src="require('../assets/svg/icon-retweet.svg')" alt />
- <div class="item-content">
- <div class="item-title">Retweet</div>
- </div>
- <div class="btn">Retweet</div>
- </template>
- </div>
- </div>
- <div class="people" @click="clickRoad">
- <div
- class="txt"
- >Total ${{ data.detail.amountValue }} USD,{{ data.detail.finishCount || 0 }}/{{ data.detail.totalCount || 0 }} People Got</div>
- <div class="right">
- <img :src="require('../assets/svg/icon-dollar.svg')" alt />
- <img :src="require('../assets/svg/icon-dollar.svg')" alt />
- <img :src="require('../assets/svg/icon-dollar.svg')" alt />
- <img :src="require('../assets/svg/icon-right.svg')" alt class="road" />
- </div>
- </div>
- <div class="footer">
- <div class="first">
- <div class="validity">Validity</div>
- <div class="time">{{ data.detail.validity || '' }}</div>
- </div>
- <div class="btn" @click="clickGetGiveways">Get Giveaways</div>
- </div>
- </div>
- <!-- success -->
- <div v-else-if="data.status == 'success'" class="success">
- <div class="header">
- <div class="money">
- <img :src="require('../assets/svg/icon-dollar.svg')" alt />
- <span class="big">{{ data.money / 100 }}</span>
- <span class="small">USD</span>
- </div>
- </div>
- <div class="luck-list-title">
- <div>{{ data.detail.finishCount || 0 }}/{{ data.detail.totalCount || 0 }} People Got</div>
- <div>Total ${{ data.detail.amountValue || '' }} {{ data.detail.amountCurrencyCode || '' }}</div>
- </div>
- <div class="luck-list">
- <div class="luck-item" v-for="item, i in data.detail.allReceived" v-bind:key="i">
- <img :src="item.simpleUserInfoVO.avatarUrl" alt />
- <div class="luck-content">
- <div class="luck-title">{{ item.simpleUserInfoVO.nickName }}</div>
- <div class="luck-time">{{ moment(item.finishTimestamp).format('MM-DD hh:mm:ss') }}</div>
- </div>
- <div class="luck-money">
- <img :src="require('../assets/svg/icon-dollar.svg')" alt />
- <div class="luck-money-txt">{{ showLastTwoPlace(item.amountValue) || 0 }}</div>
- </div>
- <div class="luck-king" v-if="item.isMaxAmount">
- <img :src="require('../assets/svg/icon-king-hat.svg')" alt />
- <span>Luckiest Draw</span>
- </div>
- </div>
- </div>
- </div>
- <!-- no-open -->
- <div v-else-if="data.status == 'not-open'" class="not-open">
- <img :src="require('../assets/img/up.png')" alt class="up" />
- <img :src="require('../assets/img/down.png')" alt class="down" />
- <div class="open" @click="clickOpenRedPacket">OPEN</div>
- </div>
- <!-- 领取列表 -->
- <div v-else-if="data.status == 'luck-peopel-list'" class="luck-peopel-list">
- <div class="head">
- <img :src="require('../assets/svg/icon-back.svg')" alt @click="clickBack" />
- </div>
- <div class="luck-list-title">
- <div>{{ data.detail.finishCount || 0 }}/{{ data.detail.totalCount || 0 }} People Got</div>
- <div>Total ${{ data.detail.amountValue || 0 }} {{ data.detail.amountCurrencyCode || '' }}</div>
- </div>
- <div class="luck-list">
- <div class="luck-item" v-for="item, i in data.detail.allReceived" v-bind:key="i">
- <img :src="item.simpleUserInfoVO.avatarUrl" alt />
- <div class="luck-content">
- <div class="luck-title">{{ item.simpleUserInfoVO.nickName }}</div>
- <div class="luck-time">{{ moment(item.finishTimestamp).format('MM-DD hh:mm:ss') }}</div>
- </div>
- <div class="luck-money">
- <img :src="require('../assets/svg/icon-dollar.svg')" alt />
- <div class="luck-money-txt">{{ showLastTwoPlace(item.amountValue) }}</div>
- </div>
- <div class="luck-king" v-if="item.isMaxAmount">
- <img :src="require('../assets/svg/icon-king-hat.svg')" alt />
- <span>Luckiest Draw</span>
- </div>
- </div>
- </div>
- </div>
- <!-- 红包被领完了 -->
- <div v-else-if="data.status == 'close'" class="close">
- <div class="header">
- <div class="close-title">{{ data.close_title }}</div>
- </div>
- <div class="luck-list-title">
- <div>{{ data.detail.finishCount || 0 }}/{{ data.detail.totalCount || 0 }} People Got</div>
- <div>Total ${{ data.detail.amountValue || 0 }} {{ data.detail.amountCurrencyCode || '' }}</div>
- </div>
- <div class="luck-list">
- <div class="luck-item" v-for="item, i in data.detail.allReceived" v-bind:key="i">
- <img :src="item.simpleUserInfoVO.avatarUrl" alt />
- <div class="luck-content">
- <div class="luck-title">{{ item.simpleUserInfoVO.nickName }}</div>
- <div class="luck-time">{{ moment(item.finishTimestamp).format('MM-DD hh:mm:ss') }}</div>
- </div>
- <div class="luck-money">
- <img :src="require('../assets/svg/icon-dollar.svg')" alt />
- <div class="luck-money-txt">{{ showLastTwoPlace(item.amountValue) || 0 }}</div>
- </div>
- <div class="luck-king" v-if="item.isMaxAmount">
- <img :src="require('../assets/svg/icon-king-hat.svg')" alt />
- <span>Luckiest Draw</span>
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- export default {
- name: 'redPacket',
- }
- </script>
- <script setup>
- /* eslint-disable */
- import { onMounted, reactive } from "vue";
- import { getPostDetail, getRedPacket, finishRedPacket } from '../http/redPacket.js'
- import { getQueryString } from '../uilts/help.js'
- var moment = require('moment');
- let data = reactive({
- status: '',
- detail: {},
- close_title: 'Better luck next time!',
- receiveAmount: 0,
- money: 0
- })
- function getValidity() {
- let timer = setInterval(() => {
- let _time = new Date().getTime()
- if (data.detail.endTimestamp - _time > 0) {
- data.detail.validity = moment(data.detail.endTimestamp - _time).format('HH:mm:ss')
- } else {
- clearInterval(timer)
- }
- }, 1000)
- }
- function showLastTwoPlace(n) {
- return n / 100
- // n = n / 100
- // let _s = n
- // // 如果是整数
- // if (Math.floor(n) === n) {
- // _s = n + '.00'
- // return _s
- // }
- // // 如果小数只有一位
- // if (_s.split('.')[1].length > 2) {
- // _s = _s + '0'
- // return _s
- // }
- // return _s
- }
- function init() {
- getPostDetail({
- params: {
- postId: data.postId
- }
- }).then((res) => {
- switch (res.code.toString()) {
- case "0":
- // 未开始
- if (res.data.postType == 0) {
- data.status = 'not-open'
- }
- // 进行中
- if (res.data.postType == 1) {
- data.status = 'opened'
- data.detail = JSON.parse(res.data.postBizData)
- if (data.detail.myReceived) {
- data.status = 'opened'
- if (data.detail.myReceived.taskFinishStatus == 1) {
- data.status = 'success'
- }
- if (data.detail.myReceived.taskFinishStatus == 2) {
- data.status = 'close'
- data.close_title = res.msg
- }
- } else {
- data.status = 'not-open'
- }
- data.detail.taskCondition = JSON.parse(data.detail.taskCondition)
- data.detail.amountValue = showLastTwoPlace(data.detail.amountValue)
- data.detail.receiveAmountValue = showLastTwoPlace(data.detail.receiveAmountValue)
- data.money = data.detail.myReceived.amountValue
- console.log(data.detail)
- getValidity()
- }
- // 已结束
- if (res.data.postType == 2) {
- data.status = 'close'
- }
- break
- }
- })
- }
- onMounted(() => {
- data.postId = getQueryString('postId')
- init()
- })
- function clickOpenRedPacket() {
- getRedPacket({
- params: {
- postId: data.postId
- }
- }).then((res) => {
- switch (res.code.toString()) {
- case "0":
- data.status = 'opened'
- data.money = res.data.receiveAmount
- break
- case "2008":
- data.status = 'close'
- data.close_title = 'Better luck next time!'
- break
- }
- })
- }
- function clickGetGiveways() {
- finishRedPacket({
- params: {
- postId: data.postId
- }
- }).then((res) => {
- if (res.code != 0) {
- alert(res.msg)
- } else {
- if (res.data.finished) {
- data.status = 'success'
- data.receiveAmount = res.data.receiveAmount
- init()
- } else {
- let _data = res.data.conditionResult
- for (let i in _data) {
- if (!_data[i].finished) {
- switch (_data[i].type.toString()) {
- case '1':
- alert('关注未完成')
- break
- case '2':
- alert('喜欢未完成')
- break
- case '3':
- alert('转推未完成')
- break
- }
- }
- }
- }
- }
- })
- }
- function clickBack() {
- data.status = 'opened'
- }
- function clickRoad() {
- data.status = 'luck-peopel-list'
- }
- </script>
-
- <style lang="scss">
- html,
- body {
- margin: 0;
- padding: 0;
- }
- .content {
- width: 375px;
- height: 500px;
- background: #fafafa;
- border-radius: 11px;
- font-family: "SF Pro Display";
- font-style: normal;
- .success,
- .close,
- .luck-peopel-list {
- filter: drop-shadow(0px 4px 94px rgba(0, 0, 0, 0.3));
- width: 100%;
- height: 100%;
- border-radius: 11px;
- background: #fff;
- .close-title {
- font-weight: 600;
- font-size: 27px;
- line-height: 32px;
- text-align: center;
- letter-spacing: 0.3px;
- color: #ffffff;
- }
- .head {
- padding: 14px 16px;
- img {
- cursor: pointer;
- width: 24px;
- height: 24px;
- }
- }
- .header {
- text-align: center;
- height: 120px;
- width: 100%;
- background: #ef4545;
- padding-top: 30px;
- .title {
- color: #fff7e4;
- opacity: 0.6;
- font-weight: 700;
- font-size: 18px;
- line-height: 21px;
- letter-spacing: -0.3px;
- }
- .money {
- img {
- width: 40px;
- height: 40px;
- }
- .big {
- font-weight: 700;
- font-size: 46px;
- line-height: 55px;
- /* identical to box height */
- letter-spacing: 0.3px;
- color: #fff8e6;
- }
- .small {
- font-weight: 700;
- font-size: 13px;
- line-height: 16px;
- /* identical to box height */
- letter-spacing: 0.5px;
- color: #fff8e6;
- }
- }
- }
- .luck-list-title {
- padding: 0 16px;
- background: #fff;
- color: #9b9b9b;
- display: flex;
- justify-content: space-between;
- }
- .luck-list {
- background: #fff;
- .luck-item {
- display: flex;
- padding: 12px 16px;
- border-top: 1px solid #d1d1d1;
- justify-content: space-between;
- position: relative;
- img:first-child {
- border-radius: 50%;
- }
- .luck-king {
- position: absolute;
- top: 36px;
- right: 16px;
- display: flex;
- align-items: center;
- img {
- width: 22px;
- height: 19px;
- margin: 0;
- }
- span {
- font-weight: 500;
- font-size: 12px;
- line-height: 14px;
- letter-spacing: 0.3px;
- color: #f5b945;
- }
- }
- img {
- width: 42px;
- height: 42px;
- margin-right: 12px;
- }
- .luck-content {
- flex: auto;
- .luck-title {
- font-weight: 500;
- font-size: 16px;
- letter-spacing: 0.3px;
- color: #444444;
- }
- .luck-time {
- font-weight: 400;
- font-size: 12px;
- line-height: 14px;
- color: #9b9b9b;
- }
- }
- .luck-money {
- display: flex;
- height: 17px;
- align-items: center;
- img {
- width: 14px;
- height: 14px;
- margin-right: 6px;
- }
- .luck-money-txt {
- font-weight: 500;
- font-size: 14px;
- /* identical to box height */
- text-align: right;
- letter-spacing: 0.3px;
- color: #444444;
- }
- }
- }
- }
- }
- .opened {
- filter: drop-shadow(0px 4px 94px rgba(0, 0, 0, 0.3));
- width: 100%;
- height: 100%;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .header {
- text-align: center;
- height: 120px;
- width: 100%;
- background: #ef4545;
- padding-top: 30px;
- .title {
- color: #fff7e4;
- opacity: 0.6;
- font-weight: 700;
- font-size: 18px;
- line-height: 21px;
- letter-spacing: -0.3px;
- }
- .money {
- img {
- width: 40px;
- height: 40px;
- }
- .big {
- font-weight: 700;
- font-size: 46px;
- line-height: 55px;
- /* identical to box height */
- letter-spacing: 0.3px;
- color: #fff8e6;
- }
- .small {
- font-weight: 700;
- font-size: 13px;
- line-height: 16px;
- /* identical to box height */
- letter-spacing: 0.5px;
- color: #fff8e6;
- }
- }
- }
- .list {
- padding: 0 16px 0 16px;
- background: #ffffff;
- flex: 1;
- .item {
- display: flex;
- align-items: center;
- min-height: 50px;
- border-bottom: 1px solid #f0f0f0;
- img {
- width: 24px;
- height: 24px;
- }
- .item-content {
- flex: 1;
- .item-title {
- font-weight: 500;
- font-size: 16px;
- letter-spacing: 0.3px;
- color: #000000;
- }
- span {
- font-weight: 400;
- font-size: 11px;
- line-height: 13px;
- letter-spacing: 0.3px;
- color: #000000;
- opacity: 0.4;
- }
- }
- .btn {
- width: 72px;
- height: 29px;
- line-height: 29px;
- background: #389aff;
- border-radius: 500px;
- text-align: center;
- letter-spacing: 0.3px;
- color: #ffffff;
- cursor: pointer;
- }
- }
- .item:last-child {
- border: 0;
- }
- }
- .people {
- cursor: pointer;
- padding-left: 16px;
- height: 44px;
- line-height: 44px;
- background: #faf9f8;
- box-shadow: 0px 1px 0px #f2f2f2;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .txt {
- font-weight: 400;
- font-size: 12px;
- line-height: 14px;
- letter-spacing: 0.3px;
- color: #000000;
- opacity: 0.4;
- }
- .right {
- cursor: pointer;
- margin-right: 22px;
- display: flex;
- align-items: center;
- img {
- width: 22px;
- height: 22px;
- }
- }
- }
- .footer {
- background: #ffffff;
- display: flex;
- padding: 20px 22px 20px 17px;
- .first {
- flex: 1;
- .validity {
- font-weight: 400;
- font-size: 12px;
- line-height: 14px;
- letter-spacing: 0.3px;
- color: #000000;
- opacity: 0.4;
- margin: 2px 0 8px 0;
- }
- .time {
- font-weight: 500;
- font-size: 13px;
- line-height: 16px;
- /* identical to box height */
- color: #000000;
- }
- }
- .btn {
- background: #ef4545;
- border-radius: 100px;
- color: #fff;
- width: 258px;
- height: 52px;
- font-weight: 600;
- font-size: 18px;
- line-height: 52px;
- text-align: center;
- cursor: pointer;
- }
- }
- }
- .not-open {
- filter: drop-shadow(0px 4px 94px rgba(0, 0, 0, 0.3));
- position: relative;
- img {
- width: 100%;
- }
- .up {
- position: absolute;
- top: 0;
- box-shadow: 0px 4px 44px rgba(0, 0, 0, 0.1);
- z-index: 1;
- }
- .down {
- position: absolute;
- top: 253px;
- }
- .open {
- width: 110px;
- height: 110px;
- text-align: center;
- font-size: 26px;
- font-weight: 600;
- background: #ffe9b5;
- color: #ef4545;
- cursor: pointer;
- border-radius: 50%;
- line-height: 110px;
- position: absolute;
- top: 235px;
- left: 50%;
- margin-left: -55px;
- z-index: 2;
- }
- }
- }
- </style>
|