resource.js
4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
* 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}'),
};