<template>
    <div class='pur-list'>
        <div class="pur-list-item" v-for="( item, index ) in data" :key="index">
            <img :src="item.avatar" class="pur-list-item__avatar" />
            <span class="pur-list-item__name">{{formatName(item.wxName, 1)}}</span>
            <span class="pur-list-item__count"><i>{{item.buyQty}}</i>份</span>
            <span class="pur-list-item__time">{{formatTime(item.tmTrade, "yyyy-MM-dd HH:mm:ss")}}</span>
        </div>
    </div>
</template>
<script>
import { formaterDate } from '../../common/utils/datatools.js';
export default {
    name: 'h-pur-list',
    props: [ 'data' ],
    methods: {
        formatTime(data, format) {
            return formaterDate(data, format);
        },
        formatName(item, n) {
            let arr = item.split("");
            let y = arr.length;
            let s = [];

            if (y >= n) {
                s = arr.slice(0, n);

                for (let i = 0; i < y - n; i++) {
                    s.push("*");
                }
            } else {
                s = arr.slice(0, y);
            }
            var retstr = s.join("");
            retstr = retstr.length > 15 ? retstr.substring(0, 15) : retstr
            return retstr;
        }
    }
}
</script>
<style lang="less" scoped>
@import './index.less';
</style>