diff --git a/app.js b/app.js
index 160b1cb..9b0c461 100644
--- a/app.js
+++ b/app.js
@@ -1,6 +1,6 @@
//app.js
App({
- evn: 0, // 0: 开发版本;1:测试版本;2:生产版本
+ evn: 1, // 0: 开发版本;1:测试版本;2:生产版本
tmplIds: ['AFoM5TOfsgERsfcetNSB0UlmEixnLF1ySXr54Bqno2M', 'lOQ8Gvyy_dTk68bYGpRVnVA0M7DsYYrV81Gd39GUPBA'],
version: '2.2.0',
xAppId: '503258978847953926',
diff --git a/assets/home/icon-vehicle.png b/assets/home/icon-vehicle.png
new file mode 100644
index 0000000..2a73ba2
Binary files /dev/null and b/assets/home/icon-vehicle.png differ
diff --git a/components/virtual-list/index.js b/components/virtual-list/index.js
new file mode 100644
index 0000000..5c19781
--- /dev/null
+++ b/components/virtual-list/index.js
@@ -0,0 +1,164 @@
+const util = require('../../utils/util')
+const math = require('../../utils/math')
+
+Component({
+ /**
+ * 组件样式隔离
+ */
+ options: {
+ addGlobalClass: true,
+ multipleSlots: true // 支持多个slot
+ },
+ properties: {
+ height: {
+ type: Number,
+ value: 800
+ },
+ threshold: { // 下拉刷新阈值,下拉距离超过该值触发刷新
+ type: Number,
+ value: 30
+ },
+ loading: {
+ type: Boolean,
+ value: true,
+ observer(value) {
+ if(value){
+ this.reset()
+ }
+ }
+ },
+ finished: {
+ type: Boolean,
+ value: false
+ },
+ text: {
+ type: String,
+ value: '到底啦~'
+ },
+ size: {
+ type: Number,
+ value: 15
+ },
+ pageList: {
+ type: Array,
+ value: [],
+ observer(value) {
+ if (!Array.isArray(value)) {
+ return
+ }
+ this.setList(value[0])
+ }
+ }
+ },
+ lifetimes: {
+ ready: function() {
+ const query = wx.createSelectorQuery().in(this)
+ query.select('#scrollview').boundingClientRect().exec((res) => {
+ this.data.scrollH = res[0].height
+ })
+ }
+ },
+ /**
+ * 组件的初始数据
+ */
+ data: {
+ current: 1,
+ headerHeight: 0,
+ bottomHeight: 0,
+ // pageList: [], // 每一页数据
+ visiblist: [], // visible: false,// 当前是否显示
+ pageHeight: [], // 每一页高度
+ scrollH: 0,// 滚动框高度
+ requesting: false
+ },
+ /**
+ * 组件的方法列表
+ */
+ methods: {
+ reset: function(){
+ this.setData({ current: 1, loading: true, finished: false, headerHeight: 0, bottomHeight: 0, pageList: [], pageHeight: [] })
+ },
+ setList: function(listData){
+ this.data.requesting = false
+ if (!Array.isArray(listData)) {
+ return
+ }
+ if (listData.length < this.data.size) {
+ this.data.finished = true
+ }
+ this.data.current = this.data.current + 1
+ if (Array.isArray(listData) && listData.length > 0) {
+ let pageHeight = this.data.pageHeight, visiblist = this.data.visiblist;
+ let nowList = `pageList[${this.data.pageList.length - 1}]`
+ visiblist.push(true)
+ pageHeight.push({
+ top: 0, // 顶部在scroll里的高度
+ height: this.data.virtualHeight, // 高度
+ bottom: this.data.virtualHeight, // 底部在scroll里的高度
+ })
+ this.data.pageHeight = pageHeight
+ this.setData({ [nowList]: listData, visiblist, finished: this.data.finished })
+ console.log(this.data.pageList.length)
+ console.log(visiblist.length)
+ console.log(this.data.pageHeight.length)
+ this.initPageHeight(this.data.current - 2)
+ }
+ },
+ // 初始化首页高度
+ initPageHeight: function(index) {
+ const query = wx.createSelectorQuery().in(this)
+ query.select(`#listPageId${index}`).boundingClientRect().exec((res) => {
+ let pageHeight = this.data.pageHeight;
+ pageHeight[index] = {
+ top: index > 0 ? pageHeight[index - 1].bottom + 1 : 0, // 顶部在scroll里的高度
+ height: res[0].height,
+ bottom: index > 0 ? math.plus(pageHeight[index - 1].bottom + 1, res[0].height) : res[0].height // 底部在scroll里的高度
+ }
+ this.data.pageHeight = pageHeight
+ })
+ },
+ bindscroll: util.throttle(function (e) {
+ // 实现虚拟列表
+ let pageList = this.data.pageList
+ let visiblist = this.data.visiblist
+ let headerHeight = this.data.headerHeight
+ let bottomHeight = this.data.bottomHeight
+ this.data.pageHeight.forEach((item, index) => {
+ // 手指上滑
+ if (e.detail.deltaY < 0 && item.bottom < math.minus(e.detail.scrollTop, 10) && visiblist[index] && pageList[index + 2]) {
+ // 隐藏头部
+ visiblist[index] = false;
+ headerHeight += item.height;
+ // 显示底部
+ if (!visiblist[index + 2]) {
+ visiblist[index + 2] = true;
+ // console.log('index>>>' + index)
+ // console.log(pageList.length)
+ // console.log(visiblist.length)
+ // console.log(this.data.pageHeight.length)
+ bottomHeight -= this.data.pageHeight[index + 2].height
+ }
+ }
+ // 手指下滑
+ if (e.detail.deltaY > 0 && item.top > math.plus(e.detail.scrollTop, math.plus(this.data.scrollH, 10)) && visiblist[index] == true && pageList[index - 2]) {
+ // 隐藏头部
+ visiblist[index] = false;
+ bottomHeight += item.height;
+ if (!visiblist[index - 2]) {
+ // 显示底部
+ visiblist[index - 2] = true;
+ headerHeight -= this.data.pageHeight[index - 2].height
+ }
+ }
+ })
+ this.setData({ visiblist, headerHeight, bottomHeight })
+ }, 100),
+ scrolltolower: function(){
+ if (this.data.requesting || this.data.finished) {
+ return
+ }
+ this.data.requesting = true
+ this.triggerEvent('loadmore')
+ }
+ }
+})
\ No newline at end of file
diff --git a/components/virtual-list/index.json b/components/virtual-list/index.json
new file mode 100644
index 0000000..d179519
--- /dev/null
+++ b/components/virtual-list/index.json
@@ -0,0 +1,7 @@
+{
+ "component": true,
+ "usingComponents": {
+ "van-divider": "/components/divider/index",
+ "van-loading": "/components/loading/index"
+ }
+}
\ No newline at end of file
diff --git a/components/virtual-list/index.wxml b/components/virtual-list/index.wxml
new file mode 100644
index 0000000..1f12ee0
--- /dev/null
+++ b/components/virtual-list/index.wxml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+ {{loading? '正在加载' : '暂无数据'}}
+
+
+
+
+
+
+
+
+
+
+ {{finished?'到底啦~':'加载中...'}}
+
+
\ No newline at end of file
diff --git a/components/virtual-list/index.wxss b/components/virtual-list/index.wxss
new file mode 100644
index 0000000..e69de29
diff --git a/pages/home/index/index.wxml b/pages/home/index/index.wxml
index e265080..c09fe64 100644
--- a/pages/home/index/index.wxml
+++ b/pages/home/index/index.wxml
@@ -46,7 +46,7 @@
-
+