72 lines
1.4 KiB
JavaScript
Raw Normal View History

2024-02-21 17:43:11 +08:00
let app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
DOMAIN_NAME: app.DOMAIN_NAME,
currentTab: 0,
homelist: [],
name: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
this.getList()
},
getList() {
var that = this
app.AjaxRequest('get', {
'content-type': 'application/json'
}, '/park/list', {}, function (res) {
that.setData({
parkList: res.data
})
})
},
changePark(e) {
app.AjaxRequest('POST', {
'content-type': 'application/json',
'Authorization': 'Bearer ' + app.Getopenid()
}, '/user/profile/update', {
parkId: e.currentTarget.dataset.id
}, function (ret) {
if (ret.code == 0) {
wx.setStorageSync('parkId', e.currentTarget.dataset.id)
wx.setStorageSync('parkName', e.currentTarget.dataset.name)
wx.reLaunch({
url: '/pages/index/index',
})
}
})
},
navDetail(e) {
const eventChannel = this.getOpenerEventChannel()
let homelist = this.data.homelist
let index = e.currentTarget.dataset.index
wx.navigateBack({
url: '../logs/logs',
success() {
eventChannel.emit('acceptDataFromOpenedPage', {
data: homelist[index]
})
}
})
},
getName(e) {
this.setData({
name: e.detail.value
})
},
search() {
this.getList(this.data.name)
}
})