| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- /**
- * 有关 访问服务器的uri
- */
- var $http = function() {
- this.version = "V1.2";
- this.ajaxLock = false;
- // this.ip = "http://192.168.31.132:9002";
- // this.ip = "http://39.96.81.16:9002";
- this.ip = "https://weixin.jinyutires.com/api-web";
- // this.ip = "http://172.70.16.57:9002";
- /****** 用户相关 ******/
- // 根据省获取经销商
- this.getUpuserByProvideUrl = "/base/agent/listByArea";
- // 注册用户
- this.regizeUrl = "/jinyu/bizLogin/registRetailer";
- // 登录用户
- this.loginUrl = "/jinyu/bizLogin/login";
- // 根据loginid获取用户信息
- this.getUserInfoUrl = "/base/retailer/loginToInfo";
- /******* 订单相关 ********/
- // 查看剩余库存
- this.getStockUrl_old = "/jinyu/bizAgentStock/page";
- this.getStockUrl = "/base/material/pageMaterialStock";
- // 添加商品到购物车
- this.addCarUrl = "/jinyu/bizCart/save";
- // 获取购物车列表
- this.shopCarListUrl = "/jinyu/bizCart/list";
- // 获取商品详情
- this.getInfoUrl = "/base/material/info";
- // 下单传 {"retailerId":"212","amounr":100,"bizCartDtoList":[{"id":121...},{"id":12..}] 这里把购物车的列表给我}
- this.downOrderUrl = "/base/bizOrder/save";
- // 删除购物车 --删除一个
- this.deleteCar = "/jinyu/bizCart/deleteOne";
- // 删除购物车记录 -- 珊瑚多个
- this.deleteCars = "/jinyu/bizCart/delete";
- // 获取订单列表
- this.getOrderListUrl = "/base/bizOrder/page";
- // 获取订单详情
- this.getOrderInfo = "/base/bizOrder/info";
- // ---------- 525 ---------
- // 获取库存详情
- this.getKucunInfoUrl = "/jinyu/bizRetailerStock/page";
- // 获取商品类别
- this.getStoreTypeUrl = "/jinyu/bizGoodsType/list";
- // 添加商品类别
- this.addStoreTypeUrl = "/jinyu/bizGoodsType/save";
- // 添加商品
- this.addStoreUrl = "/jinyu/bizGoods/saveGoods";
- // 查看自己的供应商
- this.getSupplierUrl = "/jinyu/bizSupplier/list";
- // 根据条形码查询商品
- this.getStoreByScanUrl = "/jinyu/bizGoods/selectBySerialNumber";
- // 添加供应商
- this.addSupplierUrl = "/jinyu/bizSupplier/save";
- // 进货
- this.buyStoreUrl = "/jinyu/bizBills/save";
- // 单据
- this.buyListUrl = "/jinyu/bizBills/page";
- // 商品详情
- this.getStoreInfoUrl = "/jinyu/bizGoods/info";
- // 选择品牌
- this.chooseBrandUrl = "/base/brand/list";
- // 根据扫出来的码获取商品信息(进销存) -- 需要后面拼接
- this.jinstoreByScanUrl = "/base/material/infoByKey";
- // 获取门店经销商列表
- this.getSupplierListUrl = "/base/retailerAgent/list";
- // 经销商查询自己库存
- // this.checkStoreUrl = "/jinyu/bizAgentStock/page";
- this.checkStoreUrl_old = "/jinyu/bizAgentStock/page";
- this.checkStoreUrl = "/jinyu/bizAgentStock/pageOwn";
- // 扫码商品 0705
- this.addStoreByScanUrl = "/jinyu/bizGoods/selectBySerialNumberAndRetailerId";
- // 入库扫码
- this.addOrgoScanUrl = '/jinyu/bizGoods/selectInBySerialNumberAndRetailerId';
- // 出库扫码
- this.outScanUrl = '/jinyu/bizGoods/selectOutBySerialNumberAndRetailerId';
-
- /********* 0706 ***********/
- // 收取短信验证码
- this.getPhoneCode = '/jinyu/bizLogin/sendCode';
- // 获取客户信息
- this.customListUrl = '/jinyu/bizCustomRetailer/page';
- // 获取门店详情
- this.getMDInfo = "/base/retailer/retailerInfo";
- // 获取所有的轮胎服务类目
- this.getServices = "/base/service/list";
- // 添加服务
- this.addServices = "/jinyu/bizRetailerService/save";
- // 根据品牌统计库存
- this.getStockByPP = "/jinyu/bizRetailerStock/selectStockByBrand";
- // 获取积分
- this.getJFStore = "/jinyu/bizMall/page";
- // 获取新闻条
- this.getNews = "/jinyu/bizArticle/page";
- // 根据品牌获取上级代理商
- this.getUpByBrand = "/jinyu/bizAgentBrand/listByAgentIds";
- // 根据品牌和省市获取上级代理商
- this.getUpByBrandAndArea = "/jinyu/bizAgentBrand/listByBrandIds";
- // 获取门店积分列表
- this.getJFlistUrl = "/jinyu/bizRetailerIntegral/page";
- // 兑换商品
- this.exchangeUrl = "/jinyu/bizMallOrder/save";
- // 查看兑换记录
- this.exchangeListUrl = "/jinyu/bizMallOrder/page";
- // 检查版本
- this.getVersionUrl = "/biz/getAppVersion";
- // 活动banner
- this.getBannerUrl = "/biz/bizBanner/list";
- // 获取参加活动的商品
- this.getStoreBannerUrl = "/biz/bizActivity/activityInfo";
- }
- // api的ajax
- $http.prototype.$post = function(url, data, callback, other) {
- var content = "", urlT = "", _this = this;
- if (data.url == "json") {
- delete data.url;
- // 确认contenttype选项
- content = "application/json;charset=UTF-8";
- } else {
- content = "application/x-www-form-urlencoded"
- }
- var datas = this.serize(data);
- if ( typeof other != 'undefined' && other != "" && other != 'undefined') {
- urlT = this.ip + eval('this.' + url) + '/' + other;
- } else {
- urlT = this.ip + eval('this.' + url);
- }
- api.showProgress({
- });
- if (this.ajax == true) {
- return;
- }
- this.ajax = true;
- api.ajax({
- url : urlT,
- method : 'post',
- data : datas,
- headers : {
- "Content-type" : content
- },
- }, function(ret, err) {
- _this.ajax = false;
- api.hideProgress();
- api.refreshHeaderLoadDone();
- if (ret) {
- callback(ret);
- } else {
- api.toast({
- msg : JSON.stringify(err)
- });
- }
- });
- }
- // 单独的get请求
- $http.prototype.$getadd = function(url, data, callback, other) {
- var _this = this;
- api.showProgress({
- });
- this.ajax = true;
- api.ajax({
- url : this.ip + eval('this.' + url) + data,
- method : 'get',
- data : {
- values : {
- }
- },
- headers : {
- "Content-type" : "application/json;charset=UTF-8"
- },
- }, function(ret, err) {
- _this.ajax = false;
- api.hideProgress();
- api.refreshHeaderLoadDone();
- if (ret) {
- callback(ret);
- } else {
- api.toast({
- msg : JSON.stringify(err)
- });
- }
- });
- }
- // get获取
- $http.prototype.$get = function(url, data, callback, other) {
- var content = "", urlT = "", _this = this;
- if (data.url == "json") {
- delete data.url;
- // 确认contenttype选项
- content = "application/json;charset=UTF-8";
- } else {
- content = "application/x-www-form-urlencoded"
- }
- var datas = this.serize(data);
- if ( typeof other != 'undefined' && other != "" && other != 'undefined') {
- urlT = this.ip + eval('this.' + url) + '/' + other;
- } else {
- urlT = this.ip + eval('this.' + url);
- }
- api.showProgress({
- });
- if (this.ajax == true) {
- return;
- }
- this.ajax = true;
- api.ajax({
- url : urlT,
- method : 'get',
- data : {
- values : {
- }
- },
- headers : {
- "Content-type" : "application/json;charset=UTF-8"
- },
- }, function(ret, err) {
- _this.ajax = false;
- api.hideProgress();
- api.refreshHeaderLoadDone();
- if (ret) {
- callback(ret);
- } else {
- api.toast({
- msg : JSON.stringify(err)
- });
- }
- });
- }
- // 对数据进行处理,第一个为values,第二个为file body
- $http.prototype.serize = function(data) {
- var serizeData;
- if ( data instanceof Array) {
- if (data.length > 1) {
- serizeData = {
- values : data[0]
- }
- } else {
- serizeData = {
- values : data[0],
- files : data[1]
- }
- }
- } else {
- if (data.type == 'body') {
- delete data.type;
- if (data.yy == 'keng') {
- delete data.yy
- serizeData = {
- body : data.id
- }
- } else {
- serizeData = {
- body : data
- }
- }
- } else {
- serizeData = {
- values : data
- }
- }
- }
- return serizeData;
- }
- function alertJson(str) {
- alert(JSON.stringify(str));
- }
|