"use strict";
const common_vendor = require("../common/vendor.js");
const BASE_URL = "/carstop/carbook";
const myRequest = (options) => {
  common_vendor.index.showLoading({
    title: "加载中",
    mask: true
  });
  return new Promise((resolve, reject) => {
    common_vendor.index.request({
      url: BASE_URL + options.url,
      method: options.method || "GET",
      data: options.data || {},
      success: (res) => {
        common_vendor.index.hideLoading();
        if (res.data.code === 200) {
          resolve(res.data.data);
        } else {
          common_vendor.index.showToast({
            title: res.data.message,
            icon: "none"
          });
        }
      },
      fail: (err) => {
        common_vendor.index.hideLoading();
        common_vendor.index.showToast({
          title: "请求数据失败",
          icon: "none"
        });
        reject(err);
      }
    });
  });
};
exports.myRequest = myRequest;
