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

74 lines
1.7 KiB

import { changeIntroduce, getAssociationDetail } from '../../utils/api'
const app = getApp()
Page({
data: {
associationInfo: {
id: '',
groupIntroduction: ''
}
},
onLoad (options) {
wx.setNavigationBarTitle({
title: '修改群介绍'
})
this.getAssociationDetail(options.id)
},
onShow () {
},
// textarea 双向绑定
bindTextareaValue (e) {
const associationInfo = Object.assign(this.data.associationInfo, { groupIntroduction: e.detail.value})
this.setData({
associationInfo
})
},
// 修改群介绍
changeIntroduce () {
if (this.data.associationInfo.groupIntroduction === '') {
wx.showToast({
title: '请输入社群介绍',
icon: 'none',
duration: 2000
})
return false
}
const para = {
id: this.data.associationInfo.id,
groupIntroduction: this.data.associationInfo.groupIntroduction
}
wx.showLoading({
title: '加载中'
})
changeIntroduce(para).then(res => {
wx.hideLoading()
console.log('修改群介绍', res)
wx.showToast({
title: '修改群介绍成功',
icon: 'none',
duration: 2000
})
setTimeout(() => {
wx.navigateBack()
}, 500)
}).catch(err => {
console.log(err)
})
},
// 获取社群详情
getAssociationDetail (id) {
getAssociationDetail(id).then(res=> {
console.log('社群详情', res)
const associationInfo = {}
for(const key in this.data.associationInfo) {
associationInfo[key] = res.data[key]
}
this.setData({
associationInfo
})
}).catch(err => {
console.log(err)
})
}
})