纸通宝小程序
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.
 

78 lines
2.0 KiB

// pages/moment/host-info/index.js
const request = require('../../../utils/request') //导入模块
const util = require('../../../utils/util')
Page({
/**
* 页面的初始数据
*/
data: {
hostDetail: null
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if(options.id){
wx.showLoading({
title: '加载中',
mask: true
})
request.get('/information-center/paper-bar/get/' + options.id).then(result => {
//成功回调
this.setData({ hostDetail: result.data })
wx.hideLoading()
}).catch(err => {
//异常回调
wx.hideLoading()
util.showToast(err)
})
}
},
/**
* 生命周期函数--监听页面隐藏
*/
inoutHost: function () {
if(!this.data.hostDetail){
return
}
if(this.data.hostDetail.join){
wx.showLoading({
title: '处理中',
mask: true
})
request.post('/information-center/paper-bar/quit/paper-bar/' + this.data.hostDetail.id).then(result => {
//成功回调
wx.hideLoading()
this.setData({
['hostDetail.join']: false,
['hostDetail.memberQuantity']: (this.data.hostDetail.memberQuantity - 1)
})
util.showToast('退出成功!')
}).catch(err => {
//异常回调
wx.hideLoading()
util.showToast(err)
})
} else {
wx.showLoading({
title: '处理中',
mask: true
})
request.post('/information-center/paper-bar/join/paper-bar/' + this.data.hostDetail.id).then(result => {
//成功回调
wx.hideLoading()
this.setData({
['hostDetail.join']: true,
['hostDetail.memberQuantity']: (this.data.hostDetail.memberQuantity + 1)
})
util.showToast('加入成功!')
}).catch(err => {
//异常回调
wx.hideLoading()
util.showToast(err)
})
}
}
})