bt-lcyd/pages/detail/detail.js
dong_bo0602 4458f60375 0614
2022-06-14 10:56:41 +08:00

206 lines
4.9 KiB
JavaScript

// pages/detail/detail.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
bookingType: '',
indicatorDots: true,
autoplay: true,
venuesInfoId: '',
venueInfo: {},
swiperList: [],
serviceList: [],
other: '',
tabList: [],
selectedTab: '',
tabContent: {},
facilitiesList: [],
dayList: [],
token: '',
requestIp: '',
project: '',
desc: '',
selectedProjectName: ''
},
getProject: function () {
var self = this
wx.request({
url: self.data.requestIp + 'app/wechatprogram/listvenueproject?venuesInfoId=' + self.data.venuesInfoId,
header: {
'token': self.data.token
},
success: function (res) {
console.log(res)
self.setData({
facilitiesList: res.data.data,
selectedTab: res.data.data[0].venuesProjectId,
project: res.data.data[0].facilities,
desc: res.data.data[0].projectDescription,
selectedProjectName: res.data.data[0].projectCategory,
bookingType: res.data.data[0].bookingType
})
}
})
},
goVenueDetail: function () {
wx.navigateTo({
url: '../venueIntro/venueIntro?venuesInfoId=' + this.data.venuesInfoId,
})
},
callPhone: function (e) {
wx.makePhoneCall({
phoneNumber: e.currentTarget.dataset.phone,
})
},
goMap: function (e) {
wx.navigateTo({
url: '../map/map?long=' + e.currentTarget.dataset.long + '&lng=' + e.currentTarget.dataset.lng,
})
},
getDetail: function () {
var self = this
wx.request({
url: self.data.requestIp + 'app/wechatprogram/getvenuesdetailbyId?venuesInfoId=' + self.data.venuesInfoId,
header: {
"token": self.data.token
},
success: function (res) {
if(res.statusCode == 200){
console.log(res)
var banner = res.data.data.venuePanorama.split(',')
if (res.data.data.venueService) {
var service = res.data.data.venueService.split(',')
} else {
var service = ''
}
// console.log(res.data)
// if (res.data.projectList.length > 0) {
// self.setData({
// selectedTab: res.data.projectList[0].venues_project_id
// })
// self.getTabContent()
// } else {
// self.setData({
// selectedTab: ''
// })
// }
self.setData({
venueInfo: res.data.data,
swiperList: banner,
serviceList: service,
other: res.data.data.venueOtherService,
// tabList: res.data.projectList
})
}
}
})
},
changeTab: function (e) {
console.log(e)
this.setData({
selectedTab: e.currentTarget.dataset.id,
desc: this.data.facilitiesList[e.currentTarget.dataset.idx].projectDescription,
project: this.data.facilitiesList[e.currentTarget.dataset.idx].facilities,
selectedProjectName: e.currentTarget.dataset.name,
bookingType: e.currentTarget.dataset.type
})
},
getTabContent: function () {
var self = this
wx.request({
url: self.data.requestIp + 'app/wechatprogram/getvenuesprojectdetailbyId?venuesProjectId=' + self.data.selectedTab,
header: {
"token": self.data.token
},
success: function (res) {
if(res.statusCode == 200){
self.setData({
tabContent: res.data.venuesProjectInfo,
facilitiesList: res.data.venuesProjectInfo.facilities.split(','),
dayList: res.data.dayList
})
}
}
})
},
goBook: function (e) {
wx.navigateTo({
url: '../book/book?projectId=' + this.data.selectedTab + '&name=' + this.data.selectedProjectName,
})
},
getToken: function () {
var self = this
wx.getStorage({
key: 'token',
success: function (res) {
self.setData({
token: res.data
})
self.getDetail()
self.getProject()
},
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
venuesInfoId: options.venuesInfoId,
requestIp: app.globalData.requestIp
})
this.getToken()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})