<template>
  <div id="right-1">
    <el-row>
      <el-col :span="24" class="main">
        <el-col :span="24" class="right_one">
          <p class="right_one_name">{{ customer.name }}</p>
          <p class="right_one_address">
            {{ address.name }},{{ address.phone }},{{ address.province }},{{ address.city }},{{ address.area }},{{ address.address }}
          </p>
        </el-col>
        <el-col :span="24" class="right_two">
          <el-col :span="24" v-for="item in list" :key="item._id">
            <el-col :span="24" class="right_time">{{ item.time }}</el-col>
            <el-col :span="24" class="right_left" v-if="item.speaker._id != user._id">
              <el-col :span="24">
                <el-col :span="2" class="right_image">
                  <el-image :src="item.speaker.icon[0].url" class="right_icon"> </el-image>
                </el-col>
                <el-col :span="20" class="right_left_cont">
                  <p class="test">{{ item.content }}</p>
                </el-col>
              </el-col>
            </el-col>
            <el-col :span="24" class="right_right" v-else-if="item.speaker._id == user._id">
              <el-col :span="24">
                <el-col :span="20" class="right_right_cont">
                  <p class="test">{{ item.content }}</p>
                </el-col>
                <el-col :span="2" class="right_image">
                  <el-image :src="item.speaker.icon[0].url" class="right_icon"> </el-image>
                </el-col>
              </el-col>
            </el-col>
          </el-col>
        </el-col>
        <el-col :span="24" class="right_thr">
          <el-col :span="20" class="right_thr_1">
            <!-- <el-input v-model="message" :autosize="{ minRows: 5, maxRows: 7 }" maxlength="-1" placeholder="消息" type="textarea" size="small"></el-input> -->
            <el-form ref="form" :model="form" label-width="80px">
              <el-input v-model="form.message" :autosize="{ minRows: 5, maxRows: 7 }" maxlength="-1" placeholder="消息" type="textarea" size="small"></el-input>
            </el-form>
          </el-col>
          <el-col :span="4" class="right_thr_2">
            <el-col :span="12" class="btn"><el-button type="success" size="mini" @click="onSubmit('content')">发送</el-button></el-col>
            <el-col :span="12" class="icon">
              <i class="el-icon-circle-plus-outline" style="color: #666; font-size: 50px" @click="toUp()"></i>
            </el-col>
          </el-col>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { mapState, createNamespacedHelpers } from 'vuex';
export default {
  name: 'right-1',
  props: {
    list: { type: Array },
    address: { type: Object },
    customer: { type: Object },
    form: { type: Object },
  },
  components: {},
  data: function () {
    return {};
  },
  created() {},
  methods: {
    toUp() {
      this.$emit('toUp');
    },
    onSubmit(data) {
      this.$emit('onSubmit', data);
    },
  },
  computed: {
    ...mapState(['user']),
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    test: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

<style lang="less" scoped>
.right_one {
  text-align: center;
  line-height: 30px;
  padding: 5px;
  .right_one_name {
    font-size: 22px;
  }
  .right_one_address {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    color: #666;
  }
}

.right_two {
  background: rgb(246, 246, 246);
  height: 62vh;
  overflow-y: auto;
  .right_icon {
    border-radius: 10px;
    width: 50px;
    height: 50px;
  }
  .right_time {
    text-align: center;
    padding: 10px 0;
    color: #666;
  }
  .right_left {
    text-align: left;
    padding: 0 30px;

    .right_image {
      padding: 10px 15px;
    }

    .right_left_cont {
      padding: 10px 10px;
      .test {
        border-radius: 8px;
        border: 1px #ccc solid;
        background: rgb(235, 249, 162);
        padding: 10px;
      }
    }
  }
  .right_right {
    text-align: right;
    padding: 0 30px;
    .right_image {
      padding: 10px 15px;
    }
    .right_time {
      padding: 10px 0;
    }
    .right_right_cont {
      margin: 0 0 0 8.3%;
      padding: 10px 10px;
      text-align: left;
      .test {
        border-radius: 8px;
        border: 1px #ccc solid;
        background: rgb(174, 254, 149);
        padding: 10px;
      }
    }
  }
}
.right_thr {
  position: relative;
  bottom: 0;
  padding: 3px 5px;
  .right_thr_2 {
    padding: 20px;
    .btn {
      margin: 20px 0 0 0;
    }
  }
}
</style>
