You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
2.2 KiB
110 lines
2.2 KiB
// pages/service/service.js
|
|
import { ServiceModel } from '../../models/service.js'
|
|
let serviceModel = new ServiceModel()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
list:[],
|
|
page:1,
|
|
next:true
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
serviceModel.myService(this.data.page,res=>{
|
|
|
|
if(res.result.length > 0){
|
|
this.setData({
|
|
list:res.result
|
|
})
|
|
}else{
|
|
this.setData({
|
|
next:false
|
|
})
|
|
}
|
|
|
|
})
|
|
// wx.showShareMenu({
|
|
// withShareTicket: true,
|
|
// menus: ['shareAppMessage', 'shareTimeline']
|
|
// });
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
if(this.data.next){
|
|
var nextPage = this.data.page + 1
|
|
serviceModel.myService(nextPage,res=>{
|
|
|
|
if(res.result.length > 0){
|
|
this.setData({
|
|
list:this.data.list.concat(res.result),
|
|
page:nextPage
|
|
})
|
|
}else{
|
|
this.setData({
|
|
next:false
|
|
})
|
|
}
|
|
|
|
})
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
},
|
|
detail:function(e){
|
|
// console.log(e)
|
|
// return
|
|
wx.navigateTo({
|
|
url: '/pages/service/myService/myService?id=' + e.currentTarget.dataset.id
|
|
})
|
|
}
|
|
})
|