|
@@ -1,22 +1,22 @@
|
|
|
<template>
|
|
|
<view class="rive-ani" id="rive-ani" v-if="state.comVisable" >
|
|
|
- <view class="coin-total" >
|
|
|
+ <view class="coin-total" :style="{top: navbarInfo.top }" >
|
|
|
+ <span>{{wisdomCoinStore.total || 0}}</span>
|
|
|
<view class="coin-logo" id="coin-logo" :animation="state.heartbeatAni" >
|
|
|
<img :src="staticImg.coinTotal" alt="">
|
|
|
</view>
|
|
|
- <span>{{wisdomCoinStore.total}}</span>
|
|
|
</view>
|
|
|
- <view class="coin-ani" id="coin-ani" v-if="state.visible" >
|
|
|
- <view
|
|
|
- class="coin-item"
|
|
|
- v-for="item in state.cointCount"
|
|
|
- :key="item"
|
|
|
- :animation="state.animation[item - 1]"
|
|
|
- :id="`coin-item-${item}`"
|
|
|
- >
|
|
|
- <img :src="staticImg.coinAni" alt="" >
|
|
|
- </view>
|
|
|
- <view class="coin-count" id="coin-count" >+ {{state.cointCount}}</view>
|
|
|
+ <view class="coin-ani" id="coin-ani" v-if="state.visible" >
|
|
|
+ <view
|
|
|
+ class="coin-item"
|
|
|
+ v-for="item in state.cointCount"
|
|
|
+ :key="item"
|
|
|
+ :animation="state.animation[item - 1]"
|
|
|
+ :id="`coin-item-${item}`"
|
|
|
+ >
|
|
|
+ <img :src="staticImg.coinAni" alt="" >
|
|
|
+ </view>
|
|
|
+ <view class="coin-count" id="coin-count" >+ {{state.cointCount}}</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
@@ -25,8 +25,9 @@
|
|
|
<script setup lang="ts" name="rive " >
|
|
|
import { onMounted, ref, reactive, getCurrentInstance, defineExpose, nextTick} from 'vue'
|
|
|
import { Rive } from "@rive-app/canvas"
|
|
|
-import { useStaticImg, useQueryElInfo, useSchedulerOnce } from '@/hooks/index'
|
|
|
+import { useStaticImg, useQueryElInfo, useSchedulerOnce, useNavbarInfo } from '@/hooks/index'
|
|
|
import { useWisdomCoinStore } from '@/store'
|
|
|
+import { AudioController } from '@/controller/AudioController';
|
|
|
|
|
|
enum AniEnum {
|
|
|
'one',
|
|
@@ -50,7 +51,8 @@ interface State {
|
|
|
visible: boolean,
|
|
|
heartbeatAni: any,
|
|
|
cointCount: number,
|
|
|
- comVisable: boolean
|
|
|
+ comVisable: boolean,
|
|
|
+ cardType: 0 | 1
|
|
|
}
|
|
|
|
|
|
const state = reactive<Partial<State>>({
|
|
@@ -58,13 +60,16 @@ const state = reactive<Partial<State>>({
|
|
|
visible: false,
|
|
|
heartbeatAni: null,
|
|
|
cointCount: 0,
|
|
|
- comVisable: false
|
|
|
+ comVisable: false,
|
|
|
+ cardType: 0
|
|
|
})
|
|
|
|
|
|
const staticImg = useStaticImg()
|
|
|
|
|
|
const wisdomCoinStore = useWisdomCoinStore()
|
|
|
|
|
|
+const navbarInfo = useNavbarInfo()
|
|
|
+
|
|
|
const emit = defineEmits(['onEnd'])
|
|
|
|
|
|
const coinLoginRef = ref()
|
|
@@ -89,34 +94,35 @@ const initRive = () => {
|
|
|
|
|
|
const canvas = document.createElement('canvas')
|
|
|
|
|
|
- canvas.width = 1000
|
|
|
- canvas.height = 1000
|
|
|
+ canvas.width = 375
|
|
|
+ canvas.height = 375
|
|
|
|
|
|
canvas.id = 'rive-canvas'
|
|
|
|
|
|
canvas.style.position = 'absolute'
|
|
|
- canvas.style.top = '50%'
|
|
|
- canvas.style.left = '45%'
|
|
|
- canvas.style.transform = 'translate(-50%, -50%)'
|
|
|
|
|
|
document.getElementById('rive-ani')?.appendChild(canvas)
|
|
|
|
|
|
rive = new Rive({
|
|
|
- src: "https://res-game.luojigou.vip/coin1.riv",
|
|
|
+ src: "https://res-game.luojigou.vip/coin1234.riv",
|
|
|
canvas: canvas,
|
|
|
autoplay: false,
|
|
|
stateMachines: "bumpy",
|
|
|
- artboard: 'six-xing',
|
|
|
+ artboard: state.cardType === 0 ? 'si-xing' : 'six-xing',
|
|
|
onLoad: () => {
|
|
|
+
|
|
|
rive.resizeToCanvas()
|
|
|
- rive.play(AniEnum[state.cointCount!])
|
|
|
+ rive.play(AniEnum[state.cointCount! - 1])
|
|
|
+
|
|
|
+ // AudioController.playCoinLight()
|
|
|
+
|
|
|
},
|
|
|
onStop: () => {
|
|
|
fadeOutRive()
|
|
|
useSchedulerOnce(() => {
|
|
|
state.visible = true
|
|
|
- useSchedulerOnce(() => document.getElementById('coin-count')!.style.display = 'none', 800)
|
|
|
- useSchedulerOnce(() => goBezier(), 1000)
|
|
|
+ useSchedulerOnce(() => document.getElementById('coin-count')!.style.display = 'none', 1200)
|
|
|
+ useSchedulerOnce(() => goBezier(), 1400)
|
|
|
}, 1000)
|
|
|
|
|
|
}
|
|
@@ -127,12 +133,12 @@ const initRive = () => {
|
|
|
const createAnimationStep = (animation: UniApp.Animation, count: number) => {
|
|
|
|
|
|
for (let i = 0; i < count; i++) {
|
|
|
- state.animation.push(animation.step({duration: 1000 + i * 600}).export())
|
|
|
+ state.animation.push(animation.step({duration: 400 + i * 200}).export())
|
|
|
useSchedulerOnce(() => {
|
|
|
wisdomCoinStore.total ++
|
|
|
document.getElementById(`coin-item-${i + 1}`)!.style.display = 'none'
|
|
|
state.heartbeatAni = initHeartbeatAni()
|
|
|
- }, 1000 + i * 600)
|
|
|
+ }, 400 + i * 200)
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -152,7 +158,7 @@ const goBezier = () => {
|
|
|
});
|
|
|
|
|
|
animation
|
|
|
- .top(coinLoginRef.value.top)
|
|
|
+ .top(coinLoginRef.value.top )
|
|
|
.left(coinLoginRef.value.left)
|
|
|
.scale(0.25, 0.25)
|
|
|
|
|
@@ -167,9 +173,17 @@ const goBezier = () => {
|
|
|
|
|
|
}
|
|
|
|
|
|
-const start = (starCount: number) => {
|
|
|
+const start = (starCount: number, cardType: 0 | 1) => {
|
|
|
+
|
|
|
state.comVisable = true
|
|
|
state.cointCount = starCount
|
|
|
+ state.cardType = cardType
|
|
|
+
|
|
|
+ if (cardType === 0) {
|
|
|
+ starCount <= 2 ? AudioController.playFail() : AudioController.playPass()
|
|
|
+ } else {
|
|
|
+ starCount <= 3 ? AudioController.playFail() : AudioController.playPass()
|
|
|
+ }
|
|
|
useSchedulerOnce(initRive)
|
|
|
|
|
|
nextTick(() => useQueryElInfo('#coin-logo', (res) => coinLoginRef.value = res, getCurrentInstance()!, false))
|
|
@@ -186,8 +200,6 @@ defineExpose({
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
-
|
|
|
-
|
|
|
})
|
|
|
|
|
|
|
|
@@ -203,7 +215,7 @@ onMounted(() => {
|
|
|
top: 0;
|
|
|
left: 0;
|
|
|
z-index: 200;
|
|
|
- background-color: rgba(0,0,0,.2);
|
|
|
+ background-color: rgba(0,0,0, .6);
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
@@ -212,13 +224,13 @@ onMounted(() => {
|
|
|
background: #414141;
|
|
|
border-radius: 19px;
|
|
|
position: absolute;
|
|
|
- top: 18px;
|
|
|
right: 26px;
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
padding: 0 8px;
|
|
|
box-sizing: border-box;
|
|
|
.coin-logo {
|
|
|
+ margin-left: 6px;
|
|
|
img {
|
|
|
width: 20px;
|
|
|
height: 20px;
|
|
@@ -231,7 +243,7 @@ onMounted(() => {
|
|
|
font-family: PingFangSC-Semibold, PingFang SC;
|
|
|
font-weight: 600;
|
|
|
color: #FEFBFB;
|
|
|
- margin-left: 6px;
|
|
|
+
|
|
|
display: block;
|
|
|
}
|
|
|
}
|
|
@@ -249,6 +261,16 @@ onMounted(() => {
|
|
|
top: 50%;
|
|
|
left: 50%;
|
|
|
transform: translate(-50%, -50%);
|
|
|
+ animation: jelly 0.5s;
|
|
|
+ transform-origin: top center;
|
|
|
+ }
|
|
|
+ @keyframes jelly {
|
|
|
+ 0% {
|
|
|
+ scale: 0;
|
|
|
+ }
|
|
|
+ 100% {
|
|
|
+ scale: 1;
|
|
|
+ }
|
|
|
}
|
|
|
img {
|
|
|
width: 152rpx;
|