You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

291 lines
6.8 KiB

1 month ago
4 weeks ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
4 weeks ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
4 weeks ago
1 month ago
1 month ago
4 weeks ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
4 weeks ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
4 weeks ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
4 weeks ago
1 month ago
4 weeks ago
1 month ago
  1. <script setup>
  2. import { ref, onBeforeMount,onMounted } from 'vue'
  3. import jiantou from '../assets/img/jiantou.png'
  4. const showPopup = ref(false);
  5. const popupMessage = ref('');
  6. const totalScore = ref(4000) // 初始分数
  7. const myLucky = ref()
  8. // 新增变量记录基础分数
  9. //const baseScore = 4000
  10. const wheelConfig = ref({
  11. })
  12. const prizes = ref([
  13. { fonts: [{ text: '-199', top: '10%', fontColor: '#FF2C29', fontSize: '40px' }], background: '#FAF9F0' }, //0
  14. { fonts: [{ text: '-55', top: '10%', fontColor: '#FF2C29', fontSize: '40px' }], background: '#F5D7AD' }, //1
  15. { fonts: [{ text: '+200', top: '10%', fontColor: '#FF2C29', fontSize: '40px' }], background: '#FAF9F0' }, //2
  16. { fonts: [{ text: '-88', top: '10%', fontColor: '#FF2C29', fontSize: '40px' }], background: '#F5D7AD' }, //3
  17. { fonts: [{ text: '-11', top: '10%', fontColor: '#FF2C29', fontSize: '40px' }], background: '#FAF9F0' }, //4
  18. { fonts: [{ text: '-299', top: '10%', fontColor: '#FF2C29', fontSize: '40px' }], background: '#F5D7AD' }, //5
  19. { fonts: [{ text: '+200', top: '10%', fontColor: '#FF2C29', fontSize: '40px' }], background: '#FAF9F0' }, //6
  20. { fonts: [{ text: '-66', top: '10%', fontColor: '#FF2C29', fontSize: '40px' }], background: '#F5D7AD' }, //7
  21. ])
  22. const blocks = ref([{ padding: '13px', background: ' #FF2A00' }])
  23. const buttons = ref([{
  24. radius: '35%',
  25. imgs: [{
  26. src: jiantou,
  27. width: '100%',
  28. top: '-130%'
  29. }],
  30. //background: '#8a9bf3',
  31. pointer: true,
  32. }])
  33. //自定义数组
  34. const customOrder = ref([0, 4, 3, 1, 2, 4, 5, 7, 3, 4, 0])
  35. let orderIndex = 0;
  36. function startCallback() {
  37. // 重置为初始分数
  38. //totalScore.value = baseScore
  39. // 调用抽奖组件的play方法开始游戏
  40. myLucky.value.play()
  41. // 模拟调用接口异步抽奖
  42. setTimeout(() => {
  43. //
  44. console.log(orderIndex, 'orderIndex')
  45. const index = orderIndex
  46. console.log(customOrder.value[index], 'custome')
  47. // 调用stop停止旋转并传递中奖索引
  48. myLucky.value.stop(customOrder.value[index])
  49. //更新指针(循环)
  50. orderIndex = (index + 1) % customOrder.value.length;
  51. }, 3000)
  52. }
  53. const scoreAnimation = ref(false)
  54. // 抽奖结束end回调
  55. function endCallback(prize) {
  56. const result = Number(prize.fonts[0].text)
  57. console.log(prize.fonts[0].text)
  58. // 更新总分
  59. totalScore.value = totalScore.value + result
  60. // 触发动画
  61. animateScoreChange()
  62. // 先清空文字
  63. popupMessage.value = "";
  64. showPopup.value = true;
  65. // 设置弹窗内容
  66. setTimeout(() => {
  67. popupMessage.value= `${result}金币`;
  68. }, 1000); // <--- 正确的用法
  69. showPopup.value = true;
  70. // 3秒后隐藏弹窗
  71. setTimeout(() => {
  72. showPopup.value = false;
  73. }, 3000);
  74. }
  75. // 添加分数变化动画方法
  76. const animateScoreChange = () => {
  77. scoreAnimation.value = true
  78. setTimeout(() => {
  79. scoreAnimation.value = false
  80. }, 3000)
  81. }
  82. onMounted(() => {
  83. console.log(import.meta.env.MODE,'1111')
  84. console.log(process.env.NODE_ENV,'2222')
  85. })
  86. </script>
  87. <template>
  88. <div class="full-background">
  89. <!-- <img :src="jiantou" alt="111"> -->
  90. <div class="art-text" :class="{ 'score-change': scoreAnimation }">
  91. {{ totalScore }}金币
  92. </div>
  93. <div class="luckyWheel">
  94. <LuckyWheel class="lucky" ref="myLucky" width="434px" height="434px" :default-config="wheelConfig"
  95. :prizes="prizes" :blocks="blocks" :buttons="buttons" @start="startCallback" @end="endCallback" />
  96. </div>
  97. <div class="full-background">
  98. <!-- 其他原有代码不变 -->
  99. </div>
  100. <div class="wheel-base">
  101. </div>
  102. <transition name="popup-fade">
  103. <div v-if="showPopup" class="score-popup" :class="{ 'boom-effect': showPopup }">
  104. <!-- <div class="score-popup" :class="{ 'boom-effect': showPopup }"> -->
  105. <div class="ziti">
  106. {{ popupMessage }}
  107. </div>
  108. </div>
  109. </transition>
  110. </div>
  111. </template>
  112. <style scoped>
  113. /* 爆炸动画关键帧 */
  114. @keyframes boom {
  115. 0% {
  116. transform: translate(-50%, -50%) scale(0);
  117. opacity: 0;
  118. }
  119. 50% {
  120. transform: translate(-50%, -50%) scale(1.2);
  121. opacity: 1;
  122. }
  123. 100% {
  124. transform: translate(-50%, -50%) scale(1);
  125. opacity: 1;
  126. }
  127. }
  128. .score-popup {
  129. /* 基础样式同上 */
  130. position: fixed;
  131. left: 50%;
  132. top: 45%;
  133. transform: translate(-50%, -50%);
  134. z-index: 1000;
  135. /* 背景图配置 */
  136. background:
  137. url('/public/tanchuang.png') center/contain no-repeat;
  138. padding: 120px 80px;
  139. /* 根据图片留出边距 */
  140. /* 尺寸控制 */
  141. width: 800px;
  142. height: 1000px;
  143. display: flex;
  144. justify-content: center;
  145. align-items: center;
  146. }
  147. .score-popup::before {
  148. background: rgba(255, 215, 0, 0.1);
  149. }
  150. .ziti {
  151. /* 文字样式 */
  152. font-family: '华康金文体', 'Arial Black', sans-serif;
  153. font-size: 100px;
  154. /* 根据图片调整字号 */
  155. color: #ffd904;
  156. /* 金色文字 */
  157. line-height: 250px;
  158. /* 垂直居中文字 */
  159. text-shadow: 2px 2px 0 #B8860B;
  160. /* 略微加粗文字 */
  161. margin-bottom: 100px;
  162. }
  163. /* 添加艺术字样式 */
  164. .art-text {
  165. position: fixed;
  166. left: 30%;
  167. bottom: 20%;
  168. transform: translateX(-50%);
  169. font-family: 'Arial Black', sans-serif;
  170. font-size: 150px;
  171. color: #FFD700;
  172. /* 金色 */
  173. text-shadow:
  174. 3px 3px 0 #FF0000,
  175. /* 红色描边 */
  176. -1px -1px 0 #000,
  177. 1px -1px 0 #000,
  178. -1px 1px 0 #000,
  179. 1px 1px 0 #000;
  180. transition: transform 0.3s ease;
  181. z-index: 1000;
  182. }
  183. /* 添加分数变化动画 */
  184. .score-change {
  185. transform: translateX(-50%) scale(1.2);
  186. color: hwb(69 0% 0%);
  187. /* 变化时的橙色 */
  188. }
  189. .full-background {
  190. background-image: url('/public/bg.png');
  191. background-size: cover;
  192. background-repeat: no-repeat;
  193. background-position: center;
  194. width: 100vw;
  195. height: 100vh;
  196. position: fixed;
  197. top: 0;
  198. left: 0;
  199. z-index: 0;
  200. }
  201. .custom-text {
  202. position: fixed;
  203. left: 300px;
  204. bottom: 200px;
  205. color: black;
  206. font-size: 150px;
  207. z-index: 999;
  208. }
  209. .luckyWheel {
  210. position: fixed;
  211. z-index: 999;
  212. left: 1140px;
  213. top: 443px;
  214. pointer-events: auto;
  215. }
  216. /* 转盘底的样式 */
  217. .wheel-base {
  218. background-image: url('/public/wheel-base.png');
  219. position: fixed;
  220. left: 1065px;
  221. top: 350px;
  222. width: 568px;
  223. height: 600px;
  224. z-index: 990;
  225. }
  226. .luckyWheel .lucky {
  227. aspect-ratio: 1/1;
  228. color: aqua;
  229. }
  230. h1 {
  231. position: relative;
  232. z-index: 1;
  233. text-align: center;
  234. /* 居中标题 */
  235. width: 100%;
  236. top: 50px;
  237. /* 让标题占据整个宽度 */
  238. font-size: 100px;
  239. /* 文字大小 */
  240. }
  241. </style>