index.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <script setup lang="ts">
  2. // const myLucky = ref<any>(null)
  3. // const prizes = [
  4. // { background: '#e9e8fe', fonts: [{ text: '0' }] },
  5. // { background: '#b8c5f2', fonts: [{ text: '1' }] },
  6. // { background: '#e9e8fe', fonts: [{ text: '2' }] },
  7. // { background: '#b8c5f2', fonts: [{ text: '3' }] },
  8. // ]
  9. // const blocks = [{ padding: '10px', background: '#869cfa' }]
  10. // const defaultConfig = ref<any>([{
  11. // gutter: '5px',
  12. // offsetDegree: 10,
  13. // }])
  14. // const buttons = [
  15. // { radius: '40%', background: '#617df2' },
  16. // { radius: '35%', background: '#afc8ff' },
  17. // {
  18. // radius: '30%',
  19. // background: '#869cfa',
  20. // pointer: true,
  21. // fonts: [{ text: '开始', top: '-10px' }],
  22. // },
  23. // ]
  24. // // 点击抽奖按钮会触发star回调
  25. // function startCallback() {
  26. // console.log(myLucky?.value)
  27. // // 调用抽奖组件的play方法开始游戏
  28. // myLucky?.value?.play()
  29. // // 模拟调用接口异步抽奖
  30. // setTimeout(() => {
  31. // // 假设后端返回的中奖索引是0
  32. // const index = 1
  33. // // 调用stop停止旋转并传递中奖索引
  34. // defaultConfig.value = [{
  35. // gutter: '5px',
  36. // offsetDegree: 90,
  37. // }]
  38. // myLucky?.value?.stop(index)
  39. // }, 3000)
  40. // console.log(myLucky?.value?.stop, 'myLucky?.value?.stop')
  41. // }
  42. // // 抽奖结束会触发end回调
  43. // function endCallback(prize: any) {
  44. // console.log(prize)
  45. // }
  46. </script>
  47. <template>
  48. <div>
  49. <!-- <LuckyWheel -->
  50. <!-- ref="myLucky" -->
  51. <!-- width="300px" -->
  52. <!-- height="300px" -->
  53. <!-- :prizes="prizes" -->
  54. <!-- :blocks="blocks" -->
  55. <!-- :buttons="buttons" -->
  56. <!-- @start="startCallback" -->
  57. <!-- @end="endCallback" -->
  58. <!-- :default-config="defaultConfig[0]" -->
  59. <!-- /> -->
  60. </div>
  61. </template>
  62. <style scoped lang="scss"></style>