<template> <view> <view class="questionBankAnswer-bottom-flex" @tap="jiucuo"> <view class="iconfont icon-sousuo1" style="font-weight: bold;"></view> <view>纠错</view> </view> <uni-popup ref="popup" type="bottom" radius="12rpx" background-color="#8c8989" color="#5A5B5C" width="90%"> <view class="jiucuo"> <view class="popup-content"> <text class="text">纠错反馈</text> <view class="iconfont icon-cuo1" @tap="hide"></view> </view> <view class="jiucuo-content"> <text>为方便我们排查错误,请您详细描述错误,例如:</text> <view class="jiucuo-xuan"> <checkbox-group @change="checkboxChange" class="jiucuo-checkbox"> <label v-for='(item,index) in list' :key="index"> <checkbox :value="item.value" color="#3c7bfc" :checked="item.checked" style="transform:scale(0.6)" />{{item.name}} </label> </checkbox-group> </view> <textarea :value="content" placeholder="其他错误,请详细描述您遇到的问题..." @input="setContent" class="popup-textarea" /> <textarea :value="analysis" placeholder="答案解析" @input="setAnalysis" class="popup-textarea" /> <button type="primary" :loading="isSubmit" @tap="submit" class="popup-button">提交</button> </view> </view> </uni-popup> </view> </template> <script> export default { props: { current_timu: { type: Object, default: {}, }, }, data() { return { isSubmit: false, arr: [], content: '', analysis: '', list: [{ value: '1', name: '含有错别字' }, { value: '2', name: '答案不正确' }, { value: '3', name: '答案不完整' }, { value: '4', name: '解析不完整' }, ] } }, methods: { async submit() { if (this.content == '' && this.arr.length == 0) return if (this.isSubmit) return this.isSubmit = true let res = await this.$myHttp.post({ url: this.$myHttp.urlMap.jiucuo, data: { analysis: this.analysis, question_id: this.current_timu.id, type: this.arr.join(',') + (this.arr.length > 0 && this.content != '' ? ',' : '') + this.content }, needLogin: true }) if (res.code == 1) { this.isSubmit = false uni.showToast({ title: '提交成功' }) this.$refs.popup.close() } else { uni.showToast({ title: res.msg, icon: 'none' }) this.isSubmit = false } }, show() { this.$refs.popup.open('bottom') this.arr = [] this.content = '' var items = this.list; for (var i = 0, lenI = items.length; i < lenI; ++i) { const item = items[i] this.$set(item, 'checked', false) } }, hide() { this.$refs.popup.close() }, setContent(e) { this.content = e.detail.value }, setAnalysis(e) { this.analysis = e.detail.value }, checkboxChange: function(e) { var items = this.list, values = e.detail.value; this.arr = [] for (var i = 0, lenI = items.length; i < lenI; ++i) { const item = items[i] if (values.includes(item.value)) { this.$set(item, 'checked', true) this.arr.push(item.name) } else { this.$set(item, 'checked', false) } } }, jiucuo() { if (this.current_timu.id != '' && this.current_timu.id != undefined) { this.show() } }, } } </script> <style> .popup-content { position: relative; background: #fff; z-index: 111; width: 100%; border-radius: 12px 12px 0 0; height: 42px; border-bottom: solid 1px #f1f1f1; text-align: center; line-height: 42px; color: #313131; font-size: 15px; } .jiucuo { position: relative; background: #fff; border-radius: 12rpx 12rpx 0 0; max-height: 80vh; overflow-y: auto; } .jiucuo-content { font-size: 13px; padding: 9px 9px 0; } .jiucuo-xuan { background: #fff; padding: 7px 2px; margin: 12px 0; border-radius: 4px; } .jiucuo-checkbox { width: 100%; display: flex; flex-wrap: wrap; align-items: flex-start; } .jiucuo-checkbox label { flex: 0 0 30%; display: flex; align-items: center; } .popup-textarea { width: 92%; margin: 0; font-size: 13px; background: #fff; padding: 11px; height: 72px; margin-bottom: 12px; background: #f7f7f7; } .popup-button { background: #3c7bfc !important; color: #fff; padding: 2px; margin: 0 auto 11px; border-radius: 43px; font-size: 16px; display: block !important; width: 95%; } .icon-cuo1 { position: absolute; color: #ccc; top: 0; right: 12px; } </style>