<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('积分详情')" />
    <style>
        #toolbar p {
            margin: 0;
            padding: 0;
            padding-bottom: 12px;
            border-bottom: 2px solid skyblue;
        }
        .top_data {
            display: flex;
            padding: 20px;
        }
        .top_data_img span {
            display: inline-block;
            width: 70px;
            height: 70px;
            background: #ccc;
            border-radius: 50%;
        }
        .top_data_right {
            margin-left: 12px;
            display: flex;
            flex-direction: column;
            justify-content: center;
        }
        .top_data_right .name .nameSp{
            margin-left: 12px;
        }
        .userData {
            margin-top: 14px;
            display: flex;
        }
        .userData p {
            margin-right: 12px;
        }
    </style>
</head>
<body class="gray-bg">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <div class="top_data">
                    <div class="top_data_img">
                        <span></span>
                    </div>
                    <div class="top_data_right">
                        <div class="name"><span id="name">张三</span><span class="nameSp">17788774478</span></div>
                        <div class="userData">
                            <p>积分状态：<span id="status">正常</span></p>
                            <p>总积分：<span id="scoreAll">1000</span></p>
                            <p>已使用积分：<span id="scoreUse">300</span></p>
                            <p>剩余积分：<span id="scoreRest">700</span></p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="btn-group-sm" id="toolbar" role="group">
                <p>积分变更记录</p>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer"/>
    <script th:inline="javascript">
        let datas = [];
        var dicCouponBusiType = [[${@dict.getType('zhengzai_coupon_busi_type')}]];
        var dicCouponBindType = [[${@dict.getType('zhengzai_coupon_bind_type')}]];
        var prefix = ctx + "stone/logs";

        var viewMgtCouponFlag = [[${@permission.hasPermi('candy:coupon:mgt:detail')}]];
        var cancelMgtCouponFlag = [[${@permission.hasPermi('candy:coupon:mgt:cancel')}]];
        
        var couType = [[${couType}]];
        $(function () {
            getAllData();
            
        });
        function getAllData() {
            let uid = getUrlParms('id');
            let data = {
                uid
            }
            $.ajax({
                type: 'get',
                url: prefix + '/details',
                data,
                success:function(e) {
                    console.log(e)
                    if (e.code == 0) {
                        const { dto } = e.data;
                        datas= e.data.scoreLogs;
                        var options = {
                            data: datas,
                            pagination: false,
                            showSearch: false,
                            showRefresh: false,
                            showToggle: false,
                            showColumns: false,
                            sidePagination: "client",
                            columns: [
                                {
                                    field: 'createdAt',
                                    title: '时间',
                                    // formatter: function (value, row, index) {
                                    //     return $.common.dateFormat(value, 'yyyy-MM-dd HH:mm:ss');
                                    // }
                                },
                                // {
                                //     field: 'eventAmt',
                                //     title: '类型'
                                // },
                                // {
                                //     field: 'content',
                                //     title: '任务名称',
                                //     formatter: function(value, row, index) {
                                //         return $.table.selectDictLabel(dicCouponBindType, value);
                                //     }
                                // },
                                {
                                    field: 'score',
                                    title: '获得积分',
                                },
                                {
                                    field: 'reason',
                                    title: '变更原因'
                                }
                            ]
                        };
                        $.table.init(options);
                        $('#name').text(dto.nickName);
                        let statusName = '';
                        $('#scoreAll').text(dto.scoreAll);
                        $('#scoreUse').text(dto.scoreUse);
                        $('#scoreRest').text(dto.scoreRest);
                        if (dto.status == 1) {
                            statusName = '正常'
                        } else {
                            statusName = '冻结'
                        }
                        $('#status').text(statusName);
                    }
                }
            })
        }
        function getUrlParms(name){
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r!=null)
                return unescape(r[2]);
                return null;
        }
        /* 查看码列表 */
        function couponCodeList(couponId) {
            var url = 'candy/coupon/code?couponId=' + couponId;
            $.modal.openTab("积分明细列表", url);
        }
    </script>
</body>
</html>