// pages/pageSerchDetail/pageSerchDetail.js const utils = require('../../utils/serve') Page({ /** * 页面的初始数据 */ data: { searchData: [], paginate: null, p: 1, total: 0, }, skipSearch: function () { wx.navigateTo({ url: '/pages/pageSearch/pageSearch', }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.data.finData = (JSON.parse(options.param)) this.init() wx.setNavigationBarTitle({ title: JSON.parse(options.param).name }) }, init: function () { utils.http({ url: '/manicureApi/Index/finishedProduct', method: 'GET', data: { color_id: this.data.finData.id, p: this.data.p, limit: 40, } }).then(res => { if (this.data.p >= 2) { this.setData({ searchData: this.data.searchData.concat(res.data.lists), }, () => { this.data.paginate = res.data.paginate }) } else { this.setData({ searchData: res.data.lists, total: res.data.paginate.total }, () => { this.data.paginate = res.data.paginate }) } }) }, skipDetail: function (ev) { let param = ev.currentTarget.dataset.param let obj = { param: param, searchData: this.data.searchData, paginate: this.data.paginate, finData: this.data.finData } wx.navigateTo({ url: '/pages/detailContent/detailContent?obj=' + JSON.stringify(obj), // success: res => { // // console.log(res, 123) // // // 通过eventChannel向被打开页面传送数据 // // res.eventChannel.emit('acceptDataFromOpenerPage', param, this.data.searchData, this.data.paginate, this.data.finData) // } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { if (this.data.searchData.length < this.data.total ) { this.data.p ++ this.init() } else { wx.showToast({ title: '已经到底了~', duration: 2000, icon: 'none', }) } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })