"use strict";
const common_vendor = require("../../common/vendor.js");
const components_TimeFormatting = require("../../components/TimeFormatting.js");
const components_goEasyTool_tool = require("../../components/goEasyTool/tool.js");
const tabBar = () => "../../components/tabBar/tabBar.js";
const _sfc_main = {
  data() {
    return {
      Conversationobj: { conversations: [] },
      DeleteSession: {},
      triggered: false
    };
  },
  onLoad() {
    components_goEasyTool_tool.getConversationList(this.$goeasy).then((res) => {
      common_vendor.index.__f__("log", "at pages/index/index.vue:103", res);
      this.Conversationobj = res;
    });
    var im = this.$goeasy.im;
    im.on(common_vendor.jo.IM_EVENT.CONVERSATIONS_UPDATED, this.onConversationsUpdated);
  },
  methods: {
    //下拉刷新
    onRefresherRefresh() {
      this.triggered = true;
      components_goEasyTool_tool.getConversationList(this.$goeasy).then((res) => {
        this.Conversationobj = res;
        this.triggered = false;
      });
    },
    //删除会话
    operation() {
      components_goEasyTool_tool.conversationDelete(this.$goeasy, this.DeleteSession).then((res) => {
        common_vendor.index.showToast({
          title: "删除成功",
          icon: "none"
        });
        this.$refs.Refusepopup.close();
      });
    },
    //关闭提示框
    RefuseHintcloseHint() {
      this.$refs.Refusepopup.close();
      this.DeleteSession = {};
    },
    //删除会话
    deleteConversation(item) {
      this.DeleteSession = item;
      this.$refs.Refusepopup.open("center");
    },
    //置顶会话
    goTop(item, top) {
      components_goEasyTool_tool.conversationTop(this.$goeasy, item, top).then((res) => {
        common_vendor.index.showToast({
          title: top ? "置顶成功" : "取消置顶成功",
          icon: "none"
        });
      });
    },
    //监听会话列表变化
    onConversationsUpdated(conversations) {
      this.Conversationobj = conversations;
    },
    TimeFormatting: components_TimeFormatting.TimeFormatting,
    //跳转聊天页面
    goChat(userId, nickname, avatar) {
      common_vendor.wx$1.navigateTo({
        url: `/pages/index/chat/chat?userId=${userId}&nickname=${nickname}&avatar=${avatar}`
      });
    }
  },
  components: {
    tabBar
  }
};
if (!Array) {
  const _easycom_uni_swipe_action_item2 = common_vendor.resolveComponent("uni-swipe-action-item");
  const _easycom_uni_swipe_action2 = common_vendor.resolveComponent("uni-swipe-action");
  const _easycom_tabBar2 = common_vendor.resolveComponent("tabBar");
  const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
  (_easycom_uni_swipe_action_item2 + _easycom_uni_swipe_action2 + _easycom_tabBar2 + _easycom_uni_popup2)();
}
const _easycom_uni_swipe_action_item = () => "../../uni_modules/uni-swipe-action/components/uni-swipe-action-item/uni-swipe-action-item.js";
const _easycom_uni_swipe_action = () => "../../uni_modules/uni-swipe-action/components/uni-swipe-action/uni-swipe-action.js";
const _easycom_tabBar = () => "../../components/tabBar/tabBar.js";
const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
if (!Math) {
  (_easycom_uni_swipe_action_item + _easycom_uni_swipe_action + _easycom_tabBar + _easycom_uni_popup)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: $data.Conversationobj.conversations.length > 0
  }, $data.Conversationobj.conversations.length > 0 ? {
    b: common_vendor.f($data.Conversationobj.conversations, (item, k0, i0) => {
      return common_vendor.e({
        a: item.data.avatar,
        b: item.unread > 0
      }, item.unread > 0 ? {
        c: common_vendor.t(item.unread > 99 ? "99+" : item.unread)
      } : {}, {
        d: common_vendor.t(item.data.nickname),
        e: common_vendor.t($options.TimeFormatting(item.lastMessage.timestamp)),
        f: common_vendor.t(item.lastMessage.payload.text),
        g: common_vendor.o(($event) => $options.goChat(item.userId, item.data.nickname, item.data.avatar), item.userId),
        h: !item.top
      }, !item.top ? {
        i: common_vendor.o(($event) => $options.goTop(item, true), item.userId)
      } : {}, {
        j: item.top
      }, item.top ? {
        k: common_vendor.o(($event) => $options.goTop(item, false), item.userId)
      } : {}, {
        l: common_vendor.o(($event) => $options.deleteConversation(item), item.userId),
        m: "1cf27b2a-1-" + i0 + "," + ("1cf27b2a-0-" + i0),
        n: "1cf27b2a-0-" + i0,
        o: item.userId
      });
    }),
    c: common_vendor.o((...args) => $options.onRefresherRefresh && $options.onRefresherRefresh(...args)),
    d: $data.triggered
  } : {}, {
    e: $data.Conversationobj.conversations.length == 0
  }, $data.Conversationobj.conversations.length == 0 ? {} : {}, {
    f: common_vendor.p({
      tabIndex: 3
    }),
    g: common_vendor.o(($event) => $options.operation()),
    h: common_vendor.o(($event) => $options.RefuseHintcloseHint()),
    i: common_vendor.sr("Refusepopup", "1cf27b2a-3"),
    j: common_vendor.p({
      type: "center",
      ["border-radius"]: "10px 10px 0 0"
    })
  });
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-1cf27b2a"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/index.js.map
