<template>
  <div class="page-body">
    <div class="head-box">
      <div class="head-box-top">
        <div class="top-call" />
        <div class="top-call"><img src="@/assets/home_images/gemho_logo_b.png"></div>
        <div class="top-call"><title-menus ref="titleMenus" menu-index="99" style="padding-top: 15px" /></div>
        <div class="top-call"><user-login ref="userLogin" /></div>
        <div class="top-call"><language-setting ref="languageSetting" /></div>
      </div>
    </div>
    <div class="content-box">
      <div style="width: 88%;padding-left: 9%;">
        <el-row :gutter="20" style="padding-top: 10px">
          <el-col :span="3">
            <user-menus menu-index="99" />
          </el-col>
          <el-col :span="21" style="padding: 10px 20px">
            <div class="user-info-box">
              <div class="user-info-avatar touch" @click="uploadAvatar">
                <img :src="user.avatarName ? baseApi + '/avatar/' + user.avatarName : Avatar" class="user-avatar">
              </div>
              <div class="user-info-content">
                <div class="user-info-text" style="padding-top:5px">用户名：<span>{{ userObj.userName }}</span></div>
                <div class="user-info-text">企业名称：<span>{{ userObj.enterpriseName }}</span></div>
                <div class="user-info-text">供应商状态：<span style="color: #0D8BF7">{{ userObj.status }}</span></div>
                <div class="line-btn">
                  <div class="user-info-btn touch" @click="$router.push({ path: '/console/userInfo' })">信息修改</div>
                  <div class="user-info-btn touch" @click="$refs.pass.dialog = true">密码修改</div>
                </div>
              </div>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
    <updatePass ref="pass" />
    <home-footer ref="homeFooter" />
    <inquiry-view ref="inquiryView" />
    <el-backtop />
    <myUpload
      v-model="uploadVisible"
      :headers="headers"
      :url="updateAvatarApi"
      @crop-success="cropUploadSuccess"
    />
  </div>
</template>
<script>
import default_product from '@/assets/home_images/default_product.png'
import Avatar from '@/assets/images/avatar.png'

import titleMenus from '../components/titleMenusV2'
import userLogin from '../components/userLoginV2'
import languageSetting from '../components/languageSettingV2'
import homeFooter from '../components/homeFooter'
import inquiryView from '../components/inquiryView'
import userMenus from '../components/userMenus'
import { mapGetters } from 'vuex'
import myUpload from 'vue-image-crop-upload'
import updatePass from '../../system/user/center/updatePass'
import { getToken } from '@/utils/auth'

export default {
  components: { titleMenus, userLogin, languageSetting, homeFooter, inquiryView, userMenus, myUpload, updatePass },
  data() {
    return {
      Avatar: Avatar,
      defaultImgProduct: default_product,
      headers: {
        'Authorization': getToken()
      },
      imgSrcStart: process.env.VUE_APP_BASE_API,
      page: 1,
      pageSize: 16,
      total: 0,
      userObj: {
        userName: '546586856',
        enterpriseName: '企业名称：佛山英沃传感科技有限公司',
        status: '审核已通过'
      },
      uploadVisible: false,
      throttle: null, // 节流器
      throttleTime: 300
    }
  },
  computed: {
    ...mapGetters([
      'user',
      'updateAvatarApi',
      'baseApi'
    ])
  },
  mounted() {
    this.$nextTick(() => {

    })
  },
  methods: {
    uploadAvatar() {
      this.uploadVisible = !this.uploadVisible
    },
    cropUploadSuccess() {
      location.reload()
    }
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.touch {
  cursor:pointer;
}
.clear {
  clear: both
}
.inline-block {
  display: inline-block;
}
.ellipsis {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  -webkit-line-clamp: 2;
  text-overflow: ellipsis;
}
.head-box {
  width: 100vw;
  top: 0;
  position: fixed;
  background: none repeat scroll 0 0 white;
  z-index: 999;
  box-shadow: 0px 3px 7px 0px rgba(0,0,0,0.2);
  .head-box-top {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    .top-call {
      height: 80px;
      padding-top: 15px;
    }
  }
}
.content-box {
  min-height: 70vh;
  margin-top: 94px;
  font-family: Source Han Sans CN;
  user-select: none;
  .page-title {
    margin-top: 20px;
    padding: 0 20px;
    font-size: 26px;
    font-weight: bold;
    color: #333333;
  }
}
.line-btn {
  display: flex;
  justify-content: center;
  font-family: Source Han Sans CN;
  font-weight: 400;
  .btn-o {
    margin: 0 25px;
    width: 360px;
    padding: 6px 10px;
    background: #F7601A;
    box-shadow: 0 3px 6px 0 rgba(0,0,0,0.2);
    text-align: center;
    border: 1px solid transparent;
    font-size: 22px;
    color: #FFFFFF;
    cursor:pointer;
    user-select: none;
  }
  .btn-o:hover {
    border: 1px solid rgba(30, 144, 255, 0.8);
    color: #1482f0;
  }
  .btn-l {
    margin: 0 25px;
    width: 360px;
    padding: 10px;
    background: #1961C5;
    box-shadow: 0 3px 6px 0 rgba(0,0,0,0.2);
    text-align: center;
    border: 1px solid transparent;
    font-size: 22px;
    color: #FFFFFF;
    cursor:pointer;
    user-select: none;
  }
  .btn-l:hover {
    border: 1px solid rgba(0,0,0,0.3);
    color: #F7601A;
  }
  .btn-b {
    margin: 0 10px;
    width: 168px;
    padding: 6px;
    background: #EFF6FF;
    border: 1px solid transparent;
    box-shadow: 0 1px 2px 0 rgba(0,0,0,0.2);
    text-align: center;
    font-size: 20px;
    color: #1961C5;
    cursor:pointer;
    user-select: none;
  }
  .btn-b:hover {
    border: 1px solid rgba(30, 144, 255, 0.9);
  }
  .active {
    color: #FFFFFF;
    font-weight: 400;
    background: #1961C5;
  }
}
.user-info-box {
  display: flex;
  width: 720px;
  height: 174px;
  margin: 160px auto;
  .user-info-avatar {
    img {
      width: 174px;
      height: 174px;
    }
  }
  .user-info-content {
    height: 174px;
    padding: 0 50px;
    .user-info-text {
      padding: 10px;
      font-size: 18px;
    }
  }
  .user-info-btn {
    margin: 16px;
    padding: 8px;
    width: 146px;
    background: #EFF6FF;
    border: 1px solid transparent;
    border-radius: 10px;
    text-align: center;
    color: #1961C5;
  }
  .user-info-btn:hover {
    border: 1px solid rgba(30, 144, 255, 0.9);
    color: #0D8BF7;
  }
}
</style>
