|
@@ -1,5 +1,7 @@
|
|
|
<template>
|
|
|
<view class="hasquestion-wrap">
|
|
|
+ <van-cell title="所属品种" :value="varietyVal||'请选择问题所属品种'" is-link @click="showFilter=true"/>
|
|
|
+ <view style="padding:34rpx">
|
|
|
<view class="title">问题描述<van-icon @click="showHint" coloe="rgba(0, 0, 0, 0.2)" name="question" />
|
|
|
<view class="hint" v-if="hintShow">实际发布的问题会以提炼出的精简内容为准</view>
|
|
|
</view>
|
|
@@ -14,20 +16,57 @@
|
|
|
<view class="btn-wrap">
|
|
|
<view class="btn" :class="{'active':textlength>0}" @click="handleClick">完成</view>
|
|
|
</view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 选择品种 -->
|
|
|
+ <van-popup
|
|
|
+ :show="showFilter"
|
|
|
+ position="bottom"
|
|
|
+ closeable
|
|
|
+ :close-on-click-overlay="true"
|
|
|
+ @close="showFilter = false"
|
|
|
+ round
|
|
|
+ >
|
|
|
+ <view class="fliter-wrap-list">
|
|
|
+ <view class="flex top">
|
|
|
+ <text style="color:#000">选择所属品种</text>
|
|
|
+ </view>
|
|
|
+ <van-tree-select
|
|
|
+ :items="options"
|
|
|
+ :main-active-index="mainActiveIndex"
|
|
|
+ :active-id="activeId"
|
|
|
+ @click-nav="onClickNav"
|
|
|
+ @click-item="onClickItem"
|
|
|
+ main-active-class="main-active-class"
|
|
|
+ content-active-class="content-active-class"
|
|
|
+ />
|
|
|
+ </view>
|
|
|
+ </van-popup>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import {apiPubAsk} from '@/api/question.js'
|
|
|
+import {apiGetTagTree} from '@/api/common'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
text:'',
|
|
|
textlength:0,
|
|
|
- maxlength:50,
|
|
|
- hintShow:false
|
|
|
+ maxlength:40,
|
|
|
+ hintShow:false,
|
|
|
+
|
|
|
+
|
|
|
+ showFilter:false,
|
|
|
+ options:[],
|
|
|
+ mainActiveIndex:0,
|
|
|
+ activeId:0,//选择的品种id
|
|
|
+ varietyVal:'',
|
|
|
};
|
|
|
},
|
|
|
+ onLoad(){
|
|
|
+ this.getOptionsList()
|
|
|
+ },
|
|
|
methods: {
|
|
|
async handleClick(){
|
|
|
if(!this.textlength){
|
|
@@ -37,6 +76,13 @@ export default {
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
+ if(!this.activeId){
|
|
|
+ uni.showToast({
|
|
|
+ title: '请选择问题所属品种',
|
|
|
+ icon: 'none',
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
const res = await apiPubAsk({
|
|
|
question_content:this.text
|
|
|
})
|
|
@@ -62,7 +108,48 @@ export default {
|
|
|
setTimeout(()=>{
|
|
|
this.hintShow = false
|
|
|
},1000)
|
|
|
- }
|
|
|
+ },
|
|
|
+
|
|
|
+ //获取品种筛选
|
|
|
+ async getOptionsList(){
|
|
|
+ const res = await apiGetTagTree()
|
|
|
+ if(res.code===200){
|
|
|
+ const arr = res.data||[]
|
|
|
+ this.options=arr.map(item=>{
|
|
|
+ let obj={
|
|
|
+ text:'',
|
|
|
+ children:[]
|
|
|
+ }
|
|
|
+ obj.text=item.classify_name
|
|
|
+ obj.children=item.tags.map(_item=>{
|
|
|
+ return {
|
|
|
+ text:_item.tag_name,
|
|
|
+ id:_item.tag_id
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return obj
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onClickNav({detail}){
|
|
|
+ console.log(detail);
|
|
|
+ this.mainActiveIndex=detail.index
|
|
|
+ },
|
|
|
+
|
|
|
+ onClickItem({detail}){
|
|
|
+ console.log(detail);
|
|
|
+ if(this.activeId==detail.id){
|
|
|
+ this.activeId=0
|
|
|
+ this.varietyVal=''
|
|
|
+ }else{
|
|
|
+ this.activeId=detail.id
|
|
|
+ this.varietyVal=detail.text
|
|
|
+ }
|
|
|
+ this.showFilter=false
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
@@ -73,11 +160,37 @@ export default {
|
|
|
color:rgba(0, 0, 0, 0.2);
|
|
|
}
|
|
|
}
|
|
|
+ .van-cell{
|
|
|
+ border-bottom: 1px solid #e5e5e5;
|
|
|
+ }
|
|
|
+ .fliter-wrap-list{
|
|
|
+ background-color: #fff;
|
|
|
+ padding-top: 28rpx;
|
|
|
+ padding-bottom: 100rpx;
|
|
|
+ .top{
|
|
|
+ font-size: 32rpx;
|
|
|
+ justify-content: center;
|
|
|
+ margin-bottom: 40rpx;
|
|
|
+ padding: 0 34rpx;
|
|
|
+ position: relative;
|
|
|
+ }
|
|
|
+ .van-sidebar{
|
|
|
+ flex-shrink: 0;
|
|
|
+ }
|
|
|
+ .van-tree-select__content{
|
|
|
+ overflow-x: hidden;
|
|
|
+ }
|
|
|
+ .main-active-class{
|
|
|
+ border-color: #E3B377;
|
|
|
+ }
|
|
|
+ .content-active-class{
|
|
|
+ color: #E3B377;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|
|
|
<style scoped lang="scss">
|
|
|
.hasquestion-wrap{
|
|
|
- padding:40rpx 34rpx;
|
|
|
.title{
|
|
|
margin-bottom: 20rpx;
|
|
|
font-size: 32rpx;
|