httpRequest_tbr.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /**
  2. * 有关 访问服务器的uri
  3. */
  4. var $http = function() {
  5. // this.ip = "http://192.168.242.26:9002";
  6. //this.ip = "http://b2bcnapi.sailuntire.com/api/test/web";
  7. //this.ip = "http://b2bcnapi.sailuntire.com/api/web";
  8. //this.ip = "http://192.168.237.6/api/web";
  9. this.ip = "http://b2bcnapi.sailuntire.com/allstell/test/app";//测试
  10. // this.ip = "http://b2bcnapi.sailuntire.com/allstell/app";//正式
  11. /****** 用户相关 ******/
  12. // 根据省获取经销商
  13. this.getUpuserByProvideUrl = "/base/agent/listByArea";
  14. // 注册用户
  15. this.regizeUrl = "/bizLogin/registRetailer";
  16. // 登录用户
  17. this.loginUrl = "/biz/bizAgentLogin/login";
  18. // 收取短信验证码---新增
  19. this.getPhoneCode = '/web/bizLogin/sendCode';
  20. // 根据loginid获取用户信息
  21. // this.getUserInfoUrl = "/base/retailer/loginToInfo";
  22. /******* 订单相关 ********/
  23. // 查看剩余库存
  24. this.getStockUrl_old = "/bizAgentStock/page";
  25. this.getStockUrl = "/base/material/pageMaterialStock";
  26. // 添加商品到购物车
  27. this.addCarUrl = "/bizCart/save";
  28. // 获取购物车列表
  29. this.shopCarListUrl = "/bizCart/list";
  30. // 获取商品详情
  31. this.getInfoUrl = "/base/material/info";
  32. // 下单传 {"retailerId":"212","amounr":100,"bizCartDtoList":[{"id":121...},{"id":12..}] 这里把购物车的列表给我}
  33. this.downOrderUrl = "/base/bizOrder/save";
  34. // 删除购物车 --删除一个
  35. this.deleteCar = "/bizCart/deleteOne";
  36. // 删除购物车记录 -- 珊瑚多个
  37. this.deleteCars = "/bizCart/delete";
  38. // 获取订单列表
  39. this.getOrderListUrl = "/base/bizOrder/page";
  40. // 获取门店订单
  41. this.getStoreOrderListUrl = "/base/bizOrder/selectStore";
  42. // 获取订单详情
  43. this.getOrderInfo = "/base/bizOrder/info";
  44. // ---------- 525 ---------
  45. // 获取库存详情
  46. this.getKucunInfoUrl = "/bizRetailerStock/page";
  47. // 获取商品类别
  48. this.getStoreTypeUrl = "/bizGoodsType/list";
  49. // 添加商品类别
  50. this.addStoreTypeUrl = "/bizGoodsType/save";
  51. // 添加商品
  52. this.addStoreUrl = "/bizGoods/saveGoods";
  53. // 查看自己的供应商
  54. this.getSupplierUrl = "/bizSupplier/list";
  55. // 根据条形码查询商品
  56. this.getStoreByScanUrl = "/bizGoods/selectBySerialNumber";
  57. // 添加供应商
  58. this.addSupplierUrl = "/bizSupplier/save";
  59. // 进货
  60. this.buyStoreUrl = "/bizBills/save";
  61. // 单据
  62. this.buyListUrl = "/bizBills/page";
  63. // 商品详情
  64. this.getStoreInfoUrl = "/bizGoods/info";
  65. // 获取经销商详情
  66. this.getUserInfoUrl = "/base/agent/infoByCode";
  67. //查询经销商库存的查询条件列表
  68. this.getStoreAgentCondition = "/app/appAgent/getStoreAgentCondition";
  69. // 经销商查询自己库存
  70. this.checkStoreUrl = "/app/appAgent/getAgentStock";
  71. // 经销商查询b2b订单
  72. this.b2bOrderList = "/biz/bizOrderTracking/orderCheckHead";
  73. this.b2bOrderInfo = "biz/bizOrderTracking/orderCheckDetail";
  74. this.b2bOrderTrans = "";
  75. this.checkOrderUrl = "/base/bizOrder/page";
  76. // 接单退单
  77. this.orderReviceUrl = "/base/bizOrder/update";
  78. // 传agentId 经销商的库存根据品牌分
  79. this.getStockByBrand = "/bizAgentStock/selectGroupBrand";
  80. // 经销商下的门店
  81. this.getRetailerUrl = "/store/storeAgentBrandLv/getStoresByAgentId";
  82. this.getRetailerUrl_old = "/base/retailerAgent/page";
  83. //搜索门店
  84. this.getRetailerSearch="/biz/bizStoreBasicInfo/selectSearch"
  85. // 审核门店
  86. this.checkRetailerUrl = "/biz/bizAudit/update";
  87. // 消息列表
  88. this.getNewsList = "/bizSms/page";
  89. // 获取经销商签约品牌
  90. this.getBrandUrl = "/bizAgentBrand/list";
  91. // 获取经销商下的物流信息
  92. this.getWuLiuUrl = "/base/agent/selectPageCar";
  93. // 获取经销商断下物流的车辆信息
  94. this.getCarInfoUrl = "/base/agent/carNowPosition";
  95. // 修改经销商下的库存
  96. this.upDateStockUrl = "/bizAgentStock/update";
  97. // 检查版本
  98. this.getVersionUrl = "/biz/getAppVersion";
  99. // 获取经销商下门店订单
  100. this.getAgentList = "/base/bizOrder/selectStore";
  101. // 审核门店订单
  102. this.handerOrderUrl = "/base/bizOrder/updateTake";
  103. // 经销商查询工厂库存
  104. this.checkFactoryStoreUrl = "/biz/bizAgentLogin/showMateriafPRC";
  105. // 获取经销商信息
  106. this.getMeberInfoU = "/app/appAgent/getClientBasicMsg";
  107. // 门店注册审核通过
  108. this.passSignForBatch = "/store/storeAgentBrandLv/passSignForBatch";
  109. // 门店注册审核拒绝
  110. this.refuseSignForBatch = "/store/storeAgentBrandLv/refuseSignForBatch";
  111. // 获取订单详情
  112. this.getAgentOrderInfoU = "/biz/bizOrderInfo/selectOrderInfo";
  113. // 获取门店详情
  114. this.getAgentInfoU = "/store/storeAgentBrandLv/getStoreInfoAndBrandSignInfo";
  115. // 删除门店签约品牌
  116. this.deleteSignInfo = "/store/storeAgentBrandLv/deleteSignInfo";
  117. // 查看订单详情
  118. this.getOrderInfoU = "/biz/bizOrderInfo/selectOrderInfo";
  119. // 审核门店核销码
  120. this.checkConponU = "/myapp/agentCheckCoupon";
  121. // 查看门店核销码列表
  122. this.getCheckListU = "/myapp/agentSelectCoupon";
  123. // 查询门店进货分析列表
  124. this.getIntoStoreU = "/biz/bizGoods/agentSelectStoreRecord"
  125. // 获取门店进货分析列表
  126. this.getInfoStoreU_jiage = "/app/appAgent/agentSelectStoreRecord";
  127. // 查看门店返利明细
  128. this.getBackMoneyListU = "/biz/bizStoreReward/page";
  129. // 查询b2b订单详情
  130. this.getB2bOrderInfoU = "/biz/bizOrderTracking/orderCheckDetail";
  131. // 获取文章 根据ID
  132. this.getOneDetails="/homepage/getArticleOne";
  133. // 检查版本更新
  134. this.checkVersionU = "/baseReq/agentVersion"
  135. this.getIntoStoreU = "/biz/bizGoods/agentSelectStoreRecord";
  136. //获取跑马灯list
  137. this.getMessageList="/homepage/noticeList";
  138. //轮播图
  139. this.getAgentBanner="/homepage/getBanners";
  140. //核销查询
  141. this.selectCouponLike="/biz/bizCoupon/selectCouponLike";
  142. }
  143. // api的ajax
  144. $http.prototype.$post = function(url, data, callback, other) {
  145. var content = "", urlT = "";
  146. if (data.url == "json") {
  147. delete data.url;
  148. // 确认contenttype选项
  149. content = "application/json;charset=UTF-8";
  150. } else {
  151. content = "application/x-www-form-urlencoded"
  152. }
  153. var datas = this.serize(data);
  154. if ( typeof other != 'undefined' && other != "" && other != 'undefined') {
  155. urlT = this.ip + eval('this.' + url) + '/' + other;
  156. } else {
  157. urlT = this.ip + eval('this.' + url);
  158. }
  159. api.showProgress({
  160. });
  161. // console.log(urlT)
  162. // console.log(JSON.stringify(datas))
  163. api.ajax({
  164. url : urlT,
  165. method : 'post',
  166. data : datas,
  167. headers : {
  168. "Content-type" : content
  169. },
  170. }, function(ret, err) {
  171. // console.log(JSON.stringify(ret))
  172. api.hideProgress();
  173. api.refreshHeaderLoadDone();
  174. if (ret) {
  175. callback(ret);
  176. } else {
  177. api.toast({
  178. msg: '当前网络不稳定,请稍后再试'
  179. });
  180. }
  181. });
  182. }
  183. // get方法
  184. $http.prototype.$get = function(url, data, callback, other) {
  185. var urlT = other == 'formdata' ? (this.ip + eval('this.' + url)) : (this.ip + eval('this.' + url) + '?' + data);
  186. api.showProgress({
  187. });
  188. api.ajax({
  189. url : urlT,
  190. method : 'get',
  191. data : {},
  192. headers : {
  193. "Content-type" : "application/json;charset=UTF-8"
  194. },
  195. }, function(ret, err) {
  196. api.hideProgress();
  197. api.refreshHeaderLoadDone();
  198. if (ret) {
  199. callback(ret);
  200. } else {
  201. api.toast({
  202. msg: '当前网络不稳定,请稍后再试'
  203. });
  204. }
  205. });
  206. }
  207. // 对数据进行处理,第一个为values,第二个为file body
  208. $http.prototype.serize = function(data) {
  209. var serizeData;
  210. if ( data instanceof Array) {
  211. if (data.length > 1) {
  212. serizeData = {
  213. values : data[0]
  214. }
  215. } else {
  216. serizeData = {
  217. values : data[0],
  218. files : data[1]
  219. }
  220. }
  221. } else {
  222. if (data.type == 'body') {
  223. delete data.type;
  224. if (data.yy == 'keng') {
  225. delete data.yy
  226. serizeData = {
  227. body : data.id
  228. }
  229. } else {
  230. serizeData = {
  231. body : data
  232. }
  233. }
  234. } else {
  235. serizeData = {
  236. values : data
  237. }
  238. }
  239. }
  240. return serizeData;
  241. }
  242. function alertJson(str) {
  243. alert(JSON.stringify(str));
  244. }