123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- //#ifdef MP-WEIXIN
- var url = "http://shanghai.keao.tech/wx/";
- var flowableUrl = "http://shanghai.keao.tech/api/";
- var shanghaiUrl = "http://shanghai.keao.tech/adm/";
- var beijingUrl = "http://beijing.keao.tech/adm/";
- var channel = "MP";
- // #endif
- //#ifdef H5
- var url = "/wx/";
- var flowableUrl = "/api/";
- var shanghaiUrl = "/sh/adm/";
- var beijingUrl = "/bj/adm/";
- var channel = "H5";
- // #endif
- function minRequest(options) {
- var action = options.action;
- var data = options.data;
- var success = options.success;
- var error = options.error;
- var fatal = options.fatal;
- var loading = options.loading != false;
- var async = options.async;
- var method = options.method==null?"GET":options.method;
- var lang = options.lang == false ? false : true;
- uni.showLoading({
- title:"加载中..."
- })
- uni.request({
- data: data,
- method: method,
- url: url + action,
- header : {
- 'Authorization' : uni.getStorageSync("Authorization"),
- 'channel' : channel
- },
- success: (res) => {
- uni.hideLoading();
-
- if (res.statusCode == 200) {
- success(res);
- } else {
- if (error) {
- error(res);
- } else {
- uni.showToast({
- icon: 'none',
- title: res.data.message,
- duration: 2000
- });
- }
- }
- },
- fail: (e) => {
- uni.hideLoading();
- if (error) {
- error(e);
- } else {
- uni.showToast({
- icon: 'none',
- title: '操作失败!',
- duration: 2000
- });
- }
- },
- complete: (e) => {
- // uni.hideLoading();
- }
- })
- }
- function flowableRequest(options) {
- var action = options.action;
- var data = options.data;
- var success = options.success;
- var error = options.error;
- var fatal = options.fatal;
- var loading = options.loading != false;
- var async = options.async;
- var method = options.method==null?"GET":options.method;
- var lang = options.lang == false ? false : true;
- var contentType = options.contentType==null?'application/json;charset=UTF-8':options.contentType;
- uni.showLoading({
- title:"加载中..."
- })
-
- var userInfo = uni.getStorageSync("userInfo");
- var branchid = userInfo.branchid;
- uni.request({
- data: data,
- method: method,
- url: flowableUrl + action,
- header : {
- 'Authorization' : uni.getStorageSync("Authorization"),
- "content-type": contentType,
- 'channel' : channel,
- 'branchid' : branchid
- },
- success: (res) => {
- uni.hideLoading();
- if (res.data.status == "0") {
- success(res);
- } else {
- if (res.data.code == "500") {
- uni.showToast({
- icon: 'none',
- title: res.data.message,
- duration: 2000
- });
- } else {
- if (error) {
- error(res);
- } else {
- uni.showToast({
- icon: 'none',
- title: res.data.message,
- duration: 2000
- });
- }
- }
- }
- },
- fail: (e) => {
- uni.hideLoading();
- if (error) {
- error(e);
- } else {
- uni.showToast({
- icon: 'none',
- title: '操作失败!',
- duration: 2000
- });
- }
- },
- complete: (e) => {
- // uni.hideLoading();
- }
- })
- }
- function admRequest(options) {
- var action = options.action;
- var data = options.data;
- var success = options.success;
- var error = options.error;
- var fatal = options.fatal;
- var loading = options.loading != false;
- var async = options.async;
- var method = options.method==null?"GET":options.method;
- var lang = options.lang == false ? false : true;
- var contentType = options.contentType==null?'application/json;charset=UTF-8':options.contentType;
- uni.showLoading({
- title:"加载中..."
- })
-
- var url = "";
- var userInfo = uni.getStorageSync("userInfo");
- // 北京项目
- if (userInfo.branchid == '100741') {
- url = beijingUrl + action;
- // 上海项目
- } else {
- url = shanghaiUrl + action;
- }
- uni.request({
- data: data,
- method: method,
- url: url,
- header : {
- 'Authorization' : uni.getStorageSync("Authorization"),
- "content-type": contentType,
- 'channel' : channel
- },
- success: (res) => {
- uni.hideLoading();
- if (res.statusCode == 200) {
- success(res);
- } else {
- if (error) {
- error(res);
- } else {
- uni.showToast({
- icon: 'none',
- title: res.data.message,
- duration: 2000
- });
- }
- }
- },
- fail: (e) => {
- uni.hideLoading();
- if (error) {
- error(e);
- } else {
- uni.showToast({
- icon: 'none',
- title: '操作失败!',
- duration: 2000
- });
- }
- },
- complete: (e) => {
- // uni.hideLoading();
- }
- })
- }
- function getWxconfig(){
- var m = {};
- m.appID = 'wx3040531f517bec0e';
- m.appsecret = 'af68135110294602911733199448d02f';
- return m;
- }
- export {
- minRequest,
- flowableRequest,
- admRequest,
- getWxconfig
- }
|