feat(custom): 增加背景音乐

This commit is contained in:
2024-01-21 19:29:47 +08:00
parent 42687fd697
commit 1be8bca950
2 changed files with 714 additions and 712 deletions

View File

@@ -15,11 +15,27 @@ import zj from '../../../static/zj.json'
import './index.scss'
Taro.useDidShow(() => {
startMusic('https://files.wanzhuanyongcheng.com/file/music/yaotouzi/3.mp3', true)
getUserInfo()
getBetList()
getList()
})
const innerAudioContext = Taro.createInnerAudioContext()
const startMusic = (path: string, loop: boolean = false) => {
// const innerAudioContext = Taro.createInnerAudioContext()
innerAudioContext.autoplay = true
innerAudioContext.src = path
innerAudioContext.loop = loop
innerAudioContext.onPlay(() => {
console.log('开始播放')
})
innerAudioContext.onError(() => {
console.log('播放失败')
})
}
const user_info = ref<{
nickName: string
avatarUrl: string
@@ -57,9 +73,7 @@ const timeStr = ref('')
const getUserInfo = async () => {
Taro.request({
url: `${process.env.TARO_APP_AOSHI_API}/australia/user/info?uid=${Taro.getStorageSync(
'uid'
)}`,
url: `${process.env.TARO_APP_AOSHI_API}/australia/user/info?uid=${Taro.getStorageSync('uid')}`,
method: 'GET',
success: ({ data: res }) => {
user_info.value = res.data.data || {}
@@ -192,6 +206,10 @@ const startRun = (name: string) => {
})
isRunning.value = true
innerAudioContext.stop()
startMusic('https://files.wanzhuanyongcheng.com/file/music/yaotouzi/1.mp3', false)
turntable_list.value.forEach((item) => {
item.isActive = false
})
@@ -362,10 +380,7 @@ const getBetJl = () => {
<view class="user-box">
<view class="avatar-box">
<view class="bg"></view>
<image
class="avatar"
:src="user_info.avatarUrl || '../../../static/default_avatar.png'"
/>
<image class="avatar" :src="user_info.avatarUrl || '../../../static/default_avatar.png'" />
</view>
<view class="user-info">
<view class="name">{{ user_info.nickName }}</view>
@@ -380,11 +395,7 @@ const getBetJl = () => {
<view class="kj-box">
<text class="title">{{ list[0]?.preDrawIssue || 0 }}期已开奖</text>
<view class="num-box">
<view
class="item"
v-for="(item, index) in list[0]?.preDrawCode?.split(',')"
:key="index"
>
<view class="item" v-for="(item, index) in list[0]?.preDrawCode?.split(',')" :key="index">
{{ Number(item) }}
</view>
</view>
@@ -394,9 +405,7 @@ const getBetJl = () => {
</view>
</view> -->
</view>
<view
style="display: flex; justify-content: flex-end; flex-direction: column; margin-top: 6%"
>
<view style="display: flex; justify-content: flex-end; flex-direction: column; margin-top: 6%">
<view class="turntable-box">
<view class="star star-1"></view>
<view class="star star-2"></view>
@@ -431,9 +440,7 @@ const getBetJl = () => {
</view>
</view>
<view class="countdown-box">
<text class="title" v-if="!isRunning">
{{ newKjNum }}期开奖还剩:{{ timeStr || '00' }}
</text>
<text class="title" v-if="!isRunning">{{ newKjNum }}期开奖还剩:{{ timeStr || '00' }}</text>
<text v-else class="title">正在开奖中...</text>
</view>
<view class="footer-box">

View File

@@ -15,7 +15,7 @@ import zj from '../../../static/zj.json'
import './index.scss'
Taro.useDidShow(() => {
// startMusic('https://files.wanzhuanyongcheng.com/file/music/yaotouzi/3.mp3', true)
startMusic('https://files.wanzhuanyongcheng.com/file/music/yaotouzi/3.mp3', true)
getUserInfo()
getBetList()
getList()
@@ -437,10 +437,7 @@ onBeforeUnmount(() => {
<view class="user-box">
<view class="avatar-box">
<view class="bg"></view>
<image
class="avatar"
:src="user_info.avatarUrl || '../static/default_avatar.png'"
/>
<image class="avatar" :src="user_info.avatarUrl || '../static/default_avatar.png'" />
</view>
<view class="user-info">
<view class="name">{{ user_info.nickName }}</view>
@@ -465,9 +462,7 @@ onBeforeUnmount(() => {
</view>
</view>
</view>
<view
style="display: flex; justify-content: flex-end; flex-direction: column; margin-top: 6%"
>
<view style="display: flex; justify-content: flex-end; flex-direction: column; margin-top: 6%">
<view class="turntable-box">
<view class="star star-1"></view>
<view class="star star-2"></view>