answerFloatBox.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <view class="complaintViewClass">
  3. <image src="/static/image/hall/baoxiang_icon.png" mode="aspectFill"></image>
  4. <view class="complaintViewTextClass">
  5. <view v-if="~~typeNum === 1" class="pointsOkTextClass">
  6. 已得<text class="pointsNumTextClass">{{ pointsNum }}</text>积分
  7. </view>
  8. <view v-if="~~typeNum === 2" class="pointsOkTowTextClass" @tap="handleShowTomorrowTip">
  9. <text>未答对\n明天再来</text>
  10. </view>
  11. <view v-if="~~typeNum === 3" class="pointsOkTowTextClass">
  12. <text>未答对\n继续答题</text>
  13. <view class="answerBtnClass" @tap="handleShowAnswerMethods">答题</view>
  14. </view>
  15. <view v-if="~~typeNum === 4" class="pointsOkTowTextClass">
  16. <text>
  17. <text v-if="remainSeconds > 0">再观看{{ formatTime(remainSeconds) }}\n</text>答题得奖励
  18. </text>
  19. <view class="answerBtnClass" @tap="handleShowAnswerMethods">答题</view>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. props: {
  27. typeNum: {
  28. type: Number,
  29. default: 1, //悬浮框类型:1、已得积分,2、未答对明天再来,3、未答对继续答题,4、答题得奖励
  30. },
  31. pointsNum: {
  32. type: Number,
  33. default: 0, //已得积分数量
  34. },
  35. // 父组件传:剩余秒数
  36. remainSeconds: {
  37. type: Number,
  38. default: 0
  39. },
  40. },
  41. methods: {
  42. handleShowAnswerMethods() {
  43. this.$emit('handleShowAnswer')
  44. },
  45. handleShowTomorrowTip() {
  46. this.$emit('showTomorrowTipMethods')
  47. },
  48. // 秒数 → 分:秒 格式
  49. formatTime(seconds) {
  50. if (seconds <= 0) {
  51. return '00:00'
  52. }
  53. const m = Math.floor(seconds / 60)
  54. const s = seconds % 60
  55. return `${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`
  56. },
  57. }
  58. }
  59. </script>
  60. <style scoped lang="scss">
  61. @mixin u-flex($flexD, $alignI, $justifyC) {
  62. display: flex;
  63. flex-direction: $flexD;
  64. align-items: $alignI;
  65. justify-content: $justifyC;
  66. }
  67. .complaintViewClass {
  68. @include u-flex(column, center, center);
  69. position: fixed;
  70. right: 34rpx;
  71. bottom: 400rpx;
  72. image {
  73. width: 210rpx;
  74. height: 90rpx;
  75. }
  76. .complaintViewTextClass {
  77. @include u-flex(column, center, center);
  78. margin-top: -15rpx;
  79. z-index: 10;
  80. width: 210rpx;
  81. min-height: 120rpx;
  82. background: linear-gradient(180deg, #FFF9DC 0%, #FFDC97 100%);
  83. border-radius: 20rpx;
  84. border: 2rpx solid linear-gradient(180deg, rgba(255, 228, 105, 1), rgba(255, 178, 30, 1));
  85. padding: 10rpx 10rpx 20rpx;
  86. box-sizing: border-box;
  87. text-align: center;
  88. overflow: hidden;
  89. }
  90. }
  91. .pointsOkTextClass {
  92. font-weight: 400;
  93. font-size: 28rpx;
  94. color: #FF2E3F;
  95. line-height: 40rpx;
  96. }
  97. .pointsNumTextClass {
  98. font-weight: 600;
  99. font-size: 56rpx;
  100. color: #FF2E3F;
  101. }
  102. .pointsOkTowTextClass {
  103. @include u-flex(column, center, center);
  104. font-weight: 600;
  105. font-size: 32rpx;
  106. color: #FF2E3F;
  107. }
  108. .answerBtnClass {
  109. width: 150rpx;
  110. height: 60rpx;
  111. background: linear-gradient(135deg, #FF515F 0%, #F72234 100%);
  112. border-radius: 30rpx;
  113. margin-top: 10rpx;
  114. font-weight: 600;
  115. font-size: 32rpx;
  116. color: #FFF2C3;
  117. line-height: 55rpx;
  118. text-align: center;
  119. }
  120. </style>