锦水居民端小程序
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.
 

81 lines
2.0 KiB

import { getAssociationDetail, joinAssociation } from '../../utils/api'
const app = getApp()
Page({
data: {
name: '加入社群',
pageType: 'join',
associationInfo: {
groupAvatar: '',
groupName: '',
id: '',
nickname: '',
groupIntroduction: ''
},
groupIntroductionList: [],
dialogVisible: false,
lordFlag: '0'
},
onShow () {
if (this.data.associationInfo.id !== '') {
this.getAssociationDetail(this.data.associationInfo.id)
}
},
onLoad (options) {
let pageType = ''
if (options.type === 'change') {
pageType = 'change'
} else if (options.type === 'join') {
pageType = 'join'
}
this.getAssociationDetail(options.id)
this.setData({
lordFlag: app.globalData.groupInfo.lordFlag,
pageType
})
},
// 修改群介绍
navigateToChangeIntroduce () {
wx.navigateTo({
url: `/subpages/association/pages/changeIntroduce/changeIntroduce?id=${this.data.associationInfo.id}`
})
},
// 获取社群详情
getAssociationDetail (id) {
getAssociationDetail(id).then(res => {
console.log('社群详情', res)
const associationInfo = {}
for(const key in this.data.associationInfo) {
associationInfo[key] = res.data[key]
}
let groupIntroductionList = []
if (associationInfo.groupIntroduction.length > 0) {
groupIntroductionList = associationInfo.groupIntroduction.split('\n')
}
this.setData({
associationInfo,
groupIntroductionList
})
}).catch(err => {
console.log(err)
})
},
confirmDialog () {
wx.navigateBack()
},
joinAssociation () {
wx.showLoading({
title: '加载中'
})
joinAssociation(this.data.associationInfo.id).then(res => {
wx.hideLoading()
console.log('审核加入社群', res)
this.setData({
dialogVisible: !this.data.dialogVisible
})
}).catch(err => {
console.log(err)
})
}
})