此框架是Charlin出品的大型iOS框架CoreList的小程序版本。
-
框架依赖CoreHttp (https://github.com/ShiDianSoftware/wx.CoreHttp ),请先导入这个框架。
-
将CoreList放入您的FrameWorks目录。
-
请设置项目配置不校验请求域名,设置app.json的window的"backgroundTextStyle":"dark",列表控制器js的json文件设置"enablePullDownRefresh": true
-
建议初始化页面的时侯,一次性先copy以下代码到您的控制器js
// NewsList.js var CoreList = require('../FrameWorks/CoreList/CoreList.js'); Page({ data: { //CoreList框架变量 //1.动态变量:无需配置,请保留,框架会自动调用 dataList: null, footerStatusText: null, //2.静态变量:请填写配置(为了更灵活,请带上单位) insetsTop: "100px", insetsBottom: "50px" }, //初始化 onLoad: function(o){ CoreList.url = "http://39.108.3.179/tp5test/index" CoreList.params = { "uid": "1" } CoreList.method = "POST" CoreList.listVC = this CoreList.prepare() }, //自定义框架数据 corelist_findUsefullData_ReturnObj: function (obj){ return obj.list }, //触发顶部刷新 onPullDownRefresh: function(){ CoreList.beginHeaderRefresh() }, //触发底部刷新 onReachBottom: function(){ CoreList.beginFooterRefresh() } })
1.请问这个框架怎么没有加载HUD?
答:我认为列表不需要HUD,HUD在列表非常难看。顶部刷新以及底部刷新控件完全足以实现加载进度提示。
2.insetsTop和insetsBottom是做什么的?
答: (1)这个有两个作用,首选在ios的UITableview(UIScrollView)本身就有这两个概念,这两个主要是实现各种blur以及半透明穿透效果。
(2)作为通用列表,您的列表不可能是点满整个屏幕的,顶部或者底部总会有点什么,这个是为了这种情况而设计的。请注意您的布局,列表总是占满整个页面的布局。
3. corelist_findUsefullData_ReturnObj这个方法是做什么的?
答:这个方法您可以实现也可以不实现,这个是不强制的,框架内部也做了判断。服务器返回的列表一般是data下面的数组。例如:data: [listObjs]
有时侯服务器返回的却是一些更复杂的信息,比如例如:data: [count: 99, list: [listObjs]]
这个方法是为了让你手动剥离出来列表数组,至于为什么这个方法不写死在框架内部,因为有的列表结构又不是这么复杂,这个完全是一种定制行为。
4.我可以自定义一些数据吗?
答:可以的,请查看:
//框架需要接受的外部参数
//1.列表的请求URL
CoreList.url = null
//2.列表请求的参数
CoreList.params = null
//3.列表请求的方式:GET/POST,默认是POST
CoreList.method = "POST"
//4.请传入当前列表页面的指针
CoreList.listVC = null
//5.请传入insetsTop值以及insetsBottom值
CoreList.insetsTop = 0
CoreList.insetsBottom = 0
//框架内部使用的参数
CoreList.CoreListisHeaderRefreshing = false
CoreList.isFooterRefreshing = false
CoreList.FooterStatusFirstText = "正在读取数据..."
CoreList.FooterStatusNormalText = "继续上拉刷新"
CoreList.FooterStatusRefreshgingText = "正在读取数据..."
CoreList.FooterStatusRefreshNomoreDataText = "没有更多数据啦"
CoreList.FooterStatusRefreshErrorText = "网络错误,请稍后再试吧~"
CoreList.PageKey = "page"
CoreList.PageSizeKey = "page_size"
CoreList.page = 0
CoreList.page_size = 20
CoreList.dataList = new Array()
CoreList.hasMoreData = true