<template>
  <div class="my_qa">
    <el-breadcrumb separator="/" class="bread_crumb1 bread_left">
      <el-breadcrumb-item :to="{ path: '/user' }">{{
        $t("lang.personal_center")
      }}</el-breadcrumb-item>
      <el-breadcrumb-item>{{
        $t("lang.my_questions_and_answers")
      }}</el-breadcrumb-item>
    </el-breadcrumb>
    <BlockRadius class="info_block user_qa">
      <div class="left_user">
        <div class="img_head">
          <img src="@/assets/imgs/shop_img_banner_test.png" />
        </div>
        <div class="left_word">
          <p class="left_name">设计师设计啥都往</p>
          <p class="left_role">普通用户开发者</p>
        </div>
      </div>
      <div class="right_list">
        <div class="user_qa_card my_q">
          <img src="@/assets/imgs/ic_wodetiwen.png" />
          <div class="card_word">
            <p class="card_name">我的提问</p>
            <p>
              {{ helper.numberFormat(870000) }}<span class="card_wan">万</span>
            </p>
          </div>
        </div>
        <div class="user_qa_card my_a">
          <img src="@/assets/imgs/ic_wodehuida.png" />
          <div class="card_word">
            <p class="card_name">我的提问</p>
            <p>
              {{ helper.numberFormat(870000) }}<span class="card_wan">万</span>
            </p>
          </div>
        </div>
        <div class="user_qa_card my_view">
          <img src="@/assets/imgs/ic_liulanshu.png" />
          <div class="card_word">
            <p class="card_name">我的提问</p>
            <p>
              {{ helper.numberFormat(870000) }}<span class="card_wan">万</span>
            </p>
          </div>
        </div>
      </div>
    </BlockRadius>
    <BlockRadius class="block_down info_block">
      <el-tabs v-model="activeName" @tab-click="clickTab">
        <el-tab-pane label="我的提问" name="0"> </el-tab-pane>
        <el-tab-pane label="我的回答" name="1"> </el-tab-pane>
        <el-tab-pane label="被删除" name="2"> </el-tab-pane>
      </el-tabs>
      <div class="qa_list apaas_scroll">
        <div v-for="(item, index) in data_list" :key="index" class="qa_cell">
          <div class="qa_cell_in">
            <div :class="activeName == 2 ? 'qa_is_del' : 'qa_init'">
              <p v-if="activeName == 1" class="cell_answer">为什么感知服务提示我无法注册？</p>
              <p :class="activeName == 0 ? 'cell_title' : 'cell_ans_title'">为什么感知服务提示我无法注册？</p>
              <p class="cell_cont">
                为什么感知服务提示我无法注册？为什么感知服务提示我无法注册？为什么感知服务提示我无法注册？为什么感知服务提示我无法注册？为什么感知服务提示我无法注册？为什么感知服务提示我无法注册？为什么感知服务提示我无法注册？
              </p>
              <p v-if="activeName == 2" class="cell_other">
                <span>删除时间：2020-10-01 18:00:00</span>
                <span>删除人：管理员</span>
                <span>删除理由：帖子内容含违规广告信息</span>
              </p>
              <p v-else class="cell_other">
                <span>2020-10-01 18:00:00</span>
                <span>评论 12</span>
                <span>阅读 1,024</span>
              </p>
              
            </div>
            <div class="qa_del">
              <img
                src="@/assets/imgs/msg_icon_shanchu.png"
                @click="delectItem(index)"
              />
            </div>
          </div>
        </div>
      </div>
      <!-- 分页 -->
      <section class="com-pagination">
        <div class="com_page_total">共3个条目</div>
        <div class="com_page_item">
          <div class="com_page_num">
            <div>每页条数：</div>
            <div class="com_page_num_sel">
              <el-select
                v-model="pagination.rowsPerPage"
                placeholder="请选择"
                size="small"
                @change="handleSizeChange"
              >
                <el-option
                  v-for="item in pageOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </div>
          </div>
          <div class="com_page_control">
            <el-button
              icon="el-icon-arrow-left"
              circle
              size="mini"
              @click="handleCurrentChange(-1)"
              :disabled="pagination.page == 1"
            ></el-button>
            &nbsp;&nbsp;第{{ pagination.page }}页 / 共{{
              Math.ceil((total == 0 ? 1 : total) / pagination.rowsPerPage)
            }}页
            <el-button
              icon="el-icon-arrow-right"
              circle
              size="mini"
              @click="handleCurrentChange(1)"
              :disabled="
                pagination.page >=
                Math.ceil((total == 0 ? 1 : total) / pagination.rowsPerPage)
              "
            ></el-button>
          </div>
        </div>
      </section>
    </BlockRadius>
  </div>
</template>

<script>
import BlockRadius from "@/components/general/block-radius";
import helper from "@/services/helper.js";
export default {
  components: {
    BlockRadius,
  },
  data: () => ({
    helper,
    activeName: "0",
    pagination: {
      rowsPerPage: 10,
      page: 1,
    },
    total: 123,
    pageOptions: [
      {
        value: "10",
        label: "10",
      },
      {
        value: "20",
        label: "20",
      },
      {
        value: "50",
        label: "50",
      },
    ],
    data_list: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],
  }),
  watch: {},
  methods: {
    clickTab() {},
    handleSizeChange(val) {
      this.pagination.rowsPerPage = val;
      this.refreshData();
    },
    handleCurrentChange(val) {
      this.pagination.page += val;
      this.refreshData();
    },
    refreshData() {
      this.$emit("refresh", this.pagination);
    },
    pageResize() {
      let listWidth = this.$refs.commodityCardIn.clientWidth;
      let rowCardNum = Math.floor(listWidth / 310);
      let cardArr = this.$refs.commodityCardIn.children;
      // console.log(rowCardNum, listWidth / rowCardNum);
      for (let i = 0; i < cardArr.length; i++) {
        cardArr[i].style.width = listWidth / rowCardNum - 1 + "px";
      }
      // console.log(this.$refs.commodityCardIn);
    },
    delectItem(index) {
      console.log(index);
    },
  },
  mounted() {},
};
</script>

