120 lines
2.5 KiB
JavaScript
120 lines
2.5 KiB
JavaScript
// pages/community/joinCommunity.js
|
|
const app = getApp()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
token: app.globalData.token,
|
|
communityList: [],
|
|
sourceUrl: app.baseUrls.sourceUrl,
|
|
},
|
|
getMyCommunity: function () {
|
|
var self = this
|
|
app.restAjax.get(app.restAjax.path(app.apis.mycommunity, [app.baseUrls.requestUrl]), {}, {
|
|
headers: {
|
|
token: self.data.token
|
|
}
|
|
}, function (code, data) {
|
|
self.setData({
|
|
communityList: data
|
|
})
|
|
}, function (code, data) {
|
|
console.log(data)
|
|
})
|
|
},
|
|
quitCommunity: function (e) {
|
|
var id = e.currentTarget.dataset.id
|
|
var community = e.currentTarget.dataset.community
|
|
var self = this
|
|
wx.showModal({
|
|
cancelColor: '#000000',
|
|
title: '确认退出该社区?',
|
|
success: function (res) {
|
|
if (res.confirm) {
|
|
app.restAjax.delete(app.restAjax.path(app.apis.quitCommunity, [app.baseUrls.requestUrl, id]), {}, {
|
|
headers: {
|
|
token: self.data.token
|
|
}
|
|
}, function (code, data) {
|
|
var areaId = wx.getStorageSync('curCommunityId')
|
|
if (community == areaId) {
|
|
// wx.removeStorageSync('areaId')
|
|
wx.removeStorageSync('areaCode')
|
|
wx.removeStorageSync('curCommunityId')
|
|
wx.removeStorageSync('curCommunityName')
|
|
wx.removeStorageSync('areaLevel')
|
|
}
|
|
wx.showToast({
|
|
title: '退出成功',
|
|
})
|
|
self.getMyCommunity()
|
|
}, function (code, data) {
|
|
console.log(data)
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
selectCommunity: function () {
|
|
wx.navigateTo({
|
|
url: './join/select',
|
|
})
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
this.getMyCommunity()
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
}) |