// banner
var imgIndex = 0;
var imgDivArr = document.getElementsByClassName("imgdiv");
var dotArr = document.getElementsByClassName("dot");
/**
 *  播放图片
 *  参数r：是否正放，若为true，正放。若为false，倒放
 */
function picplay(r) {
    for (let i = 0; i < imgDivArr.length; i++) {
        imgDivArr[i].style.display = "none";
        dotArr[i].className = "dot";
    }
    if (r) {
        imgIndex++;
        imgIndex = (imgIndex >= imgDivArr.length) ? 0 : imgIndex;
    } else {
        imgIndex--;
        imgIndex = (imgIndex < 0) ? imgDivArr.length - 1 : imgIndex;
    }
    imgDivArr[imgIndex].style.display = "block";
    dotArr[imgIndex].className = "dot active";
}
setInterval(picplay, 3000, true);
// banner
// 判断用户登录状态
function usermessage() {
    var userId = window.localStorage.getItem('userId');
    var userToken = window.localStorage.getItem("yq_token");
    console.log(userId);
    $.ajax({

        url: 'http://127.0.0.1:81/consumer/user/fineById/' + userId + '/', //请求url
        undefined,
        type: "get",
        headers: {
            undefined,
            "token": userToken //此处放置请求到的用户token
        },
        success: function(data) {
            if (data.code == 200) {
                b = '<ul class="denglu">' +
                    data.data.username + '</ul>';
                b += '<p style="margin-bottom:30px;">' + data.data[j].poemUser + '</p>';
                b += '<div class="mb-6"><p>' + data.data[j].time + '</p></div></div></div>';
                $("#denglu").append(b);
            }
        }
    })
}
// 判断用户状态结束