<template>
  <basic-container class="mt-10">
    <el-avatar class="mt-20" :size="150" :src="user.info.avatarUrl"></el-avatar>
    <div class="bold font-30">{{ user.info.name }}</div>
    <div class="bold font-24 mt-10">{{ user.info.deptName }}</div>
    <div class="mt-20 font-18 lines-height-15">
      <div>绑定电话：{{ user.info.phone }}</div>
      <div>注册时间：{{ user.info.createTime }}</div>
    </div>
    <div class="mt-20 flex flex-center">
      <div class="mr-20">
        <img
          class="icon"
          src="https://wutong-1302848345.cos.ap-chengdu.myqcloud.com/wtzx/db94c8a6a7ec46f7a3b32b20a5da3844.jpg"
        />
        <div class="font-18 bold">梧桐研究院</div>
      </div>
      <div class="ml-20">
        <img
          class="icon"
          src="https://wutong-1302848345.cos.ap-chengdu.myqcloud.com/wtzx/23fcdf89312f4c969eeb636d1adf9adc.jpg"
        />
        <div class="font-18 bold">梧桐树云数据服务</div>
      </div>
    </div>
    <div class="mt-20 grey-6">微信扫一扫 随时掌握项目动态</div>
  </basic-container>
</template>

<route>
{
  name: '个人中心',
  meta: { keepAlive: true }
}
</route>

<script>
import BasicContainer from '@/components/basic-container/main.vue'
import { useStore } from '@/store/user.js'

export default {
  name: 'index',
  components: { BasicContainer },
  setup() {
    const user = useStore()
    return { user }
  },
  data() {
    return {
      list: [],
      form: {},
      data: [],
      option: {
        align: 'center',
        menuAlign: 'center',
        menuWidth: 380,
        size: 'mini',
        addBtn: false,
        refreshBtn: false,
        columnBtn: false,
        labelWidth: 140,
        border: true,
        column: [
          {
            label: '文章名称',
            prop: 'title'
          },
          {
            label: '标签名称',
            prop: 'tagsName'
          }
        ]
      }
    }
  },
  methods: {
    init() {
      this.data = this.$route.query
      this.$api.login.sendSMS({ current: 1, size: 200 }).then(res => {
        if (res.code === 200) {
          this.list = res.data.records
        }
      })
    },
    push() {
      this.$router.push({ path: '/user', query: { id: 12, type: 'test' } })
    },
    onLoad() {
      this.$api.login.sendSMS({ current: 1, size: 10 }).then(res => {
        if (res.code === 200) {
          this.list = res.data.records
        }
      })
    },
    beforeOpen(done, type) {
      if (['view', 'edit'].includes(type)) {
        this.getDetail()
      }
      done()
    },
    refreshChange() {
      this.onLoad()
    },
    rowSave(row, done, loading) {
      const data = {
        projectInfoId: this.info.id
      }
      this.$api.projects.meeting.save(Object.assign(row, data)).then(
        res => {
          if (res.code === 200) {
            this.$message.success(res.msg)
          } else {
            this.$message.error(res.msg)
          }
          done(row)
          this.onLoad()
        },
        error => {
          window.console.log(error)
          loading()
        }
      )
    },
    rowUpdate(row, index, done, loading) {
      const data = {
        projectInfoId: this.info.id
      }
      this.$api.projects.meeting.update(Object.assign(row, data)).then(
        res => {
          if (res.code === 200) {
            this.$message.success(res.msg)
          } else {
            this.$message.error(res.msg)
          }
          done(row)
          this.onLoad()
        },
        error => {
          window.console.log(error)
          loading()
        }
      )
    },
    rowDel(row, index, done) {
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          return this.$api.projects.meeting.removeList({ ids: row.id })
        })
        .then(() => {
          this.$message({
            type: 'success',
            message: '操作成功!'
          })
          // 数据回调进行刷新
          done(row)
          this.onLoad()
        })
        .catch(() => {})
    }
  }
}
</script>

<style scoped>
.icon {
  width: 180px;
  height: 180px;
}
</style>
