// pages/community/join/joinDetail.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { token: app.globalData.token, array: ['商业住宅小区','个人自建房'], index: 0, xqArray: [], xqAll: [], xqIndex: 0, xqSelected: '', communityName: '', communityId: '', locationCode: '', houseName: '', roomNum: '', floorNum: '', isLoading: false }, // 建筑类型 bindPickerChange: function(e) { this.setData({ index: e.detail.value }) }, // 小区 bindPickerChange1: function(e) { var self = this var result if (e.detail.value == 0) { result = '' } else { result = self.data.xqAll[e.detail.value - 1].residentialId } this.setData({ xqIndex: e.detail.value, xqSelected: result }) }, submitJoin: function () { var self = this if (!self.data.isLoading) { if (self.data.xqIndex == 0 && !self.data.houseName) { wx.showToast({ title: '请选择小区', icon: 'error' }) return } if (!self.data.floorNum) { wx.showToast({ title: '请输入楼栋', icon: 'error' }) return } if (!self.data.roomNum) { wx.showToast({ title: '请输入门牌号', icon: 'error' }) return } var residential, residentialValue if (self.data.xqSelected) { residential = self.data.xqSelected residentialValue = 'ID' } else { residential = self.data.houseName residentialValue = '非ID' } var info = { communityId: self.data.communityId, areaId:self.data.communityId, areaCode: self.data.locationCode, communityName: self.data.communityName, buildingType: self.data.array[self.data.index], residential: residential, residentialValue: residentialValue, building: self.data.floorNum, houseNumber: self.data.roomNum, buildingValue: '非ID', houseNumberValue: '非ID', locationCode: self.data.locationCode } self.setData({ isLoading: true }) app.restAjax.post(app.restAjax.path(app.apis.joinCommunity, [app.baseUrls.requestUrl]), info, { headers: { token: self.data.token } }, function (code, data) { wx.showToast({ title: '加入成功', icon: 'success' }) setTimeout(function () { self.setData({ isLoading: false }) wx.navigateBack({ delta: 2 }) }, 1500) }, function (code, data) { console.log(data) wx.showToast({ title: data.msg, icon: 'error' }) self.setData({ isLoading: false }) }) } }, getHouseList: function () { var self = this app.restAjax.get(app.restAjax.path(app.apis.getHouse, [app.baseUrls.communityUrl]), { areaCode: self.data.locationCode }, { headers: { token: self.data.token } }, function (code, data) { var arr = ['请选择小区'] for (let i = 0; i < data.length; i++) { arr.push(data[i].residentialName) } self.setData({ xqArray: arr, xqAll: data }) }, function (code, data) { console.log(data) }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ communityName: options.communityName, communityId: options.communityId, locationCode: options.locationCode }) this.getHouseList() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })