guochao.page.js 1.39 KB
/* eslint-disable eqeqeq */
require('admin/user.page.css');
require('bootpag/lib/jquery.bootpag.min');

const _ = require('lodash');

function bind_table_pagination() {
    const $ul = $('.guochao-list');
    const fetchRender = () => {
        $.ajax({
            url: '/admin/api/guochao/list',
        }).then(result => {
            const list = result;

            let html = '';

            _.each(list, item => {
                if (item.place) {
                    item.placeText = '下';
                } else {
                    item.placeText = '上';
                }

                html += `
                    <tr class="even pointer">
                        <td class="">${item.id}</td>
                        <td class=""><img src="${item.logo}" style="background: #000000" width="100" height="50"/></td>
                        <td class="">${item.shop_name}</td>
                        <td class="">${item.sort}</td>
                        <td class="">${item.placeText}</td>
                        <td class="">${item.collect_count}</td>
                        <td class="">
                            <a class="btn btn-info btn-update" href="/admin/guochao/update?id=${item.id}">修改</a>
                        </td>
                    </tr>`;
            });
            $ul.html(html);
        });
    };

    fetchRender();

}

(function() {
    bind_table_pagination();
}());