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

86 lines
2.5 KiB

  1. <template>
  2. <view class="container">
  3. <view v-for="(item,index) in radioData" :key="index">
  4. <view class="font28" style="font-weight: 600">
  5. <text style="color: red">*</text>
  6. {{ index + 1 }}{{ item.questionStem }}
  7. </view>
  8. <up-radio-group
  9. v-model="radioValue[index]"
  10. placement="column"
  11. iconPlacement="right"
  12. size="40rpx"
  13. >
  14. <up-radio
  15. activeColor="#4cc0ec"
  16. :customStyle="{marginBottom: '10rpx'}"
  17. v-for="items in item.options"
  18. :key="items"
  19. :labelColor="radioValue[index]===items.value?'#4cc0ec':''"
  20. :label="items.content"
  21. :name="items.value"
  22. @change="radioChange"
  23. >
  24. </up-radio>
  25. </up-radio-group>
  26. <u-line margin="20rpx 0"></u-line>
  27. </view>
  28. </view>
  29. <submitBut text="下一步" @click="handleClick"></submitBut>
  30. </template>
  31. <script setup>
  32. import submitBut from "../../../components/submitBut/index.vue"
  33. import {ref} from "vue";
  34. import tab from "@/plugins/tab";
  35. import {getBasicQuestion, submitBasic} from "../../../api/work/work";
  36. import {getStorage, setStorage} from "../../../utils/auth";
  37. import {getPersonalInfo} from "../../../api/system/user";
  38. import modal from "../../../plugins/modal";
  39. const radioData = ref([])
  40. const radioValue = ref([])
  41. const handleClick = async () => {
  42. tab.navigateTo("/otherPages/workbenchManage/trainingExamination/index")
  43. if (3 - getStorage("userInfo").answerCount > 0) {
  44. if (radioValue.value.length === 33) {
  45. let flag = true
  46. console.log(radioValue.value);
  47. radioValue.value.forEach((item, i) => {
  48. if (radioData.value[i].answerNumber.indexOf(item) === -1) {
  49. flag = false
  50. }
  51. })
  52. await submitBasic({
  53. staffId: getStorage("userInfo").id,
  54. passed: flag
  55. })
  56. await getUserInfo()
  57. if (flag) {
  58. tab.navigateTo("/otherPages/workbenchManage/trainingExamination/index")
  59. } else {
  60. radioValue.value = []
  61. modal.msg("提目未全部回答对,请重新答题")
  62. tab.navigateBack()
  63. }
  64. } else {
  65. modal.msg("提目未全部作答,请检查")
  66. }
  67. } else {
  68. modal.msg("答题机会已用完")
  69. }
  70. }
  71. const getUserInfo = async () => {
  72. const {data} = await getPersonalInfo()
  73. setStorage('userInfo', data)
  74. }
  75. const getList = async () => {
  76. const {data} = await getBasicQuestion();
  77. radioData.value = data || []
  78. }
  79. getList()
  80. </script>
  81. <style lang="scss" scoped>
  82. @import "index";
  83. </style>