httpRequest_tbr.js 8.3 KB

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