"use strict";const e=require("../common/vendor.js"),o=require("../config.js");require("../uni_modules/uview-plus/index.js");const n=require("../uni_modules/uview-plus/libs/function/index.js");exports.http=(i,s,t)=>new Promise(((d,r)=>{let c=e.index.getStorageSync("token")||"",a=e.index.getStorageSync("version")||e.index.getSystemInfoSync();e.index.getStorageSync("version")||e.index.setStorageSync("version",a);let{deviceId:u,deviceBrand:l,deviceModel:g,osVersion:v}=a,x={deviceId:u,deviceBrand:l,deviceModel:g,osVersion:v,platform:1,Authorization:c};e.index.request({url:o.config.baseUrl+i,data:s||{},method:t||"POST",header:x,success:o=>{if(401==o.statusCode)return e.index.removeStorageSync("token"),e.index.removeStorageSync("user"),e.index.hideLoading(),void e.index.showModal({title:"提示",content:"为提供更好的服务，请前往登录",success:o=>{o.confirm?e.index.navigateTo({url:"/pages/login/login"}):o.cancel&&console.log("用户点击取消")}});const i=o.data;if(10!=i.code||i.success)return 1===i.code||i.success?void d(i.data||null):(n.toast(i.msg),void r(i));r(i)},fail:o=>{if(401==o.statusCode)return e.index.removeStorageSync("token"),e.index.removeStorageSync("user"),e.index.hideLoading(),void e.index.showModal({title:"提示",content:"为提供更好的服务，请前往登录",success:o=>{o.confirm?e.index.navigateTo({url:"/pages/login/login"}):o.cancel&&console.log("用户点击取消")}});const i=o.data;if(1!==i.code&&!i.success)return n.toast(i.msg),void r(i);e.index.hideLoading(),r(o)}})}));
