View
@model JiaYe.WeiXin.Models.ViewModels.UserViewModel
<div class="pull-left pagination">
<ul class="pagination pagination-outline">
@{ //分页算法:(总记录数+每页记录数-1)/每页记录数
var totalPageNum = (Model.OpenIdResult.openid.Count + 10 - 1)/10;
for (int id = 1; id <= totalPageNum; id++)
{
<li class="page-number">
<a href="/User/Index/@id">@id</a>
</li>
}
}
</ul>
</div>
Controller
public ActionResult Index(int id = 1)
{
var userresult = UserApi.Get(GetAccessToken(), "");
int pagesize = id*10;
List<BatchGetUserInfoData> userList = new List<BatchGetUserInfoData>(); //每十个数据为一页
for (int i = pagesize - 10;i < ((pagesize - userresult.data.openid.Count < 0) ? pagesize : userresult.data.openid.Count);i++)
{
BatchGetUserInfoData user = new BatchGetUserInfoData();
user.openid = userresult.data.openid[i];
userList.Add(user);
}
UserViewModel userViewModel = new UserViewModel();
userViewModel.OpenIdResult = userresult.data;
userViewModel.BatchGetUserInfoResult = UserApi.BatchGetUserInfo(GetAccessToken(), userList);
return View(userViewModel);
}
|
请发表评论