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.
440 lines
11 KiB
440 lines
11 KiB
import { inputSync, nextTick, doAfterLogin } from "@utils/tools";
|
|
import { wxRequestPost } from "@utils/promise-wx-api";
|
|
|
|
const app = getApp();
|
|
|
|
const testPic =
|
|
"https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3015922630,3907554494&fm=26&gp=0.jpg";
|
|
|
|
// 初始化表单数据
|
|
const iniFmData = {
|
|
topicId: "",
|
|
operateReason: "",
|
|
};
|
|
const iniCloseFmData = {
|
|
topicId: "",
|
|
operateReason: "",
|
|
closedStatus: "",
|
|
};
|
|
|
|
Component({
|
|
data: {
|
|
groupId: "",
|
|
|
|
firstLoaded: false,
|
|
|
|
customerId: "",
|
|
gridId: "",
|
|
gridName: "",
|
|
|
|
info: {
|
|
groupName: "",
|
|
auditSwitch: "",
|
|
groupType: "",
|
|
totalApplyingMember: 0,
|
|
leaderFlag: "member", // leader member
|
|
},
|
|
|
|
topics: {
|
|
loading: false,
|
|
page: 1,
|
|
pageSize: 10,
|
|
isNone: false,
|
|
state: "total", // total approved closed
|
|
list: [
|
|
// {
|
|
// id: "77824",
|
|
// userId: "78600",
|
|
// releaseUserName: "ZIHJGwb2V9",
|
|
// releaseUserHeadPhoto: "",
|
|
// releaseTime: "2021-03-10 09:30",
|
|
// status: "closed",
|
|
// releaseUserFl,
|
|
// firstPhoto: "",
|
|
// issueId: "79488",
|
|
// shiftIssueFlag: true,
|
|
// content: "KMT3gjsbD9",
|
|
// contentType: "topic",
|
|
// unReadCount: 2,
|
|
// readOrUnRead: "un_read",
|
|
// },
|
|
// {
|
|
// id: "77824",
|
|
// userId: "78600",
|
|
// releaseUserName: "e额",
|
|
// releaseUserHeadPhoto: "",
|
|
// releaseTime: "2021-03-10 09:30",
|
|
// status: "closed",
|
|
// releaseUserFl,
|
|
// firstPhoto: "",
|
|
// issueId: "79488",
|
|
// shiftIssueFlag: true,
|
|
// content: "通知乱七八糟。。。。",
|
|
// contentType: "notice",
|
|
// unReadCount: 2,
|
|
// readOrUnRead: "un_read",
|
|
// },
|
|
// {
|
|
// id: "77824",
|
|
// userId: "78600",
|
|
// releaseUserName: "肺癌方法额外",
|
|
// releaseUserHeadPhoto: "",
|
|
// releaseTime: "2021-03-10 09:30",
|
|
// status: "closed",
|
|
// releaseUserFl,
|
|
// firstPhoto: "",
|
|
// issueId: "79488",
|
|
// shiftIssueFlag: true,
|
|
// content: "举办活动啦啦啦啦啦啦啦",
|
|
// contentType: "act",
|
|
// unReadCount: 2,
|
|
// readOrUnRead: "read",
|
|
// },
|
|
],
|
|
},
|
|
|
|
focusedTopicId: "",
|
|
resolved: true, //关闭话题radio
|
|
showedCloseTopicPanel: false,
|
|
showedShieldTopicPanel: false,
|
|
fmData: {
|
|
...iniFmData,
|
|
},
|
|
closeFmData: {
|
|
...iniCloseFmData,
|
|
},
|
|
|
|
noticeBut: false,
|
|
actBut: false,
|
|
groupType: "", // ordinary branch
|
|
userRole: "", // memeber leader
|
|
unReadNews: false,
|
|
},
|
|
|
|
methods: {
|
|
async onLoad(query) {
|
|
const { gid } = query;
|
|
this.setData({ groupId: gid });
|
|
},
|
|
|
|
async onShow() {
|
|
console.log("onShow执行");
|
|
wx.showLoading({
|
|
title: "",
|
|
mask: true,
|
|
});
|
|
await doAfterLogin();
|
|
|
|
const { customerId, gridId, currentGridName } = app.globalData;
|
|
this.setData({
|
|
customerId,
|
|
gridId,
|
|
gridName: currentGridName,
|
|
});
|
|
|
|
await this.getApiData();
|
|
wx.hideLoading();
|
|
},
|
|
|
|
read(e) {
|
|
const {
|
|
target: {
|
|
dataset: { id },
|
|
},
|
|
} = e;
|
|
let {
|
|
topics: { list },
|
|
} = this.data;
|
|
list.forEach((item) => {
|
|
if (item.id === id) {
|
|
item.readOrUnRead = "read";
|
|
}
|
|
});
|
|
this.setData({
|
|
"topics.list": list,
|
|
});
|
|
},
|
|
|
|
inputSync,
|
|
|
|
handleTapRootNode() {
|
|
// this.blurTopic();
|
|
},
|
|
|
|
async handleTapUnreadHint(e) {
|
|
const {
|
|
target: {
|
|
dataset: { id, type },
|
|
},
|
|
} = e;
|
|
const { unReadCount } = await this.selectComponent("#viewUnread").show({
|
|
id,
|
|
type,
|
|
});
|
|
const {
|
|
topics: { list },
|
|
} = this.data;
|
|
list.forEach((item) => {
|
|
if (item.id === id) {
|
|
item.unReadCount = unReadCount;
|
|
}
|
|
});
|
|
this.setData({
|
|
"topics.list": list,
|
|
});
|
|
},
|
|
|
|
focuseTopic(e) {
|
|
const {
|
|
target: {
|
|
dataset: { id },
|
|
},
|
|
} = e;
|
|
let { focusedTopicId } = this.data;
|
|
if (typeof id === "undefined" || id === focusedTopicId) {
|
|
focusedTopicId = "";
|
|
} else {
|
|
focusedTopicId = id;
|
|
}
|
|
console.log(focusedTopicId);
|
|
this.setData({ focusedTopicId });
|
|
},
|
|
blurTopic() {
|
|
this.setData({ focusedTopicId: "" });
|
|
},
|
|
|
|
// 屏蔽话题
|
|
shieldTopic() {
|
|
let { fmData, focusedTopicId, showedShieldTopicPanel } = this.data;
|
|
fmData.topicId = focusedTopicId;
|
|
showedShieldTopicPanel = true;
|
|
this.setData({
|
|
fmData,
|
|
showedShieldTopicPanel,
|
|
});
|
|
},
|
|
// 确认屏蔽
|
|
async confirmShieldTopic() {
|
|
const { fmData } = this.data;
|
|
if (fmData.operateReason === "") {
|
|
return wx.showToast({
|
|
title: "屏蔽理由不能为空。",
|
|
icon: "none",
|
|
duration: 1500,
|
|
});
|
|
}
|
|
|
|
wx.showLoading({
|
|
title: "请求中",
|
|
mask: true,
|
|
});
|
|
const {
|
|
data: {
|
|
data: { code, data },
|
|
},
|
|
msg,
|
|
} = await wxRequestPost("resi/group/topic/hidetopic", fmData, {
|
|
// isMock: true
|
|
});
|
|
wx.hideLoading();
|
|
|
|
if (msg === "success" && code === 0) {
|
|
wx.showToast({
|
|
title: "屏蔽成功。",
|
|
duration: 1500,
|
|
});
|
|
let { topics } = this.data;
|
|
topics.list = topics.list.filter((item) => {
|
|
return item.id !== fmData.topicId;
|
|
});
|
|
this.setData({ topics });
|
|
this.cancelShieldTopic();
|
|
}
|
|
},
|
|
// 取消屏蔽
|
|
cancelShieldTopic() {
|
|
this.setData({
|
|
showedShieldTopicPanel: false,
|
|
fmData: {
|
|
...iniFmData,
|
|
},
|
|
});
|
|
this.blurTopic();
|
|
},
|
|
|
|
// 关闭话题
|
|
closeTopic() {
|
|
let { closeFmData, focusedTopicId, showedCloseTopicPanel } = this.data;
|
|
closeFmData.topicId = focusedTopicId;
|
|
showedCloseTopicPanel = true;
|
|
this.setData({
|
|
closeFmData,
|
|
showedCloseTopicPanel,
|
|
});
|
|
},
|
|
// 确认关闭话题
|
|
async confirmCloseTopic() {
|
|
const { closeFmData } = this.data;
|
|
if (closeFmData.operateReason === "") {
|
|
return wx.showToast({
|
|
title: "关闭理由不能为空。",
|
|
icon: "none",
|
|
duration: 1500,
|
|
});
|
|
}
|
|
closeFmData.closedStatus = this.data.resolved ? "resolved" : "unresolved";
|
|
wx.showLoading({
|
|
title: "请求中",
|
|
mask: true,
|
|
});
|
|
const {
|
|
data: {
|
|
data: { code, data },
|
|
},
|
|
msg,
|
|
} = await wxRequestPost("resi/group/topic/closetopic", closeFmData, {
|
|
// isMock: true
|
|
});
|
|
wx.hideLoading();
|
|
|
|
if (msg === "success" && code === 0) {
|
|
wx.showToast({
|
|
title: "关闭话题成功。",
|
|
duration: 1500,
|
|
});
|
|
let { topics } = this.data;
|
|
topics.list = topics.list.map((item) => {
|
|
if (item.id === closeFmData.topicId) {
|
|
item.status = "closed";
|
|
}
|
|
return item;
|
|
});
|
|
this.setData({ topics });
|
|
this.cancelCloseTopic();
|
|
}
|
|
},
|
|
// 取消关闭话题
|
|
cancelCloseTopic() {
|
|
this.setData({
|
|
showedCloseTopicPanel: false,
|
|
closeFmData: {
|
|
...iniCloseFmData,
|
|
},
|
|
resolved: true,
|
|
});
|
|
this.blurTopic();
|
|
},
|
|
|
|
closeRadioChange(e) {
|
|
let { value } = e.detail;
|
|
if (value === "resolved") {
|
|
this.setData({ resolved: true });
|
|
} else {
|
|
this.setData({ resolved: false });
|
|
}
|
|
},
|
|
|
|
translateTopic(e) {
|
|
console.log(e.currentTarget.dataset.topicid);
|
|
let topicId = e.currentTarget.dataset.topicid;
|
|
wx.navigateTo({
|
|
url: `../topicToDiscussion/index?topicid=${topicId}`,
|
|
});
|
|
},
|
|
|
|
async getApiData() {
|
|
this.getTopicList();
|
|
await this.getInfo();
|
|
},
|
|
|
|
pageScrollToBottom() {
|
|
wx.pageScrollTo({
|
|
selector: "#item_bottom",
|
|
});
|
|
},
|
|
|
|
// 获取小组详情
|
|
async getInfo() {
|
|
const { groupId } = this.data;
|
|
|
|
const {
|
|
data: {
|
|
data: { code, data },
|
|
},
|
|
msg,
|
|
} = await wxRequestPost(
|
|
"resi/group/group/getgroupsummarize",
|
|
{
|
|
groupId,
|
|
},
|
|
{
|
|
// isMock: true
|
|
}
|
|
);
|
|
|
|
if (msg === "success" && code === 0) {
|
|
let { info } = this.data;
|
|
info.groupName = data.groupName;
|
|
info.leaderFlag = data.leaderFlag;
|
|
info.auditSwitch = data.auditSwitch;
|
|
info.groupType = data.groupType;
|
|
info.totalApplyingMember = parseInt(data.totalApplyingMember);
|
|
this.setData({ info });
|
|
|
|
wx.setNavigationBarTitle({ title: data.groupName });
|
|
}
|
|
},
|
|
|
|
// 获取评论列表
|
|
async getTopicList() {
|
|
const { groupId, topics } = this.data;
|
|
// 如果正在加载或没有更多,返回
|
|
if (topics.loading) return;
|
|
|
|
topics.loading = true;
|
|
this.setData({ topics });
|
|
|
|
const {
|
|
data: {
|
|
data: { code, data },
|
|
},
|
|
msg,
|
|
} = await wxRequestPost(
|
|
"resi/group/topic/getlatestv2",
|
|
{
|
|
groupId,
|
|
pageNo: 1,
|
|
pageSize: topics.pageSize,
|
|
},
|
|
{
|
|
// isMock: true
|
|
}
|
|
);
|
|
topics.loading = false;
|
|
|
|
if (msg === "success" && code === 0) {
|
|
let newList = data.list.map((item) => {
|
|
if (item.releaseUserFlag) {
|
|
item.releaseUserName = "我";
|
|
} else if (!item.releaseUserName) {
|
|
item.releaseUserName = "匿名用户";
|
|
}
|
|
return item;
|
|
});
|
|
topics.list = newList;
|
|
topics.list.reverse();
|
|
this.setData({
|
|
noticeBut: data.noticeBut,
|
|
actBut: data.actBut,
|
|
groupType: data.groupType, // ordinary branch
|
|
userRole: data.userRole, // memeber leader
|
|
unReadNews: data.unReadNews,
|
|
});
|
|
}
|
|
this.setData({ topics });
|
|
|
|
await nextTick(0);
|
|
this.pageScrollToBottom();
|
|
},
|
|
},
|
|
});
|
|
|