index.js
2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//index.js
//获取应用实例
const app = getApp()
import mock from './mock.js'//拿到的数据
Page({
data: {
items: mock,
slide: [{image: '../../images/banner.png'}, {image: '../../images/banner.png'}],
images: [{src: '../../images/duantu@2x.png', text: '短途郊游'},
{src: '../../images/changtu@2x.png', text: '长途旅游'},
{src: '../../images/finecanting@2x.png', text: 'Fine Dining 餐厅'},
{src: '../../images/huwai@2x.png', text: '户外运动'},
{src: '../../images/juhui@2x.png', text: '聚会'},
{src: '../../images/yinyuejie@2x.png', text: '音乐节'},
{src: '../../images/dianying@2x.png', text: '电影'},
{src: '../../images/qingshe@2x.png', text: '轻奢餐厅'},
{src: '../../images/zhanlan@2x.png', text: '展览'},
{src: '../../images/wutaiju@2x.png', text: '舞台剧'},
],
banner: [{image: '../../images/banner.png'}, {image: '../../images/b1@2x (1).png'}, {image: '../../images/b1@2x (2).png'}, {image: '../../images/banner.png'}],
currentBannerIndex:0,
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo')
},
bannerChange(e){
// console.log(e,'current', current);
const current = e.detail.current;
this.setData({currentBannerIndex: current})
},
//事件处理函数
bindViewTap: function () {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad: function () {
this._doRefreshMasonry(this.data.items)
},
onReachBottom: function () {
this._doAppendMasonry(this.data.items)
},
_doRefreshMasonry(items) {
this.masonryListComponent = this.selectComponent('#masonry');
this.masonryListComponent.start(items).then(() => {
console.log('refresh completed')
})
},
_doAppendMasonry(items) {
this.masonryListComponent = this.selectComponent('#masonry')
// 获取接口数据后使用瀑布流组件append方法,当append完成后调用then,是否可触底价在的标志位可以在这里处理
this.masonryListComponent.append(items).then(() => {
console.log('refresh completed,加载更多')
})
},
})