resource.js 4.11 KB

/**
 * Created by shipfi on 2016/6/2.
 */
  /*jshint esversion: 6 */
import Vue from 'vue';
import VueResource from 'vue-resource';
//import cookieManager from '../utils/cookieManager';
//import {API_ROOT} from '../config';

//import {getCookie,signOut} from '../utils/AuthService';

Vue.use(VueResource);



// HTTP相关
Vue.http.options.crossOrigin = true;
Vue.http.options.xhr = {withCredentials: true};
//Vue.http.options.timeout = 5000;

//Vue.http.headers.common['GrpAppID'] = cookieManager.getCookie('grpAppId');
//Vue.http.headers.common['OpenID'] = cookieManager.getCookie('wxOpenId');

Vue.http.interceptors.push({
    request(request) {
        request.headers = request.headers || {};
        //request.headers.UserID = "xxx";//getCookie('UserID');
        //console.log(grpAppId);
        //request.headers.common['AppID'] = cookieManager.getCookie('grpAppId');
        //request.headers.common['OpenID'] = cookieManager.getCookie('wxOpenId');
        //request.headers.common['UserID'] = cookieManager.getCookie('userId');
        return request;
    },
    response(response){
        // 这里可以对响应的结果进行处理
        if (response.status === 401) {
            //signOut();
            window.location.pathname = '/authFaild';
        }
        return response;
    }
});


var API_ROOT='/shopAPI';

export default {
    /* 首页结构 */
    getweiIndext: Vue.resource(API_ROOT + '/weiPage/indexPage/{pageId}'),
    /* 底部导航 */
    getgroupNav:Vue.resource(API_ROOT + '/weiPage/nav'),
    /* 获取我的地址列表 */
    getmyAddressList:Vue.resource(API_ROOT + '/address/list?page={page}&pageNum={pageNum}'),
    /* 设置默认地址 */
    setDefaultAddress:Vue.resource(API_ROOT + '/address/default'),
    /* 删除默认地址 */
    deleteAddress:Vue.resource(API_ROOT + '/address'),
    /* 获取指定地址信息 */
    selectAddress:Vue.resource(API_ROOT + '/address/appoint/{buyerAddressId}'),
    /* 保存编辑地址信息 */
    posteditAddress:Vue.resource(API_ROOT + '/address/edit'),
    /* 保存新增地址信息 */
    postaddAddress:Vue.resource(API_ROOT + '/address/add'),
    /* 获取个人中心信息 */
    getpersonData:Vue.resource(API_ROOT + '/self'),
    /* 获取个人中心订单数 */
    getorderNum:Vue.resource(API_ROOT + '/order/orderCount'),
    /* 获取浏览记录 */
    getbrowseRecordList:Vue.resource(API_ROOT + '/self/browers?page={page}&pageNum={pageNum}'),
    /* 获取收藏记录 */
    getmyCollectionList:Vue.resource(API_ROOT + '/self/favoriates?page={page}&pageNum={pageNum}'),
    /* 添加/取消收藏 */
    addCancelCollection:Vue.resource(API_ROOT + '/self/favoriate?id={id}&type={type}'),
    /* 获取我的优惠券列表 */
    getmyCouponList:Vue.resource(API_ROOT + '/self/coupons?useType={useType}&page={page}&pageNum={pageNum}'),
    /* 获取优惠券详情 */
    getmyCouponDetail:Vue.resource(API_ROOT + '/self/coupon/detail/{cplId}'),
    /* 获取优惠券中心列表 */
    getcouponCenterList:Vue.resource(API_ROOT + '/coupon/list?cplType={cplType}&page={page}&pageNum={pageNum}'),
    /* 获取优惠券中心的优惠券详情 */
    getcouponCenterDetail:Vue.resource(API_ROOT + '/coupon/detail/{cplId}'),
    /* 获取优惠券适用网点 */
    getmatchNetList:Vue.resource(API_ROOT + 'coupon/sites/{cplId}?lon={lon}&lng={lng}'),
    /* 获取优惠券中心标题及背景 */
    getcouponTab:Vue.resource(API_ROOT + '/coupon'),
    /* 优惠券兑换 */
    couponExchange:Vue.resource(API_ROOT + '/coupon/exchange'),

    /* 确认订单(结算) */
    postcheckOrder:Vue.resource(API_ROOT + '/order/checkOrder'),

    /* 获取符合需求的优惠券列表 */
    postmatchCouponList:Vue.resource(API_ROOT + '/order/coupons'),

    /* 确认下单 */
    postconfirmOrder:Vue.resource(API_ROOT + '/order/submitOrder'),

    /* 支付页面 */
    getpushOrder:Vue.resource(API_ROOT + 'pay.qingger.com'),

    /* 支付订单 */
    postpayOrder:Vue.resource(API_ROOT + '/order/payOrder'),

    /* 订单列表 */
    getOrderList:Vue.resource(API_ROOT + '/order/list?orderState={orderState}&evaluationState={evaluationState}&page={page}&pageNum={pageNum}'),

};