猫妈狗爸伴宠师小程序前端代码
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.

115 lines
2.3 KiB

1 month ago
  1. <template>
  2. <!-- <view>培训考核</view> -->
  3. <view class="page">
  4. <view class="header">
  5. <view class="flex-rowl color-fff size-28 title">
  6. {{ `答题进度 ${answered}/${total}` }}
  7. </view>
  8. <up-line-progress class="progress" :percentage="progress" activeColor="#FFBF60" inactiveColor="#D9D9D9" height="16rpx" :showText="false"></up-line-progress>
  9. </view>
  10. <view class="box">
  11. <view class="content bg-fff">
  12. <view>
  13. <view class="label size-22">
  14. 主观题
  15. </view>
  16. </view>
  17. <view >
  18. <questionCard
  19. v-for="(item, qIdx) in list"
  20. :key="`question-${qIdx}`"
  21. :index="qIdx"
  22. :data="item"
  23. v-model="item.value"
  24. :type="TYPE"
  25. ></questionCard>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="footer-btn buttom ">
  30. <button plain class="btn" @click="toNext" :disabled="answered < total">
  31. 提交
  32. </button>
  33. </view>
  34. </view>
  35. </template>
  36. <script setup>
  37. import { ref, computed } from 'vue'
  38. import { onShow } from '@dcloudio/uni-app'
  39. import { getQuestionList } from '@/api/examination'
  40. import questionCard from '../components/questionCard.vue';
  41. const TYPE = '培训'
  42. const list = ref([])
  43. const total = ref(0)
  44. const initQuestion = async () => {
  45. try {
  46. let questions = (await getQuestionList({ type: TYPE })).map(item => ({ id: item.id, title: item.title, value: null }))
  47. list.value = questions
  48. total.value = questions.length
  49. } catch (err) {
  50. }
  51. }
  52. const answered = computed(() => {
  53. return list.value.filter(item => item.value?.length).length
  54. })
  55. const progress = computed(() => {
  56. return Math.floor(answered.value / total.value * 100)
  57. })
  58. const toNext = () => {
  59. uni.navigateTo({
  60. url: "/otherPages/authentication/examination/trainCompleted/index"
  61. })
  62. }
  63. onShow(() => {
  64. initQuestion()
  65. })
  66. </script>
  67. <style lang="scss" scoped>
  68. .page {
  69. padding-bottom: 144rpx;
  70. }
  71. .header {
  72. padding: 0 36rpx;
  73. position: sticky;
  74. top: 0;
  75. background-image: linear-gradient(180deg, #FFBF60 0, #ffbf60 2%, #ffbf60 8%, #f2f2f2 90%);
  76. .progress {
  77. margin-top: 19rpx;
  78. }
  79. }
  80. .box {
  81. margin-top: 31rpx;
  82. padding: 16rpx;
  83. .content {
  84. border-radius: 20rpx;
  85. padding: 15rpx 20rpx;
  86. .label {
  87. display: inline-block;
  88. padding: 5rpx 15rpx;
  89. color: #fff;
  90. background-color: #FFBF60;
  91. }
  92. }
  93. }
  94. </style>