<template>
  <div class="list">
    <div class="line-box flex">
      <div class="line"></div>
    </div>
    <div class="item" @click="selectItem(item)" :class="{'active': (item.id == accountInfo.id && accountInfo.id) || (accountInfo.uid == item.uid && accountInfo.uid)}" v-for="(item, index) in list" :key="index">
      <div class="top flex">
        <van-image
          width="20"
          height="20"
          round
          fit="cover"
          :src="`/img/user/${item.server ? item.server : 'usd'}.png?14`"
        />
        <!-- 美元钱包账户 -->
        <div>{{ serverName[item.server] || $t('account.l1') }}</div>
      </div>
      <img class="check" src="/img/user/check.png" alt="极度证券">
    </div>
    <div class="btn-box flex">
      <div class="btn ltn" @click="reset">
        <!-- 重置 -->
        {{ $t('common.l44') }}
      </div>
      <div class="btn rtn" @click="submit">
        <!-- 确认 -->
        {{ $t('common.l3') }}
      </div>
    </div>
  </div>
</template>
<script>
import { mapGetters } from "vuex";
export default {
  props: ['info'],
  data () {
    return {
      accountInfo: {},
    }
  },
  computed: {
    ...mapGetters(['cashInfo', 'accountList']),
    list() {
      var list = [this.cashInfo, ...this.accountList]
      return list
    }
  },
  created () {
    this.accountInfo = this.info
  },
  methods: {
    selectItem(item) {
      this.accountInfo = item
    },
    submit() {
      this.$emit('success', this.accountInfo)
    },
    reset() {
      this.accountInfo = {}
    }
  }
}
</script>
<style lang="less" scoped>

.line-box {
  justify-content: center;
  margin-bottom: 28px;
  .line {
    width: 36px;
    height: 4px;
    background: #E7E7E7;
    border-radius: 2px;
  }
}
.list {
  padding: 15px 18px;
  .item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    height: 50px;
    font-size: 15px;
    color: #000000;
    padding: 0 20px;
    &.active {
      border-radius: 6px;
      border: 1px solid #858585;
      .check {
        display: block;
      }
    }
  }
  .top {
    column-gap: 6px;
  }
  .check {
    width: 13px;
    display: none;
  }
}
.btn-box {
  column-gap: 11px;
  padding-top: 18px;
  .btn {
    flex: 1;
    line-height: 38px;
    text-align: center;
    border-radius: 6px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
  }
  .ltn {
    border: 1px solid #DEDEDE;
  }
  .rtn {
    border: 1px solid #000000;
    background-color: #000000;
    color: #fff;
  }
}
</style>