feat(custom): 增加背景音乐
This commit is contained in:
@@ -15,11 +15,27 @@ import zj from '../../../static/zj.json'
|
|||||||
import './index.scss'
|
import './index.scss'
|
||||||
|
|
||||||
Taro.useDidShow(() => {
|
Taro.useDidShow(() => {
|
||||||
|
startMusic('https://files.wanzhuanyongcheng.com/file/music/yaotouzi/3.mp3', true)
|
||||||
getUserInfo()
|
getUserInfo()
|
||||||
getBetList()
|
getBetList()
|
||||||
getList()
|
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<{
|
const user_info = ref<{
|
||||||
nickName: string
|
nickName: string
|
||||||
avatarUrl: string
|
avatarUrl: string
|
||||||
@@ -57,9 +73,7 @@ const timeStr = ref('')
|
|||||||
|
|
||||||
const getUserInfo = async () => {
|
const getUserInfo = async () => {
|
||||||
Taro.request({
|
Taro.request({
|
||||||
url: `${process.env.TARO_APP_AOSHI_API}/australia/user/info?uid=${Taro.getStorageSync(
|
url: `${process.env.TARO_APP_AOSHI_API}/australia/user/info?uid=${Taro.getStorageSync('uid')}`,
|
||||||
'uid'
|
|
||||||
)}`,
|
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
success: ({ data: res }) => {
|
success: ({ data: res }) => {
|
||||||
user_info.value = res.data.data || {}
|
user_info.value = res.data.data || {}
|
||||||
@@ -192,6 +206,10 @@ const startRun = (name: string) => {
|
|||||||
})
|
})
|
||||||
isRunning.value = true
|
isRunning.value = true
|
||||||
|
|
||||||
|
innerAudioContext.stop()
|
||||||
|
|
||||||
|
startMusic('https://files.wanzhuanyongcheng.com/file/music/yaotouzi/1.mp3', false)
|
||||||
|
|
||||||
turntable_list.value.forEach((item) => {
|
turntable_list.value.forEach((item) => {
|
||||||
item.isActive = false
|
item.isActive = false
|
||||||
})
|
})
|
||||||
@@ -362,10 +380,7 @@ const getBetJl = () => {
|
|||||||
<view class="user-box">
|
<view class="user-box">
|
||||||
<view class="avatar-box">
|
<view class="avatar-box">
|
||||||
<view class="bg"></view>
|
<view class="bg"></view>
|
||||||
<image
|
<image class="avatar" :src="user_info.avatarUrl || '../../../static/default_avatar.png'" />
|
||||||
class="avatar"
|
|
||||||
:src="user_info.avatarUrl || '../../../static/default_avatar.png'"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="user-info">
|
<view class="user-info">
|
||||||
<view class="name">{{ user_info.nickName }}</view>
|
<view class="name">{{ user_info.nickName }}</view>
|
||||||
@@ -380,11 +395,7 @@ const getBetJl = () => {
|
|||||||
<view class="kj-box">
|
<view class="kj-box">
|
||||||
<text class="title">第{{ list[0]?.preDrawIssue || 0 }}期已开奖</text>
|
<text class="title">第{{ list[0]?.preDrawIssue || 0 }}期已开奖</text>
|
||||||
<view class="num-box">
|
<view class="num-box">
|
||||||
<view
|
<view class="item" v-for="(item, index) in list[0]?.preDrawCode?.split(',')" :key="index">
|
||||||
class="item"
|
|
||||||
v-for="(item, index) in list[0]?.preDrawCode?.split(',')"
|
|
||||||
:key="index"
|
|
||||||
>
|
|
||||||
{{ Number(item) }}
|
{{ Number(item) }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -394,9 +405,7 @@ const getBetJl = () => {
|
|||||||
</view>
|
</view>
|
||||||
</view> -->
|
</view> -->
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view style="display: flex; justify-content: flex-end; flex-direction: column; margin-top: 6%">
|
||||||
style="display: flex; justify-content: flex-end; flex-direction: column; margin-top: 6%"
|
|
||||||
>
|
|
||||||
<view class="turntable-box">
|
<view class="turntable-box">
|
||||||
<view class="star star-1"></view>
|
<view class="star star-1"></view>
|
||||||
<view class="star star-2"></view>
|
<view class="star star-2"></view>
|
||||||
@@ -431,9 +440,7 @@ const getBetJl = () => {
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="countdown-box">
|
<view class="countdown-box">
|
||||||
<text class="title" v-if="!isRunning">
|
<text class="title" v-if="!isRunning">第{{ newKjNum }}期开奖还剩:{{ timeStr || '00' }}</text>
|
||||||
第{{ newKjNum }}期开奖还剩:{{ timeStr || '00' }}
|
|
||||||
</text>
|
|
||||||
<text v-else class="title">正在开奖中...</text>
|
<text v-else class="title">正在开奖中...</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="footer-box">
|
<view class="footer-box">
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import zj from '../../../static/zj.json'
|
|||||||
import './index.scss'
|
import './index.scss'
|
||||||
|
|
||||||
Taro.useDidShow(() => {
|
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()
|
getUserInfo()
|
||||||
getBetList()
|
getBetList()
|
||||||
getList()
|
getList()
|
||||||
@@ -437,10 +437,7 @@ onBeforeUnmount(() => {
|
|||||||
<view class="user-box">
|
<view class="user-box">
|
||||||
<view class="avatar-box">
|
<view class="avatar-box">
|
||||||
<view class="bg"></view>
|
<view class="bg"></view>
|
||||||
<image
|
<image class="avatar" :src="user_info.avatarUrl || '../static/default_avatar.png'" />
|
||||||
class="avatar"
|
|
||||||
:src="user_info.avatarUrl || '../static/default_avatar.png'"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="user-info">
|
<view class="user-info">
|
||||||
<view class="name">{{ user_info.nickName }}</view>
|
<view class="name">{{ user_info.nickName }}</view>
|
||||||
@@ -465,9 +462,7 @@ onBeforeUnmount(() => {
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view style="display: flex; justify-content: flex-end; flex-direction: column; margin-top: 6%">
|
||||||
style="display: flex; justify-content: flex-end; flex-direction: column; margin-top: 6%"
|
|
||||||
>
|
|
||||||
<view class="turntable-box">
|
<view class="turntable-box">
|
||||||
<view class="star star-1"></view>
|
<view class="star star-1"></view>
|
||||||
<view class="star star-2"></view>
|
<view class="star star-2"></view>
|
||||||
|
|||||||
Reference in New Issue
Block a user