圆月山庄资源网 Design By www.vgjia.com

本文实例为大家分享了MUI实现上拉加载和下拉刷新展示的具体代码,供大家参考,具体内容如下

编写存储过程分页(此处使用T-SQL)

CREATE PROC [dbo].[Common_PageList]
(
@tab nvarchar(max),---表名
@strFld nvarchar(max), --字段字符串
@strWhere varchar(max), --where条件 
@PageIndex int, --页码
@PageSize int, --每页容纳的记录数
@Sort VARCHAR(255), --排序字段及规则,不用加order by
@IsGetCount bit --是否得到记录总数,1为得到记录总数,0为不得到记录总数,返回记录集
)
AS
declare @strSql nvarchar(max)
set nocount on;
if(@IsGetCount = 1)
begin
 set @strSql='SELECT COUNT(0) FROM ' + @tab + ' WHERE ' + @strWhere
end
else
begin
 set @strSql=' SELECT * FROM (SELECT ROW_NUMBER() 
 OVER(ORDER BY ' + @Sort + ') AS rownum, ' + @strFld + ' FROM ' + @tab + ' where ' + @strWhere + ') AS Dwhere
 WHERE rownum BETWEEN ' + CAST(((@PageIndex-1)*@PageSize + 1) as nvarchar(20)) + ' and ' + cast((@PageIndex*@PageSize) as nvarchar(20))
end

print @strSql
exec (@strSql)

set nocount off;

webApi接口(ADO.NET部分封装了,此处是调用形式)

/// 测试mui下拉刷新
    /// </summary>
    /// <param name="flag"></param>
    /// <returns></returns>
    [HttpPost]
    public object test(JObject data)
    {

      using (var db = new DbBase())
      {
        SqlParameter[] arr = { 
                   new SqlParameter{ ParameterName="tab",Value=data["tab"].ToString()},
                   new SqlParameter{ ParameterName="strFld",Value=data["strFld"].ToString()},
                   new SqlParameter{ ParameterName="strWhere",Value=data["strWhere"].ToString()},
                   new SqlParameter{ ParameterName="PageIndex",Value=Convert.ToInt32(data["PageIndex"])},
                   new SqlParameter{ ParameterName="PageSize",Value=Convert.ToInt32(data["PageSize"])},
                   new SqlParameter{ ParameterName="Sort",Value=data["Sort"].ToString()},
                   new SqlParameter{ ParameterName="IsGetCount",Value=Convert.ToInt32(data["IsGetCount"])},
                   };


      return  RepositoryBase.ExecuteReader(db, "Common_PageList", arr);


      }

页面实现

<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8">
    <title>Hello MUI</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">

    <link rel="stylesheet" href="../css/mui.min.css" rel="external nofollow" >
    <style type="text/css">
      
       
    </style>
  </head>
  <body>
    
      <header class="mui-bar mui-bar-nav">
      <h1 class="mui-title">下拉刷新(单webview模式)</h1>
    </header>
    
    <div id="pullrefresh" class="mui-content mui-scroll-wrapper">
      <div class="mui-scroll">
        
          <ul id="container" class="mui-table-view mui-table-view-chevron"></ul>
      
      </div>
    </div>
     <ul id="temp" class="mui-table-view" style="display: none;">
         <li class="mui-table-view-cell">
           <a class="mui-navigate-right">
             @name
           </a>
         </li>
        
       </ul>
    
    <script src="/UploadFiles/2021-04-02/mui.js">

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

标签:
MUI,上拉加载,下拉刷新

圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com