cxmo 2 éve
szülő
commit
46df0e8e50
3 módosított fájl, 74 hozzáadás és 9 törlés
  1. 6 0
      api/question.js
  2. 55 9
      pages-question/hasQuestion.vue
  3. 13 0
      pages-question/questionDetail.vue

+ 6 - 0
api/question.js

@@ -15,3 +15,9 @@ import { httpGet, httpPost } from "@/utils/request.js";
  export const apiOptionList=params=>{
     return httpGet('/company/permission/tree',params)
 }
+/**
+ * 发布提问
+ */
+ export const apiPubAsk=params=>{
+    return httpPost('/community/question/ask',params)
+}

+ 55 - 9
pages-question/hasQuestion.vue

@@ -1,41 +1,73 @@
 <template>
   <view class="hasquestion-wrap">
-    <view class="title">问题描述</view>
+    <view class="title">问题描述<van-icon @click="showHint" coloe="rgba(0, 0, 0, 0.2)" name="question" />
+      <view class="hint" v-if="hintShow">实际发布的问题会以提炼出的精简内容为准</view>
+    </view>
     <textarea
       v-model="text"
-      placeholder="请输入问题描述"
+      placeholder="点击输入提问"
       placeholder-class="textarea-placeholder"
       :maxlength="maxlength"
       @input="calcWord"
     />
     <text style="float:right;color:grey;">剩余可输入字数:<text :style="{color:(maxlength-textlength<=10)?'red':'grey'}">{{maxlength-textlength}}</text>字</text>
     <view class="btn-wrap">
-      <view class="btn" @click="handleClick">发布提问</view> 
+      <view class="btn" :class="{'active':textlength>0}" @click="handleClick">完成</view> 
     </view>
   </view>
 </template>
 
 <script>
+import {apiPubAsk} from '@/api/question.js'
 export default {
   data() {
     return {
       text:'',
       textlength:0,
-      maxlength:100,
+      maxlength:50,
+      hintShow:false
     };
   },
   methods: {
-    handleClick(){
-      uni.navigateBack({delta:1})
+    async handleClick(){
+      if(!this.textlength){
+        uni.showToast({
+          title: '请输入问题',
+          icon: 'none',
+        })
+        return
+      }
+      const res = await apiPubAsk({
+        question_content:this.text
+      })
+      if(res.code===200){
+        uni.navigateBack({delta:1})
+      }
+      
     },
     //计算字数
     calcWord(e){
       this.textlength = e.detail.value.length
+    },
+    //展示提示
+    showHint(){
+     this.hintShow = true
+     setTimeout(()=>{
+       this.hintShow = false
+     },1000)
     }
   },
 };
 </script>
-
+<style lang="scss">
+.hasquestion-wrap{
+  .title{
+    .van-icon{
+      color:rgba(0, 0, 0, 0.2);
+    }
+  }
+}
+</style>
 <style scoped lang="scss">
 .hasquestion-wrap{
   padding:40rpx 34rpx;
@@ -43,6 +75,17 @@ export default {
     margin-bottom: 20rpx;
     font-size: 32rpx;
     color: #333333;
+    position:relative;
+    .hint{
+      position: absolute;
+      padding:20rpx 30rpx;
+      border-radius: 4rpx;
+      font-size: 28rpx;
+      background-color: rgba(0, 0, 0, 0.5);
+      color:#FFFFFF;
+      z-index: 2;
+      left:30rpx;
+    }
   }
   textarea{
     width:100%;
@@ -59,12 +102,15 @@ export default {
       display: inline-block;
       width:390rpx;
       height:80rpx;
-      background-color: #E6B77D;
       border-radius: 40rpx;
-      color: #FFFFFF;
       font-size: 32rpx;
       text-align: center;
       line-height: 80rpx;
+      background-color: #ADADAD99;
+      color: #FFFFFF;
+      &.active{
+        background-color: #E6B77D;
+      }
     }
   }
   

+ 13 - 0
pages-question/questionDetail.vue

@@ -0,0 +1,13 @@
+<template>
+  
+</template>
+
+<script>
+export default {
+
+}
+</script>
+
+<style>
+
+</style>