"use strict";
const common_vendor = require("../../common/vendor.js");
const common_libraries_apiLoading = require("../../common/libraries/apiLoading.js");
const gen_Apis = require("../../gen/Apis.js");
const ME_push_show_model = require("./model.js");
require("../../common/libraries/request.js");
require("../../common/store/useWatermarkStore.js");
const common_store_useWeAppAuthStore = require("../../common/store/useWeAppAuthStore.js");
require("../../common/store/useWorkStore.js");
const common_libraries_naviHelper = require("../../common/libraries/naviHelper.js");
const common_libraries_sendWxWork = require("../../common/libraries/sendWxWork.js");
const auth = common_store_useWeAppAuthStore.useWeAppAuthStore();
const method = {
  getCustomerMomentsShow(id) {
    common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.Customer.CustomerMoments.Show, { id }).then((res) => {
      var _a, _b, _c, _d;
      if ((_b = (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.customer_moment_tasks) == null ? void 0 : _b.length) {
        ME_push_show_model.useModel.status.value = (_d = (_c = res == null ? void 0 : res.data) == null ? void 0 : _c.customer_moment_tasks[0]) == null ? void 0 : _d.status;
      }
      ME_push_show_model.useModel.showData.value = res.data;
      console.log(res);
    });
  },
  async handleMomentCorpSend() {
    var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U;
    if (((_a = auth == null ? void 0 : auth.data) == null ? void 0 : _a.environment) === "wxwork") {
      if (((_d = (_c = (_b = ME_push_show_model.useModel) == null ? void 0 : _b.showData) == null ? void 0 : _c.value) == null ? void 0 : _d.channel) === "MomentCorp") {
        if (((_g = (_f = (_e = ME_push_show_model.useModel) == null ? void 0 : _e.showData) == null ? void 0 : _f.value) == null ? void 0 : _g.content_type) === "Link") {
          common_libraries_sendWxWork.shareToExternalMoments(
            {
              content: (_j = (_i = (_h = ME_push_show_model.useModel) == null ? void 0 : _h.showData) == null ? void 0 : _i.value) == null ? void 0 : _j.content,
              attachments: [
                {
                  msgtype: "link",
                  // 消息类型，必填
                  link: {
                    title: (_m = (_l = (_k = ME_push_show_model.useModel) == null ? void 0 : _k.showData) == null ? void 0 : _l.value) == null ? void 0 : _m.title,
                    // H5消息标题
                    imgUrl: (_r = (_q = (_p = (_o = (_n = ME_push_show_model.useModel) == null ? void 0 : _n.showData) == null ? void 0 : _o.value) == null ? void 0 : _p.cover_image) == null ? void 0 : _q[0]) == null ? void 0 : _r.url,
                    // H5消息封面图片URL
                    url: (_u = (_t = (_s = ME_push_show_model.useModel) == null ? void 0 : _s.showData) == null ? void 0 : _t.value) == null ? void 0 : _u.skip_url
                    // H5消息页面url 必填
                  }
                }
              ]
            },
            (_w = (_v = ME_push_show_model.useModel) == null ? void 0 : _v.formData) == null ? void 0 : _w.value
          );
          return false;
        }
        if (((_z = (_y = (_x = ME_push_show_model.useModel) == null ? void 0 : _x.showData) == null ? void 0 : _y.value) == null ? void 0 : _z.content_type) === "Image") {
          common_vendor.index.showLoading({
            title: "准备资料中...",
            mask: true
          });
          let attachments_media = [];
          (_D = (_C = (_B = (_A = ME_push_show_model.useModel) == null ? void 0 : _A.showData) == null ? void 0 : _B.value) == null ? void 0 : _C.attachments_media) == null ? void 0 : _D.map((res) => {
            attachments_media == null ? void 0 : attachments_media.push({
              msgtype: "image",
              // 消息类型，必填
              image: {
                mediaid: res == null ? void 0 : res.media_id
                // 图片的media_id，必填
              }
            });
          });
          common_libraries_sendWxWork.shareToExternalMoments(
            {
              content: (_G = (_F = (_E = ME_push_show_model.useModel) == null ? void 0 : _E.showData) == null ? void 0 : _F.value) == null ? void 0 : _G.content,
              attachments: attachments_media
            },
            (_I = (_H = ME_push_show_model.useModel) == null ? void 0 : _H.formData) == null ? void 0 : _I.value
          );
          setTimeout(() => {
            common_vendor.index.hideLoading();
          }, 1e3);
          return false;
        }
        if (((_L = (_K = (_J = ME_push_show_model.useModel) == null ? void 0 : _J.showData) == null ? void 0 : _K.value) == null ? void 0 : _L.content_type) === "Video") {
          common_vendor.index.showLoading({
            title: "准备资料中...",
            mask: true
          });
          let attachments_media = [];
          (_P = (_O = (_N = (_M = ME_push_show_model.useModel) == null ? void 0 : _M.showData) == null ? void 0 : _N.value) == null ? void 0 : _O.attachments_media) == null ? void 0 : _P.map((res) => {
            attachments_media == null ? void 0 : attachments_media.push({
              msgtype: "video",
              // 消息类型，必填
              video: {
                mediaid: res == null ? void 0 : res.media_id
                // 图片的media_id，必填
              }
            });
          });
          common_libraries_sendWxWork.shareToExternalMoments(
            {
              content: (_S = (_R = (_Q = ME_push_show_model.useModel) == null ? void 0 : _Q.showData) == null ? void 0 : _R.value) == null ? void 0 : _S.content,
              attachments: attachments_media
            },
            (_U = (_T = ME_push_show_model.useModel) == null ? void 0 : _T.formData) == null ? void 0 : _U.value
          );
          setTimeout(() => {
            common_vendor.index.hideLoading();
          }, 1e3);
          return false;
        }
      }
    } else {
      common_libraries_naviHelper.showToast("请在企业微信中操作!");
    }
  },
  async handleCustomerDirectCorpSend() {
    var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la;
    if (((_a = auth == null ? void 0 : auth.data) == null ? void 0 : _a.environment) === "wxwork") {
      if (((_d = (_c = (_b = ME_push_show_model.useModel) == null ? void 0 : _b.showData) == null ? void 0 : _c.value) == null ? void 0 : _d.content_type) === "MiniProgram") {
        common_libraries_sendWxWork.shareToExternalContactTask(
          {
            content: (_g = (_f = (_e = ME_push_show_model.useModel) == null ? void 0 : _e.showData) == null ? void 0 : _f.value) == null ? void 0 : _g.content,
            attachments: [
              {
                msgtype: "miniprogram",
                // 消息类型，必填
                miniprogram: {
                  appid: (_j = (_i = (_h = ME_push_show_model.useModel) == null ? void 0 : _h.showData) == null ? void 0 : _i.value) == null ? void 0 : _j.mini_program_app_id,
                  title: (_m = (_l = (_k = ME_push_show_model.useModel) == null ? void 0 : _k.showData) == null ? void 0 : _l.value) == null ? void 0 : _m.title,
                  // 消息标题
                  imgUrl: (_r = (_q = (_p = (_o = (_n = ME_push_show_model.useModel) == null ? void 0 : _n.showData) == null ? void 0 : _o.value) == null ? void 0 : _p.cover_image) == null ? void 0 : _q[0]) == null ? void 0 : _r.url,
                  // H5消息封面图片URL
                  page: (_u = (_t = (_s = ME_push_show_model.useModel) == null ? void 0 : _s.showData) == null ? void 0 : _t.value) == null ? void 0 : _u.skip_url
                  // 消息页面url 必填
                }
              }
            ]
          },
          (_w = (_v = ME_push_show_model.useModel) == null ? void 0 : _v.formData) == null ? void 0 : _w.value
        );
      }
      if (((_z = (_y = (_x = ME_push_show_model.useModel) == null ? void 0 : _x.showData) == null ? void 0 : _y.value) == null ? void 0 : _z.content_type) === "Link") {
        common_libraries_sendWxWork.shareToExternalContactTask(
          {
            content: (_C = (_B = (_A = ME_push_show_model.useModel) == null ? void 0 : _A.showData) == null ? void 0 : _B.value) == null ? void 0 : _C.content,
            attachments: [
              {
                msgtype: "link",
                // 消息类型，必填
                link: {
                  title: (_F = (_E = (_D = ME_push_show_model.useModel) == null ? void 0 : _D.showData) == null ? void 0 : _E.value) == null ? void 0 : _F.title,
                  // H5消息标题
                  imgUrl: (_K = (_J = (_I = (_H = (_G = ME_push_show_model.useModel) == null ? void 0 : _G.showData) == null ? void 0 : _H.value) == null ? void 0 : _I.cover_image) == null ? void 0 : _J[0]) == null ? void 0 : _K.url,
                  // H5消息封面图片URL
                  url: (_N = (_M = (_L = ME_push_show_model.useModel) == null ? void 0 : _L.showData) == null ? void 0 : _M.value) == null ? void 0 : _N.skip_url
                  // H5消息页面url 必填
                }
              }
            ]
          },
          (_P = (_O = ME_push_show_model.useModel) == null ? void 0 : _O.formData) == null ? void 0 : _P.value
        );
      }
      if (((_S = (_R = (_Q = ME_push_show_model.useModel) == null ? void 0 : _Q.showData) == null ? void 0 : _R.value) == null ? void 0 : _S.content_type) === "Image") {
        common_vendor.index.showLoading({
          title: "准备资料中...",
          mask: true
        });
        let attachments_media = [];
        (_W = (_V = (_U = (_T = ME_push_show_model.useModel) == null ? void 0 : _T.showData) == null ? void 0 : _U.value) == null ? void 0 : _V.attachments_media) == null ? void 0 : _W.map((res) => {
          attachments_media == null ? void 0 : attachments_media.push({
            msgtype: "image",
            // 消息类型，必填
            image: {
              mediaid: res == null ? void 0 : res.media_id
              // 图片的media_id，必填
            }
          });
        });
        common_libraries_sendWxWork.shareToExternalContactTask(
          {
            content: (_Z = (_Y = (_X = ME_push_show_model.useModel) == null ? void 0 : _X.showData) == null ? void 0 : _Y.value) == null ? void 0 : _Z.content,
            attachments: attachments_media
          },
          (_$ = (__ = ME_push_show_model.useModel) == null ? void 0 : __.formData) == null ? void 0 : _$.value
        );
        setTimeout(() => {
          common_vendor.index.hideLoading();
        }, 1e3);
        return false;
      }
      if (((_ca = (_ba = (_aa = ME_push_show_model.useModel) == null ? void 0 : _aa.showData) == null ? void 0 : _ba.value) == null ? void 0 : _ca.content_type) === "Video") {
        common_vendor.index.showLoading({
          title: "准备资料中...",
          mask: true
        });
        let attachments_media = [];
        (_ga = (_fa = (_ea = (_da = ME_push_show_model.useModel) == null ? void 0 : _da.showData) == null ? void 0 : _ea.value) == null ? void 0 : _fa.attachments_media) == null ? void 0 : _ga.map((res) => {
          attachments_media == null ? void 0 : attachments_media.push({
            msgtype: "video",
            // 消息类型，必填
            video: {
              mediaid: res == null ? void 0 : res.media_id
              // 图片的media_id，必填
            }
          });
        });
        common_libraries_sendWxWork.shareToExternalContactTask(
          {
            content: (_ja = (_ia = (_ha = ME_push_show_model.useModel) == null ? void 0 : _ha.showData) == null ? void 0 : _ia.value) == null ? void 0 : _ja.content,
            attachments: attachments_media
          },
          (_la = (_ka = ME_push_show_model.useModel) == null ? void 0 : _ka.formData) == null ? void 0 : _la.value
        );
        setTimeout(() => {
          common_vendor.index.hideLoading();
        }, 1e3);
        return false;
      }
    } else {
      common_libraries_naviHelper.showToast("请在企业微信中操作!");
    }
  },
  async handleCustomerGroupCorpSend() {
    var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la;
    if (((_a = auth == null ? void 0 : auth.data) == null ? void 0 : _a.environment) === "wxwork") {
      if (((_d = (_c = (_b = ME_push_show_model.useModel) == null ? void 0 : _b.showData) == null ? void 0 : _c.value) == null ? void 0 : _d.content_type) === "MiniProgram") {
        common_libraries_sendWxWork.shareToExternalChatTask(
          {
            content: (_g = (_f = (_e = ME_push_show_model.useModel) == null ? void 0 : _e.showData) == null ? void 0 : _f.value) == null ? void 0 : _g.content,
            attachments: [
              {
                msgtype: "miniprogram",
                // 消息类型，必填
                miniprogram: {
                  appid: (_j = (_i = (_h = ME_push_show_model.useModel) == null ? void 0 : _h.showData) == null ? void 0 : _i.value) == null ? void 0 : _j.mini_program_app_id,
                  title: (_m = (_l = (_k = ME_push_show_model.useModel) == null ? void 0 : _k.showData) == null ? void 0 : _l.value) == null ? void 0 : _m.title,
                  // 消息标题
                  imgUrl: (_r = (_q = (_p = (_o = (_n = ME_push_show_model.useModel) == null ? void 0 : _n.showData) == null ? void 0 : _o.value) == null ? void 0 : _p.cover_image) == null ? void 0 : _q[0]) == null ? void 0 : _r.url,
                  // H5消息封面图片URL
                  page: (_u = (_t = (_s = ME_push_show_model.useModel) == null ? void 0 : _s.showData) == null ? void 0 : _t.value) == null ? void 0 : _u.skip_url
                  // 消息页面url 必填
                }
              }
            ]
          },
          (_w = (_v = ME_push_show_model.useModel) == null ? void 0 : _v.formData) == null ? void 0 : _w.value
        );
      }
      if (((_z = (_y = (_x = ME_push_show_model.useModel) == null ? void 0 : _x.showData) == null ? void 0 : _y.value) == null ? void 0 : _z.content_type) === "Link") {
        common_libraries_sendWxWork.shareToExternalChatTask(
          {
            content: (_C = (_B = (_A = ME_push_show_model.useModel) == null ? void 0 : _A.showData) == null ? void 0 : _B.value) == null ? void 0 : _C.content,
            attachments: [
              {
                msgtype: "link",
                // 消息类型，必填
                link: {
                  title: (_F = (_E = (_D = ME_push_show_model.useModel) == null ? void 0 : _D.showData) == null ? void 0 : _E.value) == null ? void 0 : _F.title,
                  // H5消息标题
                  imgUrl: (_K = (_J = (_I = (_H = (_G = ME_push_show_model.useModel) == null ? void 0 : _G.showData) == null ? void 0 : _H.value) == null ? void 0 : _I.cover_image) == null ? void 0 : _J[0]) == null ? void 0 : _K.url,
                  // H5消息封面图片URL
                  url: (_N = (_M = (_L = ME_push_show_model.useModel) == null ? void 0 : _L.showData) == null ? void 0 : _M.value) == null ? void 0 : _N.skip_url
                  // H5消息页面url 必填
                }
              }
            ]
          },
          (_P = (_O = ME_push_show_model.useModel) == null ? void 0 : _O.formData) == null ? void 0 : _P.value
        );
      }
      if (((_S = (_R = (_Q = ME_push_show_model.useModel) == null ? void 0 : _Q.showData) == null ? void 0 : _R.value) == null ? void 0 : _S.content_type) === "Image") {
        common_vendor.index.showLoading({
          title: "准备资料中...",
          mask: true
        });
        let attachments_media = [];
        (_W = (_V = (_U = (_T = ME_push_show_model.useModel) == null ? void 0 : _T.showData) == null ? void 0 : _U.value) == null ? void 0 : _V.attachments_media) == null ? void 0 : _W.map((res) => {
          attachments_media == null ? void 0 : attachments_media.push({
            msgtype: "image",
            // 消息类型，必填
            image: {
              mediaid: res == null ? void 0 : res.media_id
              // 图片的media_id，必填
            }
          });
        });
        common_libraries_sendWxWork.shareToExternalChatTask(
          {
            content: (_Z = (_Y = (_X = ME_push_show_model.useModel) == null ? void 0 : _X.showData) == null ? void 0 : _Y.value) == null ? void 0 : _Z.content,
            attachments: attachments_media
          },
          (_$ = (__ = ME_push_show_model.useModel) == null ? void 0 : __.formData) == null ? void 0 : _$.value
        );
        setTimeout(() => {
          common_vendor.index.hideLoading();
        }, 1e3);
        return false;
      }
      if (((_ca = (_ba = (_aa = ME_push_show_model.useModel) == null ? void 0 : _aa.showData) == null ? void 0 : _ba.value) == null ? void 0 : _ca.content_type) === "Video") {
        common_vendor.index.showLoading({
          title: "准备资料中...",
          mask: true
        });
        let attachments_media = [];
        (_ga = (_fa = (_ea = (_da = ME_push_show_model.useModel) == null ? void 0 : _da.showData) == null ? void 0 : _ea.value) == null ? void 0 : _fa.attachments_media) == null ? void 0 : _ga.map((res) => {
          attachments_media == null ? void 0 : attachments_media.push({
            msgtype: "video",
            // 消息类型，必填
            video: {
              mediaid: res == null ? void 0 : res.media_id
              // media_id，必填
            }
          });
        });
        common_libraries_sendWxWork.shareToExternalChatTask(
          {
            content: (_ja = (_ia = (_ha = ME_push_show_model.useModel) == null ? void 0 : _ha.showData) == null ? void 0 : _ia.value) == null ? void 0 : _ja.content,
            attachments: attachments_media
          },
          (_la = (_ka = ME_push_show_model.useModel) == null ? void 0 : _ka.formData) == null ? void 0 : _la.value
        );
        setTimeout(() => {
          common_vendor.index.hideLoading();
        }, 1e3);
        return false;
      }
    } else {
      common_libraries_naviHelper.showToast("请在企业微信中操作!");
    }
  }
};
exports.method = method;
