"use strict";
const common_vendor = require("../common/vendor.js");
const components_addPrefixToHeaderIcon = require("./addPrefixToHeaderIcon.js");
function request(urldata) {
  const { url, data, method, header, userInfo } = urldata;
  const baseUrl = "http://120.26.251.180:8086/" + url;
  if (userInfo) {
    return new Promise((resolve, reject) => {
      common_vendor.index.getStorage({
        key: "userinfo",
        success: (res) => {
          if (res.data) {
            if (res.data.nickName) {
              common_vendor.index.request({
                url: baseUrl,
                data,
                method,
                header,
                success: function(res2) {
                  resolve(components_addPrefixToHeaderIcon.addPrefixToHeaderIcon(res2.data));
                },
                fail: function(res2) {
                  reject(res2);
                }
              });
            } else {
              common_vendor.index.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
              common_vendor.index.reLaunch({ url: "/pages/UserInformation/UserInformation" });
            }
          } else {
            common_vendor.index.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
            common_vendor.index.navigateTo({ url: "/pages/login/login" });
          }
        },
        fail: function(res) {
          common_vendor.index.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
          common_vendor.index.navigateTo({ url: "/pages/login/login" });
          reject(res);
        }
      });
    });
  } else {
    return new Promise((resolve, reject) => {
      common_vendor.index.request({
        url: baseUrl,
        data,
        method,
        header,
        success: function(res) {
          resolve(components_addPrefixToHeaderIcon.addPrefixToHeaderIcon(res.data));
        },
        fail: function(res) {
          reject(res);
        }
      });
    });
  }
}
exports.request = request;
//# sourceMappingURL=../../.sourcemap/mp-weixin/components/request.js.map
