<template>
  <div>
    <div class="user-con">
      <div class="user-top"></div>
    </div>
    <!-- <div class="container" style="padding-right: 0">
        <div class="user-info">
          <div class="user">
            <van-image width="60" height="60" round class="hand" :src="userInfo.headImgUrl" />
            <div class="name">
              <div class="text">{{ userInfo.realName ? userInfo.realName : userInfo.nickname }}</div>
              <div class="grid">
                <svg-icon iconClass="grid" class-name="img" />
                {{ userInfo.agencyName }}
              </div>
            </div>
          </div>
          <div class="edit" @click="$router.push('/userInfo/edit')">
            <svg-icon iconClass="edit" />
            <span>编辑</span>
          </div>
        </div>
      </div> -->
    <div class="container">
      <div class="cell-group">
        <van-cell required is-link title="意见类型" @click="onShowPicker()">
          <div>{{ cascaderValue }}</div>
        </van-cell>
      </div>
    </div>
    <div class="container">
      <div class="cell-group">
        <div class="textarea"> <van-field v-model="content" autosize label="诉求描述" maxlength="500"
            placeholder="不超过500字" required rows="6" type="textarea">
          </van-field></div>
      </div>
    </div>
    <van-popup v-model="showType" position="bottom">
      <van-picker show-toolbar v-model="cascaderValue" title="请选择类别" :columns="backList" :value-key="label" :values="label" @close="show = false" @confirm="onChange" />
    </van-popup>
    <div style="width: 100%;" class="flex flex-center1 flex-center2 ">
      <van-button style="width: 300px;" round block @click="submit"
        color="linear-gradient(to right, #81B5FB, #3E92FF)">提交</van-button>
    </div>
    <Android @send-number="handleNumber"></Android>
  </div>
</template>
  
  <script>
  import { dictlist,resiFeedbacksave } from '@/api/user'
  export default {
    name: 'mine',
    data() {
      return {
        showType:false,
        cascaderValue:"请选择",
        userInfo: {},
        backList:[],
        val:[],
        type:"",
        content:""
      }
    },
    components:{
      
    },
    mounted() {
      this.getDictionaries()
     this.$nextTick(()=>{
      setTimeout(()=>{
        this.userInfo = this.$store.state.app.userInfo;
      },500)
     })
    },
    methods: {
      onChange(value,index){
        console.log(value,index);
        this.showType=false
        this.type=this.val[index].value
        this.cascaderValue=value
      },
      onShowPicker(){
        this.showType=true
      },
          // 字典
    async getDictionaries () {
      // const url = "/sys/dict/data/dictlist";

      let params = {
        dictType: "feedback_type",
      };
      dictlist(params).then(res=>{
        this.val=res.data
        console.log(res.data,"sadflkjsldfk");
        this.backList=res.data.map(item=>{
          console.log(item.label,"lkdfhkl");
          
        return  item.label
        })
        console.log(this.backList);
        
      })
    //   const { data, code, msg } = await requestPost(url, params);

    //   if (code === 0) {
    //     this.typeList = data;
    //   } else {
    //     this.$message.error(msg);
    //   }
    },
    //上报反馈
    async submit () {
      // const url = "/sys/dict/data/dictlist";
      console.log(this.userInfo);
      
      let params = {
        dictType: "feedback_type",
        customerId:this.userInfo.customerId,
        resiId:this.userInfo.id,
        type:this.type,
        content:this.content

      };
      resiFeedbacksave(params).then(res=>{
        if (res.code==0) {
          this.$toast.success('上报成功')
        setTimeout(() => {
          let query = this.$route.query
          this.$router.go(-1)
        }, 5000)
        }else{
          this.$toast.fail(res.msg)
        }
   
      })
    },
      handleNumber(value){
              console.log(value,"wl kgnsl, ");
              this.phone=value
          },
    }
  }
  </script>
  
  <style scoped lang="less">
  @import './index';
  .textarea {
  /deep/ .van-cell {
    display: block;
  }
  /deep/ .van-field__label {
    width: 100%;
  }
  /deep/ .van-cell__value {
    margin-top: 20px;
    background: #F7F7F7;
    padding: 14px 16px;
  }
}
  </style>
  