2025-06-06 15:17:30 +08:00

116 lines
2.2 KiB
JavaScript

const { getRoomList } = require("../../../utils/serve/user")
// subpackage/teacher/room-list/room-list.js
Page({
/**
* 页面的初始数据
*/
data: {
PageIndex:1,
haveMore:true,
list:[]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getList()
},
async getList(){
const that = this
if(this.data.haveMore){
const res = await getRoomList({
PageIndex:this.data.PageIndex,
PageSize:50,
longitude:121.531514,
latitude:31.331183
})
that.setData({
list:res.data.datas,
haveMore:res.data.total/50 > that.data.PageIndex,
PageIndex:that.PageIndex+1
})
}
},
goMap(e){
console.log(e)
wx.openLocation({
latitude:Number(e.currentTarget.dataset.latitude),
longitude:Number(e.currentTarget.dataset.longitude),
// longitude:Number(e.currentTarget.latitude),
// latitude:Number(e.currentTarget.longitude),
name:e.currentTarget.dataset.name
})
},
goRoom(e){
console.log(e);
wx.navigateTo({
url: '/subpackage/teacher/room-detail/room-datial?id='+e.currentTarget.dataset.id,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
async onPullDownRefresh() {
this.setData({
PageIndex:1,
haveMore:true
},async()=>{
await this.getList()
wx.stopPullDownRefresh()
wx.showToast({
title: '刷新成功',
icon:'none'
})
})
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
this.getList()
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})