var e = require("../common/vendor.js"),
  r = require("../utils/request.js"),
  t = require("../enums/index.js");
(exports.createOrder = function (o) {
  var n = o.payMethod,
    i = o.product,
    u = o.money,
    a = o.vin,
    d = o.car_no,
    s = o.engine,
    p = o.type;
  var c = n === t.PayMethodEnum.WECHAT_PAY ? "we" : "ali";
  return r.request({
    url: "/pay/xcx",
    method: "post",
    formData: e._.assign(
      { product: i, money: u, method: c },
      a ? { vin: a } : null,
      d ? { car_no: d } : null,
      s ? { engine: s } : null,
      p ? { type: p } : null
    ),
  });
}),
  (exports.getBlankReportDetail = function (e) {
    var t = e.order_no,
      o = e.product_id;
    return r.request({
      url: "/report/noinfo",
      method: "post",
      formData: { order_no: t, product_id: o },
    });
  }),
  (exports.getConfig = function () {
    return r.request({ url: "/config", method: "get" }).then(function (e) {
      return { config: e };
    });
  }),
  (exports.getOrderDetail = function (e) {
    var t = e.order_no;
    return r.request({
      url: "/order/detail",
      method: "post",
      formData: { order_no: t },
    });
  }),
  (exports.getOrderList = function (e) {
    var t = e.page,
      o = e.status;
    return r.request({
      url: "/order/lists",
      method: "post",
      formData: { page: t, status: o },
    });
  }),
  (exports.getOrderNum = function () {
    return r.request({ url: "/order/count", method: "post" });
  }),
  (exports.getPriceList = function (e) {
    var t = e.vin;
    return r.request({
      url: "/car/price",
      method: "post",
      formData: { vin: t },
      needToast: !1,
    });
  }),
  (exports.getReportDetail = function (e) {
    var t = e.order_no,
      o = e.product_id;
    return r.request({
      url: "/report/detail",
      method: "post",
      formData: { order_no: t, product_id: o },
    });
  }),
  (exports.getUserInfo = function () {
    return r.request({ url: "/user/info", method: "get" }).then(function (r) {
      var t = r.uid,
        o = r.nickname,
        n = r.avatar,
        i = r.vip,
        u = r.vip_limit_time,
        a = r.mobile;
      return {
        token: e.index.getStorageSync("token"),
        openId: e.index.getStorageSync("openId"),
        userId: t,
        userInfo: {
          nickName: o,
          avatar: n,
          vip: i,
          vipLimitTime: u,
          mobile: a,
        },
      };
    });
  }),
  (exports.getUserMobileForMpWeixin = function (e) {
    var t = e.code;
    return r.request({
      url: "/user/xcx/phone",
      method: "post",
      formData: { code: t },
    });
  }),
  (exports.getVehicleInfoDetail = function (e) {
    var t = e.vin;
    return r.request({
      url: "/car/carinfo",
      method: "post",
      formData: { vin: t },
      needToast: !1,
    });
  }),
  (exports.loginForMpWeixin = function (e) {
    var t = e.code,
      o = e.count;
    return r
      .request({
        url: "/login/xcx",
        method: "post",
        formData: { js_code: t },
        count: o,
      })
      .then(function (e) {
        return { token: e.token, openId: e.openid, userId: e.uid };
      });
  }),
  (exports.modifyOrderVin = function (e) {
    var t = e.order_no,
      o = e.vin;
    return r.request({
      url: "/car/modify/vin",
      method: "post",
      formData: { order_no: t, vin: o },
    });
  }),
  (exports.noDrivingLicense = function (e) {
    var t = e.order_no;
    return r.request({
      url: "/car/noimg",
      method: "post",
      formData: { order_no: t },
    });
  }),
  (exports.ocrUploadDrivingLicense = function (e) {
    var t = e.filePath;
    return r.upload({ url: "/ocr/vin", name: "image", filePath: t });
  }),
  (exports.payOrderAgain = function (e) {
    var o = e.payMethod,
      n = e.order_no;
    var i = o === t.PayMethodEnum.WECHAT_PAY ? "we" : "ali";
    return r.request({
      url: "/pay/repay/xcx",
      method: "post",
      formData: { order_no: n, method: i },
    });
  }),
  (exports.uploadDrivingLicense = function (e) {
    var t = e.filePath,
      o = e.order_no;
    return r.upload({
      url: "/car/upload",
      name: "img",
      filePath: t,
      formData: { order_no: o },
    });
  });
