"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;
  },
  // 自动登录 - 静默登录，不显示 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;
  }
};
exports.userApi = userApi;
//# sourceMappingURL=../../.sourcemap/mp-weixin/api/user.js.map
