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 = )
{
var userresult = UserApi.Get(GetAccessToken(), "");
int pagesize = id*;
List<BatchGetUserInfoData> userList = new List<BatchGetUserInfoData>();
//每十个数据为一页
for (int i = pagesize - ;i < ((pagesize - userresult.data.openid.Count < ) ? 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);
}