"use strict";
const common_vendor = require("../common/vendor.js");
const utils_request = require("../utils/request.js");
const userApi = {
  // 账号密码登录 - 显示自定义 loading 文字
  accountLogin(data, onComplete) {
    const deviceInfo = common_vendor.index.getStorageSync("deviceInfo");
    const newDeviceInfo = {
      ...deviceInfo,
      deviceId: `(${data.yhm})${deviceInfo.model}`
    };
    common_vendor.index.setStorageSync("deviceInfo", newDeviceInfo);
    const promise = utils_request.request.post(
      `/service?ssServ=ss.login&yhm=${data.yhm}&mm=${data.mm}&wdConfirmationCaptchaService=0&wechatCode=${data.wechatCode}`,
      data,
      {
        loading: false,
        // 禁用全局 loading，由登录页面自己控制
        request: {
          timeout: 15e3
          // 登录请求 15 秒超时
        }
      }
    );
    if (onComplete) {
      promise.finally(() => {
        onComplete();
      });
    }
    return promise;
  },
  // 扫码登录门系统
  sacnGateLoginQrcode(data) {
    return utils_request.request.post(
      `/service?ssServ=sacnGateLoginQrcode`,
      data,
      {
        loading: true,
        formData: true
      }
    );
  },
  // 扫码登录pc端
  sacnLoginQrcode(data) {
    return utils_request.request.post(
      `/service?ssServ=sacnLoginQrcode`,
      data,
      {
        loading: true,
        formData: true
      }
    );
  },
  // 自动登录 - 静默登录，不显示 loading
  autoLogin(data) {
    return utils_request.request.post(
      `/service?ssServ=ss.login&wdConfirmationCaptchaService=0&mdToken=${data.mdToken}`,
      data,
      {
        loading: false
        // 自动登录不显示 loading，避免打扰用户
      }
    );
  },
  // 微信登录 - 自定义 loading
  wechatLogin(data, onComplete) {
    const promise = utils_request.request.post(
      `/service?ssServ=ss.login&wdConfirmationCaptchaService=0`,
      data,
      {
        loading: false,
        // 禁用全局 loading，由登录页面自己控制
        request: {
          timeout: 15e3
          // 微信登录请求 15 秒超时
        }
      }
    );
    if (onComplete) {
      promise.finally(() => {
        onComplete();
      });
    }
    return promise;
  },
  // 获取小程序用户信息
  mp_infoHomep_load(data) {
    return utils_request.request.post(
      `/service?ssServ=mp_infoHomep_load`,
      data,
      {
        loading: true,
        formData: true
      }
    );
  },
  // 更新用户密码和信息
  updPwd(data) {
    return utils_request.request.post(
      `/service?ssServ=updPwd`,
      data,
      {
        loading: true,
        formData: true
      }
    );
  }
};
exports.userApi = userApi;
//# sourceMappingURL=../../.sourcemap/mp-weixin/api/user.js.map
