//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,加载更多')
        })
    },
})