index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <app-view class="credit-lottery">
  3. <template #header>
  4. <app-navbar title="积分红包" />
  5. </template>
  6. <div class="credit-lottery__title">
  7. <img src="@mobile/assets/images/lottery/lottery-title.png" />
  8. </div>
  9. <div class="credit-lottery__container">
  10. <div class="credit-lottery__box credit-lottery__draw">
  11. <div class="block">
  12. <!-- <ul class="block-prize">
  13. <li>
  14. <span>一等奖</span>
  15. <span>现金红包</span>
  16. </li>
  17. <li>
  18. <span>二等奖</span>
  19. <span>现金红包</span>
  20. </li>
  21. <li>
  22. <span>谢谢参与</span>
  23. </li>
  24. </ul>
  25. <div class="block-button">
  26. <button type="button" @click="onSubmit">立即抽奖</button>
  27. </div> -->
  28. <div class="block-image" @click="onSubmit">
  29. <img src="@mobile/assets/images/lottery/lottery-hongbao.png" />
  30. </div>
  31. <div class="block-info">
  32. <span>当前积分:{{ userAccount.curscore ?? 0 }}</span>
  33. <span>*抽一次消耗{{ creditConfig.parma1 ?? 0 }}积分</span>
  34. </div>
  35. </div>
  36. </div>
  37. <div class="credit-lottery__box credit-lottery__record">
  38. <dl class="block">
  39. <dt class="block-title">- 我的红包 -</dt>
  40. <dd class="block-item" v-for="(item, index) in creditList" :key="index">
  41. <span>{{ item.createtime }}</span>
  42. <span>{{ item.redpacketvalue.toFixed(2) }}</span>
  43. </dd>
  44. </dl>
  45. </div>
  46. </div>
  47. <app-reward :show="showReward" :value="redEnvelope.RedPacketAmount" button-text="开心收下"
  48. @click="showReward = false" />
  49. </app-view>
  50. </template>
  51. <script lang="ts" setup>
  52. import { shallowRef } from 'vue'
  53. import { Toast } from 'vant'
  54. import { fullloading } from '@/utils/vant'
  55. import { useCreditLottery } from '@/business/credit'
  56. import AppReward from '@mobile/components/modules/reward/index.vue'
  57. const { creditConfig, userAccount, creditList, redEnvelope, formSubmit, formRefresh } = useCreditLottery()
  58. const showReward = shallowRef(false) // 显示抽奖红包
  59. const onSubmit = () => {
  60. const { curscore = 0 } = userAccount.value
  61. const { parma1 = 0 } = creditConfig.value
  62. if (curscore < parma1) {
  63. Toast.fail('可用积分不足')
  64. } else {
  65. fullloading((hideLoading) => {
  66. formSubmit().then(() => {
  67. hideLoading()
  68. showReward.value = true
  69. }).catch(() => {
  70. Toast.fail('抽奖失败')
  71. })
  72. })
  73. }
  74. }
  75. formRefresh()
  76. </script>
  77. <style lang="less">
  78. @import './index.less';
  79. </style>