// pages/seller_home/seller_home.js const axios = require('../../api/index') Page({ /** * 页面的初始数据 */ data: { triggered: false, currentPage: 1, pageSize: 6, list_total: 0, // 商品列表 showlist: [], id:0, sellerinfo:{} }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var id = options.id this.setData({ id },()=>{ this.get_list() }) }, fun(){ return }, go_detail(e){ wx.navigateTo({ url:'/pages/detail/detail?id='+e.currentTarget.dataset.id, }) }, // 上拉刷新 onScrolltolower() { let { list_total, showlist } = this.data; if (list_total == showlist.length) return this.setData({ currentPage: this.data.currentPage + 1, }, () => { this.get_list() }) }, // 下拉加载 onRefresh() { this.setData({ currentPage: 1, refresh: true, }, () => { this.get_list() }) // setTimeout(() => { // this.setData({ // triggered: false // }) // }, 1000) }, // 获取设备列表 get_list() { console.log(123) var data = { currentPage: this.data.currentPage, pageSize: this.data.pageSize, userId:this.data.id } axios.getEquipmentListbyid(data).then(res => { var list_total = res.data.total var sellerinfo=res.data.seller if (this.data.currentPage == 1) { var list = res.data.sellerEquipmentList } else { var list = [...this.data.showlist, ...res.data.sellerEquipmentList] } this.setData({ sellerinfo, showlist: list, list_total, triggered: false }) }).catch(err => { console.log(err) }) // getEquipmentSearch }, // 返回 to_prev() { wx.navigateBack({ delta: 1 }) }, // 返回首页查看更多 to_index() { wx.reLaunch({ url: `/pages/index/index`, }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function (e) { let userInfo = wx.getStorageSync('userInfo'); if(e.from=="button"){ let detail=e.target.dataset.item return { imageUrl:detail.equipmentPictures[0].pictureLink, title: `${detail.title}`, path: `/pages/detail/detail?id=${detail.id}&shareType=newusers&userId=${userInfo.id}` } }else{ let share_data = getApp().global_share() return share_data } } })