min.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. //#ifdef MP-WEIXIN
  2. var url = "http://shanghai.keao.tech/wx/";
  3. var flowableUrl = "http://shanghai.keao.tech/api/";
  4. var shanghaiUrl = "http://shanghai.keao.tech/adm/";
  5. var beijingUrl = "http://beijing.keao.tech/adm/";
  6. var channel = "MP";
  7. // #endif
  8. //#ifdef H5
  9. var url = "/wx/";
  10. var flowableUrl = "/api/";
  11. var shanghaiUrl = "/sh/adm/";
  12. var beijingUrl = "/bj/adm/";
  13. var channel = "H5";
  14. // #endif
  15. function minRequest(options) {
  16. var action = options.action;
  17. var data = options.data;
  18. var success = options.success;
  19. var error = options.error;
  20. var fatal = options.fatal;
  21. var loading = options.loading != false;
  22. var async = options.async;
  23. var method = options.method==null?"GET":options.method;
  24. var lang = options.lang == false ? false : true;
  25. uni.showLoading({
  26. title:"加载中..."
  27. })
  28. uni.request({
  29. data: data,
  30. method: method,
  31. url: url + action,
  32. header : {
  33. 'Authorization' : uni.getStorageSync("Authorization"),
  34. 'channel' : channel
  35. },
  36. success: (res) => {
  37. uni.hideLoading();
  38. if (res.statusCode == 200) {
  39. success(res);
  40. } else {
  41. if (error) {
  42. error(res);
  43. } else {
  44. uni.showToast({
  45. icon: 'none',
  46. title: res.data.message,
  47. duration: 2000
  48. });
  49. }
  50. }
  51. },
  52. fail: (e) => {
  53. uni.hideLoading();
  54. if (error) {
  55. error(e);
  56. } else {
  57. uni.showToast({
  58. icon: 'none',
  59. title: '操作失败!',
  60. duration: 2000
  61. });
  62. }
  63. },
  64. complete: (e) => {
  65. // uni.hideLoading();
  66. }
  67. })
  68. }
  69. function flowableRequest(options) {
  70. var action = options.action;
  71. var data = options.data;
  72. var success = options.success;
  73. var error = options.error;
  74. var fatal = options.fatal;
  75. var loading = options.loading != false;
  76. var async = options.async;
  77. var method = options.method==null?"GET":options.method;
  78. var lang = options.lang == false ? false : true;
  79. var contentType = options.contentType==null?'application/json;charset=UTF-8':options.contentType;
  80. uni.showLoading({
  81. title:"加载中..."
  82. })
  83. var userInfo = uni.getStorageSync("userInfo");
  84. var branchid = userInfo.branchid;
  85. uni.request({
  86. data: data,
  87. method: method,
  88. url: flowableUrl + action,
  89. header : {
  90. 'Authorization' : uni.getStorageSync("Authorization"),
  91. "content-type": contentType,
  92. 'channel' : channel,
  93. 'branchid' : branchid
  94. },
  95. success: (res) => {
  96. uni.hideLoading();
  97. if (res.data.status == "0") {
  98. success(res);
  99. } else {
  100. if (res.data.code == "500") {
  101. uni.showToast({
  102. icon: 'none',
  103. title: res.data.message,
  104. duration: 2000
  105. });
  106. } else {
  107. if (error) {
  108. error(res);
  109. } else {
  110. uni.showToast({
  111. icon: 'none',
  112. title: res.data.message,
  113. duration: 2000
  114. });
  115. }
  116. }
  117. }
  118. },
  119. fail: (e) => {
  120. uni.hideLoading();
  121. if (error) {
  122. error(e);
  123. } else {
  124. uni.showToast({
  125. icon: 'none',
  126. title: '操作失败!',
  127. duration: 2000
  128. });
  129. }
  130. },
  131. complete: (e) => {
  132. // uni.hideLoading();
  133. }
  134. })
  135. }
  136. function admRequest(options) {
  137. var action = options.action;
  138. var data = options.data;
  139. var success = options.success;
  140. var error = options.error;
  141. var fatal = options.fatal;
  142. var loading = options.loading != false;
  143. var async = options.async;
  144. var method = options.method==null?"GET":options.method;
  145. var lang = options.lang == false ? false : true;
  146. var contentType = options.contentType==null?'application/json;charset=UTF-8':options.contentType;
  147. uni.showLoading({
  148. title:"加载中..."
  149. })
  150. var url = "";
  151. var userInfo = uni.getStorageSync("userInfo");
  152. // 北京项目
  153. if (userInfo.branchid == '100741') {
  154. url = beijingUrl + action;
  155. // 上海项目
  156. } else {
  157. url = shanghaiUrl + action;
  158. }
  159. uni.request({
  160. data: data,
  161. method: method,
  162. url: url,
  163. header : {
  164. 'Authorization' : uni.getStorageSync("Authorization"),
  165. "content-type": contentType,
  166. 'channel' : channel
  167. },
  168. success: (res) => {
  169. uni.hideLoading();
  170. if (res.statusCode == 200) {
  171. success(res);
  172. } else {
  173. if (error) {
  174. error(res);
  175. } else {
  176. uni.showToast({
  177. icon: 'none',
  178. title: res.data.message,
  179. duration: 2000
  180. });
  181. }
  182. }
  183. },
  184. fail: (e) => {
  185. uni.hideLoading();
  186. if (error) {
  187. error(e);
  188. } else {
  189. uni.showToast({
  190. icon: 'none',
  191. title: '操作失败!',
  192. duration: 2000
  193. });
  194. }
  195. },
  196. complete: (e) => {
  197. // uni.hideLoading();
  198. }
  199. })
  200. }
  201. function getWxconfig(){
  202. var m = {};
  203. m.appID = 'wx3040531f517bec0e';
  204. m.appsecret = 'af68135110294602911733199448d02f';
  205. return m;
  206. }
  207. export {
  208. minRequest,
  209. flowableRequest,
  210. admRequest,
  211. getWxconfig
  212. }