日照项目的居民端小程序
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.
 
 
 

228 lines
4.6 KiB

import { inputSync, nextTick } from '@utils/tools';
import {
wxRequestPost,
wxRedirectTo,
wxNavigateTo,
wxShowModal
} from '@utils/promise-wx-api';
const app = getApp();
Component({
properties: {
tid: {
type: String,
value: '',
},
gid: {
type: String,
value: '',
},
leader: {
type: String,
value: 'staff'
}
},
data: {
iniLoaded: false,
awaitAudit: false,
inGroup: true,
shieldStatus: false,
rejectAutit: false,
topicDraftId: '',
groupId: '',
hasLeader: 'staff',
info: {
topicContent: '',
releaseTime: '',
releaseUserHeadPhoto: '',
releaseUserName: '',
releaseAddress: '',
topicDraftId: '',
imageList: [],
docList: [],
voiceList: [],
videoList: [],
reason: '',
topicId: '',
groupId: ''
},
groupInfo: {
leaderFlag: 'member',
},
rejectReason: '',
voiceList: [], // 音频列表
refreshFlag: false, //onshow用判断
},
methods: {
async onLoad(options) {
await app.doAfterLogin();
const { tid, gid, leader } = this.data;
this.setData({ topicDraftId: tid, groupId: gid, hasLeader: leader });
console.log('hasLeader', this.data.hasLeader)
await this.getApiData();
this.setData({
iniLoaded: true,
});
},
async onShow() {
// if (this.data.refreshFlag) {
// await app.enterGridData();
// await this.getApiData();
// }
},
handleInput(e) {
let value = e.detail.value.trim()
this.setData({
rejectReason: value
})
},
// 点击查看作品图集
previewImg(e) {
const {
target: {
dataset: { index },
},
} = e;
const {
info: { picList },
} = this.data,
currentImg = picList[index],
imgArr = picList.map((item) => item);
wx.previewImage({
current: currentImg,
urls: imgArr,
});
},
async getApiData() {
await this.getInfo();
},
// 获取话题详情
async getInfo() {
const { topicDraftId } = this.data;
const {
data: {
data: { code, data },
},
msg,
} = await wxRequestPost(
'resi/group/topicdraft/detail',
{
topicDraftId,
},
{
// isMock: true
}
);
if (msg === 'success' && code === 0) {
let { info } = this.data;
for(var n in data) {
info[n] = data[n]
}
console.log('datafffff', this.data.info)
this.setData({ info });
}
},
cancelShieldTopic() {
this.setData({
rejectAutit: false
})
},
confirmShieldTopic() {
const { info } = this.data
if (info.reason === '') {
return wx.showToast({
title: '驳回理由不能为空',
icon: 'none',
duration: 1500
})
}
this.topicAuditing('rejected')
},
handleOperateTopic(e) {
const type = e.currentTarget.dataset.btn
if (type === 'cancle') {
this.setData({
rejectAutit: true
})
} else {
this.topicAuditing('approved')
}
},
// 话题审核 驳回 通过 /
async topicAuditing(auditType) {
const { topicDraftId, rejectReason } = this.data;
const {
data: {
data: { code, data },
},
msg,
} = await wxRequestPost(
'resi/group/topicdraft/audit',
{
topicDraftId,
reason: rejectReason,
auditType
},
{
// isMock: true
}
);
if (msg === 'success' && code === 0) {
wx.navigateBack()
}
},
// 删除已驳回话题
async topicDel() {
const { topicDraftId } = this.data;
const retConfirm = await wxShowModal({
title: "确认删除此话题?"
});
if (retConfirm.msg !== "success" || !retConfirm.data.confirm) {
return;
}
const {
data: {
data: { code, data },
},
msg,
} = await wxRequestPost(
'resi/group/topicdraft/del',
{
topicDraftId
},
{
// isMock: true
}
);
if (msg === 'success' && code === 0) {
wx.showToast({
title: '删除成功',
icon: 'none',
duration: 1500
})
wx.navigateBack()
}
},
// 重新编辑
reedit() {
const { topicDraftId, info } = this.data;
wxNavigateTo("/pages/group/topic/newTopic/newTopic", {
tid: topicDraftId,
gid: info.groupId
});
}
},
});