//#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 }