export const publishMoments = (workMoment) =>
  uni.$u?.http.post(
    "/office/work_moment/add",
    JSON.stringify({
      ...workMoment,
    }),
    {
      header: {
        token: uni.getStorageSync("BusinessToken"),
      },
    },
  );

export const deleteMoments = (workMomentID) =>
  uni.$u?.http.post(
    "/office/work_moment/del",
    JSON.stringify({
      workMomentID,
    }),
    {
      header: {
        token: uni.getStorageSync("BusinessToken"),
      },
    },
  );

export const getMomentsByID = (workMomentID) =>
  uni.$u?.http.post(
    "/office/work_moment/get",
    JSON.stringify({
      workMomentID,
    }),
    {
      header: {
        token: uni.getStorageSync("BusinessToken"),
      },
    },
  );

export const getUserMomentsSplit = (userID, pageNumber, showNumber = 20) =>
  uni.$u?.http.post(
    "/office/work_moment/find/send",
    JSON.stringify({
      userID,
      pagination: {
        showNumber,
        pageNumber,
      },
    }),
    {
      header: {
        token: uni.getStorageSync("BusinessToken"),
      },
    },
  );

export const getSelfMomentsSplit = (pageNumber, showNumber = 20) =>
  uni.$u?.http.post(
    "/office/work_moment/find/recv",
    JSON.stringify({
      pagination: {
        showNumber,
        pageNumber,
      },
    }),
    {
      header: {
        token: uni.getStorageSync("BusinessToken"),
      },
    },
  );

export const likeMoments = (workMomentID, like) =>
  uni.$u?.http.post(
    "/office/work_moment/like",
    JSON.stringify({
      workMomentID,
      like,
    }),
    {
      header: {
        token: uni.getStorageSync("BusinessToken"),
      },
    },
  );

export const commentMoments = (workMomentID, content, replyUserID) =>
  uni.$u?.http.post(
    "/office/work_moment/comment/add",
    JSON.stringify({
      workMomentID,
      content,
      replyUserID,
    }),
    {
      header: {
        token: uni.getStorageSync("BusinessToken"),
      },
    },
  );

export const deleteComment = (workMomentID, commentID) =>
  uni.$u?.http.post(
    "/office/work_moment/comment/del",
    JSON.stringify({
      workMomentID,
      commentID,
    }),
    {
      header: {
        token: uni.getStorageSync("BusinessToken"),
      },
    },
  );

export const getMomentUnreadCount = () =>
  uni.$u?.http.post(
    "/office/work_moment/unread/count",
    {},
    {
      header: {
        token: uni.getStorageSync("BusinessToken"),
      },
    },
  );

//   1:未读数 2:消息列表 3:全部
export const clearMomentUnreadCount = (type) =>
  uni.$u?.http.post(
    "/office/work_moment/unread/clear",
    JSON.stringify({
      type,
    }),
    {
      header: {
        token: uni.getStorageSync("BusinessToken"),
      },
    },
  );

export const getMomentLogs = (pageNumber, showNumber = 20) =>
  uni.$u?.http.post(
    "/office/work_moment/logs",
    JSON.stringify({
      pagination: {
        showNumber,
        pageNumber,
      },
    }),
    {
      header: {
        token: uni.getStorageSync("BusinessToken"),
      },
    },
  );
