index.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class='pro-main'>
  3. <text v-show='total>0' style='color:black' space="ensp" decode="true"><text
  4. class='pro-chu'>出题{{currentIndex+1}}</text><text class='pro-fen'>/{{total}}</text>
  5. {{' '}}</text>
  6. <view class="title_tips">选择你的答案进入下一题</view>
  7. <progress style='width:100%;margin-top:8px' :percent="percentage" border-radius="20" backgroundColor='#E3FDFF'
  8. activeColor="#3FB4C9" stroke-width="8" />
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. props: ['currentIndex', 'total'],
  14. data() {
  15. return {
  16. percentage: 0
  17. }
  18. },
  19. watch: {
  20. currentIndex: function(newVal, oldVal) {
  21. this.percentage = this.percentageLineProgress(newVal + 1, this.total)
  22. },
  23. total: function(newVal, oldVal) {
  24. this.percentage = this.percentageLineProgress(1, this.total)
  25. }
  26. },
  27. mounted() {
  28. },
  29. methods: {
  30. percentageLineProgress(num, total) {
  31. if (num == 0 || total == 0) {
  32. return 0;
  33. }
  34. // 小数点后两位百分比
  35. return Math.round((num / total) * 10000) / 100;
  36. // return `${num}/${total}`;
  37. },
  38. },
  39. }
  40. </script>
  41. <style scoped>
  42. .pro-main {
  43. /* display: flex; */
  44. /* margin-top: 10px; */
  45. }
  46. .pro-main>>>.uni-progress-bar {
  47. border-radius: 20px !important;
  48. overflow: hidden;
  49. }
  50. .pro-main>>>.uni-progress-inner-bar {
  51. border-radius: 20px !important;
  52. overflow: hidden;
  53. background-color: #03A2AD;
  54. }
  55. .pro-chu {
  56. font-size: 20px;
  57. font-family: Source Han Sans-Bold, Source Han Sans;
  58. font-weight: 700;
  59. color: #03A2AD;
  60. line-height: 29px;
  61. }
  62. .pro-fen {
  63. font-size: 14px;
  64. font-family: Source Han Sans-Bold, Source Han Sans;
  65. font-weight: 700;
  66. color: #656C74;
  67. line-height: 20px;
  68. margin-left: 3px;
  69. }
  70. .title_tips {
  71. font-size: 24rpx;
  72. font-family: Source Han Sans-Regular, Source Han Sans;
  73. font-weight: 400;
  74. color: #656C74;
  75. line-height: 34rpx;
  76. float: right;
  77. margin: 16rpx 34rpx 0 0;
  78. }
  79. </style>