question-note.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view>
  3. <view class="questionBankAnswer-bottom-flex" @tap="note">
  4. <view class="iconfont icon-bianjisekuai"></view>
  5. <view>笔记</view>
  6. </view>
  7. <uni-popup ref="popup" type="bottom" radius="12rpx" background-color="#8c8989" color="#5A5B5C" width="90%">
  8. <view class="biji-content">
  9. <view class="popup-content">
  10. <text class="text">笔记</text>
  11. <view class="iconfont icon-cuo1" @tap="hide"></view>
  12. </view>
  13. <textarea :value="content" placeholder="请输入笔记" @input="setContent" class="popup-textarea" />
  14. <button type="primary" :loading="isSubmit" @tap="submit" class="popup-button">提交</button>
  15. </view>
  16. </uni-popup>
  17. </view>
  18. </template>
  19. <script>
  20. export default {
  21. props: {
  22. current_timu: {
  23. type: Object,
  24. default: function() {
  25. return {}
  26. },
  27. },
  28. },
  29. data() {
  30. return {
  31. content: '',
  32. isSubmit: false,
  33. }
  34. },
  35. methods: {
  36. setContent(e) {
  37. this.content = e.detail.value
  38. },
  39. async submit() {
  40. // if (this.content == '') return
  41. if (this.isSubmit) return
  42. this.isSubmit = true
  43. let res = await this.$myHttp.post({
  44. url: this.$myHttp.urlMap.addNote,
  45. data: {
  46. question_id: this.current_timu.id,
  47. content: this.content
  48. },
  49. needLogin: true
  50. })
  51. if (res.code == 1) {
  52. this.isSubmit = false
  53. uni.showToast({
  54. title: '保存成功'
  55. })
  56. this.$refs.popup.close()
  57. } else {
  58. uni.showToast({
  59. title: res.msg,
  60. icon: 'none'
  61. })
  62. this.isSubmit = false
  63. }
  64. },
  65. //获取之前的记录
  66. async getNote() {
  67. let res = await this.$myHttp.post({
  68. url: this.$myHttp.urlMap.getNote,
  69. data: {
  70. question_id: this.current_timu.id,
  71. },
  72. needLogin: true
  73. })
  74. if (res.code == 1) {
  75. if (res.data == null) {
  76. this.content = ''
  77. } else {
  78. if (this.current_timu.id == res.data.question_id) {
  79. this.content = res.data.content
  80. }
  81. }
  82. }
  83. },
  84. note() {
  85. if (this.current_timu.id != '' && this.current_timu.id != undefined) {
  86. this.$refs.popup.open('bottom')
  87. this.getNote()
  88. }
  89. },
  90. hide() {
  91. this.$refs.popup.close()
  92. }
  93. }
  94. }
  95. </script>
  96. <style>
  97. .popup-content {
  98. position: relative;
  99. background: #fff;
  100. z-index: 111;
  101. width: 100%;
  102. border-radius: 12px 12px 0 0;
  103. height: 42px;
  104. border-bottom: solid 1px #f1f1f1;
  105. text-align: center;
  106. line-height: 42px;
  107. color: #313131;
  108. font-size: 15px;
  109. }
  110. .popup-textarea {
  111. width: 92%;
  112. margin: 12px;
  113. height: 125px;
  114. font-size: 14px;
  115. }
  116. .biji-content {
  117. position: relative;
  118. background: #fff;
  119. border-radius: 12rpx 12rpx 0 0;
  120. max-height: 80vh;
  121. overflow-y: auto;
  122. }
  123. .popup-button {
  124. background: #3c7bfc !important;
  125. color: #fff;
  126. padding: 2px;
  127. margin: 0 auto 11px;
  128. border-radius: 43px;
  129. font-size: 16px;
  130. display: block !important;
  131. width: 95%;
  132. }
  133. .icon-cuo1 {
  134. position: absolute;
  135. color: #ccc;
  136. top: 0;
  137. right: 12px;
  138. }
  139. </style>