2025-01-13 07:28:22 +00:00
|
|
|
|
<script setup>
|
2025-02-11 06:55:25 +00:00
|
|
|
|
import {ref, onMounted, onBeforeUnmount, watch} from 'vue'
|
2025-02-17 11:54:11 +00:00
|
|
|
|
import AliyunPlayer from 'aliyun-aliplayer'
|
2025-01-13 08:52:59 +00:00
|
|
|
|
import 'aliyun-aliplayer/build/skins/default/aliplayer-min.css'
|
2025-01-23 11:43:45 +00:00
|
|
|
|
import sideButton from '@/pages/liveRoom/components/SideButton/index.vue'
|
|
|
|
|
import broadcast from '@/pages/liveRoom/components/Broadcast/index.vue'
|
2025-02-11 03:34:24 +00:00
|
|
|
|
import {liveStore} from "@/stores/live/index.js"
|
2025-02-17 11:54:11 +00:00
|
|
|
|
import liveLoading from '@/components/liveLoading/index.vue'
|
2025-01-23 11:43:45 +00:00
|
|
|
|
import paymentResults from '@/pages/liveRoom/components/PaymentResults/index.vue'
|
|
|
|
|
import paymentInput from '@/pages/liveRoom/components/PaymentInput/index.vue'
|
2025-02-11 03:34:24 +00:00
|
|
|
|
import {goodStore} from "@/stores/goods/index.js"
|
|
|
|
|
import {message} from "~/components/x-message/useMessage.js"
|
2025-02-17 05:33:31 +00:00
|
|
|
|
import {showConfirmDialog} from 'vant';
|
2025-02-11 03:34:24 +00:00
|
|
|
|
import {artworkBuy} from "@/api/goods/index.js"
|
2025-02-12 06:34:05 +00:00
|
|
|
|
import {useI18n} from 'vue-i18n'
|
2025-02-17 06:50:28 +00:00
|
|
|
|
import {CountUp} from 'countup.js'
|
2025-02-17 07:18:55 +00:00
|
|
|
|
const { t } = useI18n()
|
2025-02-17 06:29:31 +00:00
|
|
|
|
const countUpRef = ref(null)
|
|
|
|
|
const nextPriceRef = ref(null)
|
2025-02-17 11:54:11 +00:00
|
|
|
|
const { auctionDetail} = goodStore();
|
2025-01-13 08:52:59 +00:00
|
|
|
|
const player = ref(null)
|
2025-02-17 05:33:31 +00:00
|
|
|
|
const {quoteStatus, show, playerId, show1, auctionData, getSocketData, getLiveLink, fullLive} = liveStore()
|
2025-02-11 06:55:25 +00:00
|
|
|
|
const pullLink = ref('')
|
2025-01-13 08:52:59 +00:00
|
|
|
|
const handlePlayerError = (error) => {
|
|
|
|
|
console.error('播放器错误:', error)
|
2025-02-24 07:39:20 +00:00
|
|
|
|
showConfirmDialog({
|
|
|
|
|
message: t('live_room.error_mess'),
|
|
|
|
|
showCancelButton: true
|
|
|
|
|
}).then(() => {
|
|
|
|
|
initializePlayer()
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
})
|
|
|
|
|
// player.value?.play()
|
2025-01-13 08:52:59 +00:00
|
|
|
|
}
|
2025-02-17 11:54:11 +00:00
|
|
|
|
const loading1=ref(false)
|
2025-02-11 06:55:25 +00:00
|
|
|
|
const initializePlayer = async () => {
|
2025-01-13 08:52:59 +00:00
|
|
|
|
try {
|
|
|
|
|
if (player.value) {
|
2025-02-11 06:55:25 +00:00
|
|
|
|
player.value.dispose()
|
2025-01-13 08:52:59 +00:00
|
|
|
|
}
|
2025-02-11 06:55:25 +00:00
|
|
|
|
|
2025-02-17 11:54:11 +00:00
|
|
|
|
// 判断是否是微信浏览器
|
|
|
|
|
const isWechat = /MicroMessenger/i.test(navigator.userAgent)
|
|
|
|
|
|
2025-02-11 03:34:24 +00:00
|
|
|
|
const playerConfig = {
|
|
|
|
|
id: playerId.value,
|
2025-02-11 06:55:25 +00:00
|
|
|
|
source: pullLink.value,
|
2025-02-11 03:34:24 +00:00
|
|
|
|
isLive: true,
|
|
|
|
|
preload: true,
|
2025-02-17 11:54:11 +00:00
|
|
|
|
autoplay: true, // 改为 true
|
|
|
|
|
muted: true, // 默认静音
|
2025-02-18 01:47:30 +00:00
|
|
|
|
diagnosisButtonVisible:false,
|
2025-02-24 07:39:20 +00:00
|
|
|
|
// vodRetry:10,
|
|
|
|
|
// liveRetry:10,
|
2025-02-13 07:23:50 +00:00
|
|
|
|
autoplayPolicy: {
|
2025-02-17 11:54:11 +00:00
|
|
|
|
fallbackToMute: true
|
2025-02-13 07:23:50 +00:00
|
|
|
|
},
|
2025-02-18 01:47:30 +00:00
|
|
|
|
width: '100%', //容器的大小
|
|
|
|
|
height: '100%', //容器的大小
|
2025-02-17 11:54:11 +00:00
|
|
|
|
skinLayout: false,
|
2025-02-11 03:34:24 +00:00
|
|
|
|
controlBarVisibility: 'never',
|
2025-02-18 01:47:30 +00:00
|
|
|
|
license: {
|
|
|
|
|
domain: "szjixun.cn",
|
|
|
|
|
key: "OProxmWaOZ2XVHXLtf4030126521c43429403194970aa8af9"
|
|
|
|
|
}
|
2025-02-11 03:34:24 +00:00
|
|
|
|
}
|
2025-02-17 11:54:11 +00:00
|
|
|
|
|
|
|
|
|
player.value = new AliyunPlayer(playerConfig, (playerInstance) => {
|
|
|
|
|
// 在微信环境下,需要用户手动触发播放
|
|
|
|
|
if (isWechat) {
|
|
|
|
|
const startPlay = () => {
|
|
|
|
|
playerInstance?.play()
|
|
|
|
|
document.removeEventListener('WeixinJSBridgeReady', startPlay)
|
|
|
|
|
document.removeEventListener('touchstart', startPlay)
|
|
|
|
|
}
|
|
|
|
|
document.addEventListener('WeixinJSBridgeReady', startPlay)
|
|
|
|
|
document.addEventListener('touchstart', startPlay)
|
|
|
|
|
}
|
|
|
|
|
loading1.value = true
|
2025-02-18 01:47:30 +00:00
|
|
|
|
playerInstance?.play()
|
2025-02-17 11:54:11 +00:00
|
|
|
|
})
|
|
|
|
|
player.value.on('playing', () => {
|
|
|
|
|
loading1.value = false
|
2025-02-18 01:47:30 +00:00
|
|
|
|
|
2025-02-17 11:54:11 +00:00
|
|
|
|
})
|
2025-02-24 07:39:20 +00:00
|
|
|
|
player.value.on('loading', () => {
|
|
|
|
|
console.log('loading')
|
|
|
|
|
})
|
2025-02-11 06:55:25 +00:00
|
|
|
|
player.value.on('error', handlePlayerError)
|
2025-01-13 08:52:59 +00:00
|
|
|
|
} catch (error) {
|
2025-02-12 02:58:47 +00:00
|
|
|
|
showConfirmDialog({
|
2025-02-17 07:18:55 +00:00
|
|
|
|
message: t('live_room.error_mess'),
|
2025-02-17 05:33:31 +00:00
|
|
|
|
showCancelButton: true
|
2025-02-11 07:58:35 +00:00
|
|
|
|
}).then(() => {
|
2025-02-24 07:39:20 +00:00
|
|
|
|
initializePlayer()
|
2025-02-17 05:33:31 +00:00
|
|
|
|
}).catch(() => {
|
2025-02-12 03:06:53 +00:00
|
|
|
|
})
|
2025-01-13 08:52:59 +00:00
|
|
|
|
console.error('播放器初始化失败:', error)
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-01-13 07:28:22 +00:00
|
|
|
|
|
2025-02-17 11:54:11 +00:00
|
|
|
|
|
2025-01-23 08:34:34 +00:00
|
|
|
|
onMounted(async () => {
|
2025-02-11 06:55:25 +00:00
|
|
|
|
pullLink.value = await getLiveLink()
|
2025-02-17 11:54:11 +00:00
|
|
|
|
if (auctionDetail.value.isLiving===1){
|
|
|
|
|
initializePlayer()
|
|
|
|
|
}
|
2025-01-13 08:52:59 +00:00
|
|
|
|
})
|
2025-02-11 03:34:24 +00:00
|
|
|
|
|
2025-01-13 07:28:22 +00:00
|
|
|
|
onBeforeUnmount(() => {
|
2025-02-11 06:55:25 +00:00
|
|
|
|
player.value?.dispose()
|
|
|
|
|
player.value = null
|
2025-01-13 08:52:59 +00:00
|
|
|
|
})
|
2025-02-17 06:29:31 +00:00
|
|
|
|
watch(() => fullLive.value, async (newVal) => {
|
|
|
|
|
if (!newVal) return
|
|
|
|
|
|
|
|
|
|
await getSocketData()
|
|
|
|
|
|
2025-02-17 11:54:11 +00:00
|
|
|
|
})
|
2025-02-11 03:34:24 +00:00
|
|
|
|
const goBuy = async () => {
|
|
|
|
|
const res = await artworkBuy({
|
|
|
|
|
auctionArtworkUuid: auctionData.value?.artwork?.uuid,
|
2025-02-20 06:47:57 +00:00
|
|
|
|
buyMoney: String(auctionData?.value.nowAuctionPrice?.nowPrice??0)
|
2025-02-08 07:21:00 +00:00
|
|
|
|
})
|
2025-02-11 03:34:24 +00:00
|
|
|
|
if (res.status === 0) {
|
2025-02-17 07:18:55 +00:00
|
|
|
|
message.success(t('live_room.success_mess'))
|
2025-02-08 07:21:00 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2025-02-11 03:34:24 +00:00
|
|
|
|
|
|
|
|
|
const tipOpen = () => {
|
2025-02-17 07:18:55 +00:00
|
|
|
|
message.warning(t('live_room.warn_mess'))
|
2025-02-10 07:47:26 +00:00
|
|
|
|
}
|
2025-01-13 07:28:22 +00:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2025-02-11 06:55:25 +00:00
|
|
|
|
<div class="relative h-full">
|
2025-02-11 03:34:24 +00:00
|
|
|
|
<div :id="playerId" class="w-full h-full"></div>
|
2025-02-24 07:39:20 +00:00
|
|
|
|
<div v-if="loading1" class="absolute left-1/2 transform translate-x--1/2 top-1/2 translate-y--1/2">
|
|
|
|
|
<van-loading type="spinner" >直播加载中...</van-loading>
|
|
|
|
|
</div>
|
2025-02-17 05:48:24 +00:00
|
|
|
|
<transition name="fade">
|
2025-02-11 07:27:31 +00:00
|
|
|
|
<div v-if="fullLive">
|
2025-02-11 06:55:25 +00:00
|
|
|
|
<sideButton class="absolute top-196px right-0 z-999"></sideButton>
|
2025-02-11 03:34:24 +00:00
|
|
|
|
<div class="absolute left-1/2 transform -translate-x-1/2 flex flex-col items-center"
|
|
|
|
|
style="bottom:calc(var(--safe-area-inset-bottom) + 26px)">
|
2025-02-17 06:50:28 +00:00
|
|
|
|
<div class="text-16px text-#FFB25F font-600 flex">
|
2025-02-17 07:18:55 +00:00
|
|
|
|
<div class="mr-5px">{{ t('live_room.now_price') }}:{{ auctionData?.nowAuctionPrice?.currency }}</div>
|
2025-02-20 11:03:39 +00:00
|
|
|
|
<div class="min-w-50px">{{auctionData?.nowAuctionPrice?.nowPrice}}</div>
|
2025-01-21 06:16:54 +00:00
|
|
|
|
</div>
|
2025-02-17 06:50:28 +00:00
|
|
|
|
<div class="text-16px text-#fff font-600 flex">
|
2025-02-17 07:18:55 +00:00
|
|
|
|
<div class="mr-5px">{{ t('live_room.lower_price') }}:{{ auctionData?.nowAuctionPrice?.currency }}</div>
|
2025-02-20 11:03:39 +00:00
|
|
|
|
<div class="min-w-50px">{{auctionData?.nowAuctionPrice?.nextPrice}}</div>
|
2025-01-21 06:16:54 +00:00
|
|
|
|
</div>
|
2025-02-19 13:03:54 +00:00
|
|
|
|
<div v-if="quoteStatus&&auctionData?.nowAuctionPrice?.nowPrice!=='0'" class="mt-10px mb-10px">
|
2025-02-24 06:05:49 +00:00
|
|
|
|
<van-button @click.stop="goBuy" color="#FFB25F" class="w-344px !h-[40px]">
|
2025-02-11 03:34:24 +00:00
|
|
|
|
<div>{{
|
2025-02-19 13:03:54 +00:00
|
|
|
|
`${t('live_room.confirm')} ${auctionData?.nowAuctionPrice?.currency} ${auctionData?.nowAuctionPrice?.nowPrice ?? 0}`
|
2025-02-17 05:33:31 +00:00
|
|
|
|
}}
|
|
|
|
|
</div>
|
2025-02-10 07:47:26 +00:00
|
|
|
|
</van-button>
|
|
|
|
|
</div>
|
2025-02-19 13:03:54 +00:00
|
|
|
|
<div v-else class="mt-10px mb-10px">
|
2025-02-17 07:18:55 +00:00
|
|
|
|
<van-button @click="tipOpen" color="#D6D6D8" class="w-344px !h-[40px]" >
|
|
|
|
|
<div class="text-#7D7D7F text-14px">{{ t('live_room.button') }}</div>
|
2025-02-10 07:47:26 +00:00
|
|
|
|
</van-button>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-01-21 06:16:54 +00:00
|
|
|
|
<broadcast></broadcast>
|
2025-01-13 12:59:25 +00:00
|
|
|
|
</div>
|
2025-02-11 07:39:22 +00:00
|
|
|
|
<paymentInput v-model:show="show"/>
|
2025-01-21 06:16:54 +00:00
|
|
|
|
<div>
|
2025-01-13 12:59:25 +00:00
|
|
|
|
</div>
|
2025-01-21 06:16:54 +00:00
|
|
|
|
<paymentResults v-model:show="show1" type="error"/>
|
2025-02-11 03:34:24 +00:00
|
|
|
|
<div v-if="auctionData?.wsType==='newArtwork'"
|
|
|
|
|
class="w-344px h-31px rounded-4px absolute top-9px bg-[#151824]/45 backdrop-blur-[10px] backdrop-saturate-[180%] left-1/2 transform translate-x--1/2 flex text-#fff text-14px items-center px-12px line-height-none">
|
|
|
|
|
<div class="mr-11px whitespace-nowrap">LOT{{ auctionData.artwork.index }}</div>
|
|
|
|
|
<div class="mr-10px truncate">{{ auctionData.artwork.name }}</div>
|
2025-02-17 07:18:55 +00:00
|
|
|
|
<div class="whitespace-nowrap">{{ t('live_room.start') }}</div>
|
2025-02-06 07:43:23 +00:00
|
|
|
|
</div>
|
2025-01-16 03:07:38 +00:00
|
|
|
|
</div>
|
2025-01-21 06:16:54 +00:00
|
|
|
|
</transition>
|
2025-01-13 07:28:22 +00:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
2025-02-11 06:55:25 +00:00
|
|
|
|
|
2025-02-17 05:48:24 +00:00
|
|
|
|
|
2025-02-18 01:47:30 +00:00
|
|
|
|
<style scoped lang="scss">
|
2025-02-17 05:48:24 +00:00
|
|
|
|
/* 定义过渡动画 */
|
2025-02-17 06:50:28 +00:00
|
|
|
|
.fade-enter-active {
|
2025-02-17 07:18:55 +00:00
|
|
|
|
transition: opacity 1s ease;
|
2025-01-21 06:16:54 +00:00
|
|
|
|
}
|
2025-01-16 03:07:38 +00:00
|
|
|
|
|
2025-02-17 05:48:24 +00:00
|
|
|
|
.fade-leave-active {
|
|
|
|
|
transition: opacity 0.2s ease;
|
|
|
|
|
}
|
2025-02-17 06:50:28 +00:00
|
|
|
|
|
2025-02-17 05:48:24 +00:00
|
|
|
|
/* 定义进入和离开的状态 */
|
|
|
|
|
.fade-enter-from,
|
|
|
|
|
.fade-leave-to {
|
2025-01-21 06:16:54 +00:00
|
|
|
|
opacity: 0;
|
|
|
|
|
}
|
2025-02-11 03:34:24 +00:00
|
|
|
|
|
2025-02-17 05:48:24 +00:00
|
|
|
|
.fade-enter-to,
|
|
|
|
|
.fade-leave-from {
|
|
|
|
|
opacity: 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-13 07:28:22 +00:00
|
|
|
|
.my-rolling-text {
|
|
|
|
|
--van-rolling-text-item-width: 10px;
|
|
|
|
|
--van-rolling-text-font-size: 16px;
|
|
|
|
|
--van-rolling-text-color: #FFB25F;
|
|
|
|
|
}
|
2025-01-13 08:52:59 +00:00
|
|
|
|
|
2025-01-13 07:28:22 +00:00
|
|
|
|
.my-rolling-text1 {
|
|
|
|
|
--van-rolling-text-item-width: 10px;
|
|
|
|
|
--van-rolling-text-font-size: 16px;
|
|
|
|
|
--van-rolling-text-color: #FFF;
|
|
|
|
|
}
|
2025-01-15 03:45:46 +00:00
|
|
|
|
|
|
|
|
|
:deep(.prism-license-watermark) {
|
|
|
|
|
display: none !important;
|
2025-01-13 12:59:25 +00:00
|
|
|
|
}
|
2025-01-13 07:28:22 +00:00
|
|
|
|
</style>
|