question-tiankong.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <view>
  3. <view>
  4. <view class="tkt_style" v-for="(item,index) in current_timu.right_answer_arr" :key="index">
  5. <input type="text" placeholder="请输入答案" :value="current_timu.my_answer_arr[index]"
  6. @input="post_answer($event, index)">
  7. </view>
  8. </view>
  9. <view class="tkt_button" :class="is_tiankong_sub ? 'duoxuan_checked' : 'duoxuan' "
  10. v-if="current_timu.right_answer_arr.length > 0 && !show_beiti" @tap="post_answer_req()">
  11. {{is_tiankong_sub ? '提交成功' : '确认提交'}}
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. props: {
  18. current_timu: {
  19. type: Object,
  20. default: function() {
  21. return {}
  22. },
  23. },
  24. is_tiankong_sub: {
  25. type: Boolean,
  26. default: false,
  27. },
  28. show_beiti: {
  29. type: Boolean,
  30. default: true,
  31. },
  32. copy_user_answer: {
  33. type: Array,
  34. default: function() {
  35. return [];
  36. },
  37. }
  38. },
  39. watch: {
  40. current_timu: {
  41. handler(newVal, oldVal) {},
  42. deep: true,
  43. immediate: true
  44. }
  45. },
  46. methods: {
  47. // 提交答案
  48. post_answer(item, index) {
  49. this.$emit('post_answer', item, index)
  50. if (this.is_tiankong_sub) {
  51. this.$emit('set_sub_button_style', 'is_tiankong_sub', false)
  52. }
  53. let timu = this.current_timu,
  54. my_answer_arr = this.current_timu.my_answer_arr;
  55. this.$set(my_answer_arr, index, item.detail.value)
  56. this.$set(timu, index, 'my_answer_arr', my_answer_arr)
  57. this.$set(timu, 'show_right_answer', true)
  58. if (timu.my_answer_arr.length > 0) {
  59. this.$set(timu, 'my_answer', timu.my_answer_arr.join('|'))
  60. }
  61. // if (timu.my_answer_arr.length > 0) {
  62. // this.$set(timu, 'user_answer', timu.my_answer_arr.join('|'))
  63. // }
  64. this.$emit('set_current_timu', timu)
  65. // let copy_user_answer_this = this.copy_user_answer;
  66. // if (copy_user_answer_this[this.current_timu.id]) {
  67. // copy_user_answer_this[this.current_timu.id] = timu.my_answer_arr
  68. // }
  69. // console.log(copy_user_answer_this)
  70. // this.$emit('set_copy_user_answer',copy_user_answer_this)
  71. },
  72. post_answer_req() {
  73. this.$emit('post_answer_req', true)
  74. },
  75. }
  76. }
  77. </script>
  78. <style>
  79. </style>