httpRequest.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. /**
  2. * 有关 访问服务器的uri
  3. */
  4. var $http = function () {
  5. this.ajaxLock = false;
  6. this.ip = "http://140.249.54.193:9002";
  7. // this.ip = "http://192.168.137.73:9002";
  8. //this.ip = "http://b2bcnapi.sailuntire.com/api";
  9. //this.ip = "http://b2bcnapi.sailuntire.com/api/test";
  10. //this.ip="http://192.168.242.19:9002"
  11. /****** 用户相关 ******/
  12. // 选择图片生成地址
  13. this.getUrlByFileUrl = "/web/file/upload";
  14. // 根据省获取经销商
  15. this.getUpuserByProvideUrl = "/web/bizLogin/testPostApi";
  16. // 注册用户
  17. this.regizeUrl = "/web/bizLogin/registRetailer";
  18. // 登录用户
  19. this.loginUrl = "/web/bizLogin/login";
  20. // 根据loginid获取用户信息
  21. // this.getUserInfoUrl = "/base/retailer/loginToInfo";
  22. /******* 订单相关 ********/
  23. // 查看剩余库存
  24. this.getStockUrl_old = "/jinyu/bizAgentStock/page";
  25. this.getStockUrl = "/base/material/pageMaterialStock";
  26. // 添加商品到购物车
  27. this.addCarUrl = "/jinyu/bizCart/save";
  28. // 获取购物车列表
  29. this.shopCarListUrl = "/jinyu/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 = "/jinyu/bizCart/deleteOne";
  36. // 删除购物车记录 -- 珊瑚多个
  37. this.deleteCars = "/jinyu/bizCart/delete";
  38. // 获取订单列表
  39. this.getOrderListUrl = "/base/bizOrder/page";
  40. // 获取订单详情
  41. this.getOrderInfo = "/base/bizOrder/info";
  42. // ---------- 525 ---------
  43. // 获取库存详情
  44. this.getKucunInfoUrl = "/jinyu/bizRetailerStock/page";
  45. // 获取商品类别
  46. this.getStoreTypeUrl = "/jinyu/bizGoodsType/list";
  47. // 添加商品类别
  48. this.addStoreTypeUrl = "/jinyu/bizGoodsType/save";
  49. // 添加商品
  50. this.addStoreUrl = "/jinyu/bizGoods/saveGoods";
  51. // 查看自己的供应商
  52. this.getSupplierUrl = "/jinyu/bizSupplier/list";
  53. // 根据条形码查询商品
  54. this.getStoreByScanUrl = "/jinyu/bizGoods/selectBySerialNumber";
  55. // 添加供应商
  56. this.addSupplierUrl = "/jinyu/bizSupplier/save";
  57. // 进货
  58. this.buyStoreUrl = "/jinyu/bizBills/save";
  59. // 单据
  60. this.buyListUrl = "/jinyu/bizBills/page";
  61. // 商品详情
  62. this.getStoreInfoUrl = "/jinyu/bizGoods/info";
  63. // 选择品牌
  64. this.chooseBrandUrl = "/base/brand/list";
  65. // 根据扫出来的码获取商品信息(进销存) -- 需要后面拼接
  66. this.jinstoreByScanUrl = "/base/material/infoByKey";
  67. // 获取门店经销商列表
  68. this.getSupplierListUrl = "/base/retailerAgent/list";
  69. // 经销商查询自己库存
  70. // this.checkStoreUrl = "/jinyu/bizAgentStock/page";
  71. this.checkStoreUrl_old = "/jinyu/bizAgentStock/page";
  72. this.checkStoreUrl = "/jinyu/bizAgentStock/pageOwn";
  73. // 扫码商品 0705
  74. this.addStoreByScanUrl = "/jinyu/bizGoods/selectBySerialNumberAndRetailerId";
  75. // 入库扫码
  76. this.addOrgoScanUrl = '/jinyu/bizGoods/selectInBySerialNumberAndRetailerId';
  77. // 出库扫码
  78. this.outScanUrl = '/jinyu/bizGoods/selectOutBySerialNumberAndRetailerId';
  79. /********* 0706 ***********/
  80. // 收取短信验证码
  81. this.getPhoneCode = '/web/bizLogin/sendCode';
  82. // 获取客户信息
  83. this.customListUrl = '/web/bizCustomRetailer/page';
  84. // 获取门店详情
  85. this.getMDInfo = "/base/retailer/retailerInfo";
  86. // 获取所有的轮胎服务类目
  87. this.getServices = "/base/service/list";
  88. // 添加服务
  89. this.addServices = "/jinyu/bizRetailerService/save";
  90. // 根据品牌统计库存
  91. this.getStockByPP = "/jinyu/bizRetailerStock/selectStockByBrand";
  92. // 获取积分
  93. this.getJFStore = "/jinyu/bizMall/page";
  94. // 获取新闻条
  95. this.getNews = "/jinyu/bizArticle/page";
  96. // 根据品牌获取上级代理商
  97. this.getUpByBrand = "/jinyu/bizAgentBrand/listByAgentIds";
  98. // 根据品牌和省市获取上级代理商
  99. this.getUpByBrandAndArea = "/jinyu/bizAgentBrand/listByBrandIds";
  100. // 获取门店积分列表
  101. this.getJFlistUrl = "/jinyu/bizRetailerIntegral/page";
  102. // 兑换商品
  103. this.exchangeUrl = "/jinyu/bizMallOrder/save";
  104. // 查看兑换记录
  105. this.exchangeListUrl = "/jinyu/bizMallOrder/page";
  106. // 检查版本
  107. this.getVersionUrl = "/web/biz/getAppVersion";
  108. // 活动banner
  109. this.getBannerUrl = "/biz/bizBanner/list";
  110. // 获取参加活动的商品
  111. this.getStoreBannerUrl = "/biz/bizActivity/activityInfo";
  112. // 根据条形码获取商品
  113. this.getStoreByScan = "/web/biz/bizGoods/Scancoderemotecall";
  114. // 获取经销商对应物料列表
  115. this.getStoreListU = "/web/biz/bizCoupon/select";
  116. // 添加商品至购物车
  117. this.addStoreToCarU = "/web/biz/bizCart/save";
  118. // 获取购物车列表
  119. this.getCarListU = "/web/biz/bizCart/selectCart";
  120. //线上订货修改购物车数量
  121. this.updateCarNum = "/web/biz/bizCart/update"
  122. // 从购物车下单
  123. this.downOrderU = "/web/base/bizOrder/save";
  124. // 扫码确定
  125. this.scanDoneU = "/web/biz/bizGoods/Scancode";
  126. //签约级别
  127. this.signLv = "/web/bizLogin/enum";
  128. // 门店立即抢购
  129. this.rushToBuyU = "/web/base/bizOrder/directSave";
  130. // 门店查询订单
  131. this.getOrderListU = "/web/base/bizOrder/selectStore";
  132. // 门店获取订单详情
  133. this.getOrderInfoU = "/web/biz/bizOrderInfo/selectOrderInfo";
  134. // 获取门店参保列表接口
  135. this.getInsuranceU = "/web/sailun/insurance/getInsuranceList";
  136. // 获取门店详情
  137. this.getAgentInfoU = "/web/biz/bizAudit/store";
  138. // 扫码入库
  139. this.sacaCodeIn = "/web/biz/bizGoods/ScanCodeIn";
  140. // 获取轮胎理赔详情
  141. this.getLipeiList = "/web/sailun/insurance/getInsuranceList";
  142. // 通过胎号获取理赔单详情
  143. this.getLipeiInfoU = "/web/sailun/insurance/getTireClaimInfo";
  144. // 理赔图片的上传
  145. this.uploadLipeU = "/web/sailun/insurance/tireImageUpload";
  146. // 提交轮胎保理赔记录
  147. this.sumbiltLipeiU = "/web/sailun/insurance/submitTireClaim";
  148. // 获取入库记录
  149. this.getIntoListU = "/web/sailun/insurance/getStoreClaimList";
  150. // 获取出入库记录
  151. this.getinOrOutU = "/web/biz/bizGoods/Incomingandoutgoingrecordsquery";
  152. // 获取赔付记录
  153. this.peifuListU = "/web/sailun/insurance/getStoreClaimList";
  154. // 扫码出库
  155. this.outStoreU = "/web/biz/bizGoods/ScanCodeOut";
  156. // 获取签约等级
  157. this.getSignLvU = "/web/bizLogin/enum";
  158. // 门店查询经销商库存
  159. this.getStockListU = "/web/biz/bizAudit/QueryStoreAgentStock";
  160. // 删除购物车记录
  161. this.delCarMataxU = "/web/biz/bizCart/deleteOne";
  162. // 获取理赔单详情
  163. this.getTlementInfoU = "/web/sailun/insurance/getTireInfo";
  164. // 生成核销code
  165. this.getHxCodeU = "/web/biz/bizCoupon/save";
  166. // 获取门店门店核销码列表
  167. this.getHxListU = "/web/biz/bizCoupon/selectCoupon";
  168. // 获取物料筛选条件
  169. this.getWuliaoAntionU = "/web/biz/bizCoupon/condition";
  170. //请求文章 根据id
  171. this.getOneDetails = "/web/biz/bizArticle/getOneDetails";
  172. //厂家宣传
  173. // this.getArticle="/web/biz/bizArticle/list"
  174. // 获取地址管理
  175. // this.getAddress="/sys/bizReceiptAddress/paget"
  176. // 获取地址列表
  177. this.getAddressListU = "/web/sys/bizReceiptAddress/page";
  178. // 门店新增收货地址
  179. this.addAddressU = "/web/sys/bizReceiptAddress/save";
  180. // 查看门店自己的优惠券
  181. // this.searchKuCunU = "/web/sys/bizStoreRegistrationSpree/page";
  182. /// 查看门店自己的库存
  183. this.searchKuCunU = "/web/biz/bizGoods/storeSelectStock";
  184. // 门店查询返利明细
  185. this.lookUserTotalU = "/web/biz/bizStoreReward/page";
  186. // 获取优惠券
  187. this.getCouponListU = "/web/sys/bizStoreRegistrationSpree/page";
  188. // 查询门店进货分析
  189. this.getStoreIntoListU = "/web/base/bizOrder/caculateStore";
  190. // 检查版本
  191. this.checkVersionU = "/web/biz/getAppVersion?type=3";
  192. // ios检查版本
  193. this.ioscheckVersionU = "/web/biz/getAppVersion?type=1";
  194. // 上传门店车辆图片接口
  195. this.uploadCarPhotoU = "/web/sailun/insurance/carPictureUpload";
  196. //我的供应商
  197. this.getSupplier = "/web/biz/bizStoreAgent/mySuppliers";
  198. //获取跑马灯list
  199. this.getMessageList = "/web/mobile/sysMessage/getMessageList";
  200. //获取新版本
  201. this.getNewVersionU = "/web/file/getShopApk";
  202. //上传门店行驶证照片
  203. this.uploadUserCarU = "/web/sailun/insurance/carPictureUpload";
  204. //离线缓存工单
  205. this.saveJxItemU = "/event/queryEventLX/";
  206. //轮播图
  207. this.getbannerLists = "/web/biz/bizStoreBrand/selectStoreBrandBanner";
  208. //获取商品分类
  209. this.getTypes = "/web/biz/bizGoodsType/selectProductCategory";
  210. // 获取商品
  211. this.getshopLists = "/web/biz/bizGoodsType/selectCategoryItem";
  212. //加入购物车
  213. this.addShopCart = "/web/sailun/bizIntegralCart/save";
  214. //查看购物车
  215. this.getShopCart = "/web/sailun/bizIntegralCart/page";
  216. //修改购物车数量
  217. this.fixCartNum = "/web/sailun/bizIntegralCart/update";
  218. //删除购物车
  219. this.delCart = "/web/sailun/bizIntegralCart/deletes";
  220. //下单
  221. this.addOrder = "/web/biz/bizShopIntegralOrder/save";
  222. //查看兑换记录
  223. this.getOrderannal = "/web/biz/bizIntegralOrderItem/page";
  224. //积分商场详情
  225. this.getProductImage = "/web//sailun/bizProductImage/storeProductItem";
  226. //收货地址查询
  227. this.getReceiptAddress = "/web/sys/bizReceiptAddress/list";
  228. // 立即下单
  229. this.immediatelyOrder = "/web/biz/bizShopIntegralOrder/immediatelyOrder";
  230. //查找更换收后地址
  231. this.updateAddress = "/web/sys/bizReceiptAddress/update";
  232. //删除收货地址
  233. this.addressDel="/web/sys/bizReceiptAddress/delete";
  234. //根据商品名搜索积分商品
  235. this.searchShop="/web/biz/bizCart/appSelectProduct";
  236. //查找订单
  237. this.searchOrder="/web/biz/bizIntegralOrderItem/selectIntegralOrderProduct"
  238. //消息列表
  239. this.getMsg="/web/sailun/bizMessageForUser/getMessageCategory";
  240. //消息详情
  241. this.getMsgdetails="/web/sailun/bizMessageForUser/list";
  242. //消息已阅
  243. this.updateMessage="/web/sailun/bizMessageForUser/updateMessage";
  244. //修改签约地址
  245. this.updatesign="/web/biz/bizStoreUpdateMessage/save";
  246. //查看签约地址
  247. this.getsignAddress="/web/biz/bizStoreUpdateMessage/list";
  248. //查看核销详情页
  249. this.hexiaoInfo="/web/biz/bizCoupon/list";
  250. //季度任务数据
  251. this.selectQuarter="/web/biz/bizScanRecord/selectQuarter";
  252. //提交用户信息
  253. this.MobileMessage="/web/biz/bizMobileMessage/save";
  254. //修改签约
  255. this.SignlvUpdate="/web/biz/bizStoreUpdateSignlv/save";
  256. //查看签约
  257. this.SignlvList="/web/biz/bizStoreUpdateSignlv/list";
  258. /**********************************车主下单功能***********************************/
  259. //根据门店id获取所有门店微信订单信息
  260. this.getAllUndealCarOrder="/web/sailun/wxCarorderHead/caroder/getAllUndealCarOrderByStoreId";
  261. this.getOrderInfo = "/web/sailun/wxCarorderHead/carorder/getOrderInfoById";
  262. this.getStoreToMaktxInfoByBSP = "/web/biz/bizGoods/getStoreToMaktxInfoByBSP";
  263. this.updateStoreToMaktxInfoByBSP = "/web/biz/bizGoods/updateStoreToMaktxInfoByBSP";
  264. this.changeWxCarOrderStatus = "/web/sailun/wxCarorderHead/carorder/changeWxCarOrderStatus";
  265. /**********************************对账功能***********************************/
  266. this.getConfirmMonth = "/web/biz/bizMonthDetail/getConfirmMonth";//获取已确认的月份
  267. this.getMonthDetail = "/web/biz/bizMonthDetail/getMonthDetail";//获取月结明细
  268. this.confirmMonthDetail = "/web/biz/bizMonthDetail/confirmMonthDetail";//确认月结明细
  269. this.getRegistTime = "/web/biz/bizMonthDetail/getRegistTime";//获取门店注册时间
  270. //通过图片获取信息
  271. this.licenseDiscern="/web/bizLogin/licenseDiscern";
  272. //运营执行信息是否有效
  273. this.verifyBusiness="/web/bizLogin/verifyBusiness";
  274. //上传运营图片
  275. this.storeUpdatalicense="/web/biz/bizStoreBasicInfo/storeUpdateLicense"
  276. //解冻
  277. this.storeUnfreezeProposer="/web/biz/bizAgentFunction/storeUnfreezeProposer"
  278. // 获取修改提示
  279. this.getStoreSignMessage= "/web/biz/getStoreSignMessage"
  280. //获取优惠券
  281. this.storeCouponMessage="/web/biz/bizGoods/storeCouponMessage"
  282. //获取优惠券余数
  283. this.residueCoupon="/web/biz/bizGoods/residueCoupon"
  284. //更改修改状态
  285. this.Couponupdate="/web/sys/bizStoreRegistrationSpree/update"
  286. //返回时更改修改状态
  287. this.CouponupdateStatus="/web/sys/bizStoreRegistrationSpree/updateStatus"
  288. //爆款活动接口
  289. this.PromoteSale="/web/biz/hotActivity/entry/1"
  290. }
  291. $http.prototype.$postFile = function (url, data, callback) {
  292. var urlT = this.ip + eval('this.' + url);
  293. api.ajax({
  294. url: urlT,
  295. method: 'post',
  296. data: {
  297. values: data
  298. },
  299. headers: {
  300. "Content-type": "multipart/form-data"
  301. },
  302. }, function (ret, err) {
  303. api.hideProgress();
  304. api.refreshHeaderLoadDone();
  305. if (ret) {
  306. callback(ret);
  307. } else {
  308. api.toast({
  309. msg: '当前网络不稳定,请稍后再试'
  310. });
  311. }
  312. });
  313. }
  314. // api的ajax
  315. $http.prototype.$post = function (url, data, callback, other) {
  316. var content = "", urlT = "", _this = this;
  317. if (data.url == "json") {
  318. delete data.url;
  319. // 确认contenttype选项
  320. content = "application/json;charset=UTF-8";
  321. } else if (data.url == "file") {
  322. data = [{}, {
  323. file: data[1].file
  324. }]
  325. content = "application/json;charset=UTF-8";
  326. } else {
  327. content = "application/x-www-form-urlencoded"
  328. }
  329. var datas = this.serize(data);
  330. if (typeof other != 'undefined' && other != "" && other != 'undefined') {
  331. urlT = this.ip + eval('this.' + url) + '/' + other;
  332. } else {
  333. urlT = this.ip + eval('this.' + url);
  334. }
  335. api.showProgress({
  336. });
  337. if (this.ajax == true) {
  338. return;
  339. }
  340. this.ajax = true;
  341. // if (url=="getCarListU"){
  342. // console.log("url"+urlT);
  343. // console.log(JSON.stringify(datas));
  344. // console.log(JSON.stringify(content));
  345. // }
  346. api.ajax({
  347. url: urlT,
  348. method: 'post',
  349. data: datas,
  350. headers: {
  351. "Content-type": content,
  352. },
  353. }, function (ret, err) {
  354. _this.ajax = false;
  355. api.hideProgress();
  356. api.refreshHeaderLoadDone();
  357. if (ret) {
  358. callback(ret);
  359. } else {
  360. api.toast({
  361. msg: '当前网络不稳定,请稍后再试'
  362. });
  363. }
  364. });
  365. }
  366. //特殊post api
  367. $http.prototype.$postuser = function (url, data, callback, other) {
  368. var content = "", urlT = "", _this = this;
  369. if (data.url == "json") {
  370. delete data.url;
  371. // 确认contenttype选项
  372. content = "application/json;charset=UTF-8";
  373. } else if (data.url == "file") {
  374. data = [{}, {
  375. file: data[1].file
  376. }]
  377. content = "application/json;charset=UTF-8";
  378. } else {
  379. content = "application/x-www-form-urlencoded"
  380. }
  381. var datas = this.serize(data);
  382. if (typeof other != 'undefined' && other != "" && other != 'undefined') {
  383. urlT = this.ip + eval('this.' + url) + '/' + other;
  384. } else {
  385. urlT = this.ip + eval('this.' + url);
  386. }
  387. api.showProgress({
  388. });
  389. if (this.ajax == true) {
  390. return;
  391. }
  392. this.ajax = true;
  393. api.ajax({
  394. url: urlT,
  395. method: 'post',
  396. data: datas,
  397. headers: {
  398. "Content-type": content,
  399. },
  400. }, function (ret, err) {
  401. _this.ajax = false;
  402. api.hideProgress();
  403. api.refreshHeaderLoadDone();
  404. if (ret) {
  405. callback(ret);
  406. } else {
  407. api.toast({
  408. msg: '当前网络不稳定,请稍后再试'
  409. });
  410. }
  411. });
  412. }
  413. // 单独的get请求
  414. $http.prototype.$getadd = function (url, data, callback, other) {
  415. var _this = this;
  416. api.showProgress({
  417. });
  418. this.ajax = true;
  419. api.ajax({
  420. url: this.ip + eval('this.' + url) + data,
  421. method: 'get',
  422. data: {
  423. values: {
  424. }
  425. },
  426. headers: {
  427. "Content-type": "application/json;charset=UTF-8"
  428. },
  429. }, function (ret, err) {
  430. _this.ajax = false;
  431. api.hideProgress();
  432. api.refreshHeaderLoadDone();
  433. if (ret) {
  434. callback(ret);
  435. } else {
  436. api.toast({
  437. msg: '当前网络不稳定,请稍后再试'
  438. });
  439. }
  440. });
  441. }
  442. // get获取
  443. $http.prototype.$get = function (url, data, callback, other) {
  444. var content = "", urlT = "", _this = this;
  445. if (data.url == "json") {
  446. delete data.url;
  447. // 确认contenttype选项
  448. content = "application/json;charset=UTF-8";
  449. } else {
  450. content = "application/x-www-form-urlencoded"
  451. }
  452. var datas = this.serize(data);
  453. if (typeof other != 'undefined' && other != "" && other != 'undefined') {
  454. urlT = this.ip + eval('this.' + url) + '/' + other;
  455. } else {
  456. urlT = this.ip + eval('this.' + url);
  457. }
  458. api.showProgress({
  459. });
  460. if (this.ajax == true) {
  461. return;
  462. }
  463. this.ajax = true;
  464. api.ajax({
  465. url: urlT,
  466. method: 'get',
  467. data: {
  468. values: {
  469. }
  470. },
  471. headers: {
  472. "Content-type": "application/json;charset=UTF-8"
  473. },
  474. }, function (ret, err) {
  475. _this.ajax = false;
  476. api.hideProgress();
  477. api.refreshHeaderLoadDone();
  478. if (ret) {
  479. callback(ret);
  480. } else {
  481. api.toast({
  482. msg: '当前网络不稳定,请稍后再试'
  483. });
  484. }
  485. });
  486. }
  487. // 在链接后面拼接参数
  488. $http.prototype.$getOption = function (url, other, callback) {
  489. var _this = this;
  490. api.showProgress({
  491. });
  492. if (typeof other != 'undefined' && other != "" && other != 'undefined') {
  493. urlT = this.ip + eval('this.' + url) + '?' + other;
  494. } else {
  495. urlT = this.ip + eval('this.' + url);
  496. }
  497. api.ajax({
  498. url: urlT,
  499. method: 'get',
  500. data: {
  501. values: {
  502. }
  503. },
  504. headers: {
  505. "Content-type": "application/json;charset=UTF-8"
  506. },
  507. }, function (ret, err) {
  508. _this.ajax = false;
  509. api.hideProgress();
  510. api.refreshHeaderLoadDone();
  511. if (ret) {
  512. callback(ret);
  513. } else {
  514. api.toast({
  515. msg: '当前网络不稳定,请稍后再试'
  516. });
  517. }
  518. });
  519. }
  520. // 单独的有文件名字的上传文件
  521. $http.prototype.uploadfile = function (url, data, callback) {
  522. var _this = this;
  523. var urlT = this.ip + eval('this.' + url);
  524. var formdata = new FormData();
  525. formdata.append('file', data.file);
  526. formdata.append('type', data.type);
  527. api.showProgress({
  528. });
  529. $.ajax({
  530. url: urlT,
  531. type: "POST",
  532. data: formdata,
  533. processData: false, // 告诉jQuery不要去处理发送的数据
  534. contentType: false, // 告诉jQuery不要去设置Content-Type请求头
  535. success: function (ret, status, xhr) {
  536. api.hideProgress();
  537. if (ret.code == 0 || ret.code == '0') {
  538. callback(ret);
  539. }
  540. }
  541. });
  542. }
  543. // 对数据进行处理,第一个为values,第二个为file body
  544. $http.prototype.serize = function (data) {
  545. var serizeData;
  546. if (data instanceof Array) {
  547. if (data.length == 1) {
  548. serizeData = {
  549. values: data[0]
  550. }
  551. } else {
  552. serizeData = {
  553. values: data[0],
  554. files: data[1]
  555. }
  556. }
  557. } else {
  558. if (data.type == 'body') {
  559. delete data.type;
  560. if (data.yy == 'keng') {
  561. delete data.yy
  562. serizeData = {
  563. body: data.id
  564. }
  565. } else {
  566. serizeData = {
  567. body: data
  568. }
  569. }
  570. } else {
  571. serizeData = {
  572. values: data
  573. }
  574. }
  575. }
  576. return serizeData;
  577. }
  578. function alertJson(str) {
  579. alert(JSON.stringify(str));
  580. }