<style scoped>
.my_qa {
  /* height: calc(100% - 20px); */
  height: calc(100%);
  overflow: hidden;
}
.info_block {
  margin: 0 20px 20px;
  position: relative;
}
.block_down {
  height: calc(100% - 214px);
}
.user_qa {
  height: 120px;
  display: flex;
  justify-content: space-between;
}
.left_user {
  width: 300px;
  display: flex;
  justify-content: space-between;
}
.img_head {
  width: 76px;
  height: 76px;
  margin: 2px 10px;
  border-radius: 50%;
  overflow: hidden;
  border: solid 2px #e3e5ef;
}
.left_word {
  width: 200px;
  padding-top: 5px;
}
.left_name {
  color: #1d1e20;
  font-size: 22px;
  line-height: 44px;
}
.left_role {
  color: #8890a7;
  font-size: 14px;
}
.right_list {
  width: 60%;
  min-width: 750px;
  max-width: 1000px;
  display: flex;
  justify-content: space-between;
}
.user_qa_card {
  width: 31%;
  height: 80px;
  border-radius: 10px 10px 10px 40px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  font-size: 34px;
  font-family: Arial;
  font-weight: bold;
  text-align: right;
}
.my_q {
  background-color: #fcefd6;
  color: #ef9433;
}
.my_a {
  background-color: #e7fdfc;
  color: #25bdb1;
}
.my_view {
  background-color: #e5f4fe;
  color: #38aef9;
}
.card_word {
}
.card_name {
  color: #242c43;
  font-size: 14px;
  font-family: Microsoft YaHei;
  font-weight: normal;
}
.card_wan {
  font-size: 14px;
}
.qa_list {
  height: calc(100% - 114px);
  overflow: auto;
}
.qa_cell {
  padding: 0 20px;
  border-radius: 12px;
}
.qa_cell:hover {
  background-color: #f8f9fd;
}
.qa_cell_in {
  height: 100%;
  padding: 20px 0;
  border-bottom: #f4f7fc 2px solid;
  display: flex;
  justify-content: space-between;
}
.qa_cell:nth-last-child(1) .qa_cell_in {
  border-bottom: none;
}
.qa_init {
  width: calc(100% - 80px);
}
.qa_init .cell_answer {
  color: #1a2236;
  font-size: 16px;
  margin: 0 0 16px;
  cursor: pointer;
}
.qa_init .cell_ans_title {
  color: #58617a;
  font-size: 16px;
  margin: 0 0 8px;
  cursor: pointer;
}
.qa_init .cell_title {
  color: #242c43;
  font-size: 16px;
  margin: 0 0 8px;
  cursor: pointer;
}
.qa_init .cell_cont {
  color: #8890a7;
  font-size: 14px;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
}
.qa_init .cell_other {
  color: #58617a;
  font-size: 14px;
  margin: 14px 0 0;
}
.qa_init .cell_other span {
  display: inline-block;
  padding: 0 16px 0 0;
  position: relative;
}
.qa_init .cell_other span::after {
  content: "";
  position: absolute;
  width: 2px;
  height: 11px;
  background-color: #e6ebfe;
  right: 5px;
  top: 4px;
}
.qa_init .cell_other span:nth-last-child(1)::after {
  content: none;
}
.qa_is_del {
  width: calc(100% - 80px);
}
.qa_is_del .cell_answer {
  color: #a9aec0;
  font-size: 16px;
  margin: 0 0 16px;
  cursor: pointer;
}
.qa_is_del .cell_ans_title {
  color: #a9aec0;
  font-size: 16px;
  margin: 0 0 8px;
  cursor: pointer;
}
.qa_is_del .cell_title {
  color: #a9aec0;
  font-size: 16px;
  margin: 0 0 8px;
  cursor: pointer;
}
.qa_is_del .cell_cont {
  color: #a9aec0;
  font-size: 14px;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
}
.qa_is_del .cell_other {
  color: #8890a7;
  font-size: 14px;
  margin: 14px 0 0;
}
.qa_is_del .cell_other span {
  display: inline-block;
  padding: 0 16px 0 0;
  position: relative;
}
.qa_is_del .cell_other span::after {
  content: "";
  position: absolute;
  width: 2px;
  height: 11px;
  background-color: #e6ebfe;
  right: 5px;
  top: 4px;
}
.qa_is_del .cell_other span:nth-last-child(1)::after {
  content: none;
}
.qa_del {
  width: 70px;
  justify-content: center;
  align-items: center;
  display: none;
}
.qa_cell:hover .qa_del {
  display: flex;
}
.qa_del img {
  cursor: pointer;
}
</style>
<style scoped>
.com-pagination {
  margin-top: 20px;
  font-size: 14px;
  padding: 0 5%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.com_page_num {
  width: 140px;
  margin-right: 20px;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.com_page_num_sel {
  width: 50px;
  font-size: 14px;
  position: relative;
  top: 1px;
}
.com_page_item {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
.commodity_card {
}
.commodity_card_list {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
}
.commodity_card_item {
  margin: 10px 0;
}
.commodity_card_item_in {
  margin: 0 auto;
}
</style>
<style>
.com_page_control .el-button {
  border: 0;
}
.com_page_num .el-input__inner {
  border: 0;
  padding: 0;
}
</style>