...
|
...
|
@@ -4,6 +4,10 @@ export const Types = { |
|
|
GET_COUPON_SUCCESS: 'GET_COUPON_SUCCESS',
|
|
|
GET_COUPON_FAILED: 'GET_COUPON_FAILED',
|
|
|
GET_SERVER_TIME_SUCCESS: 'GET_SERVER_TIME_SUCCESS',
|
|
|
|
|
|
GET_PRODUCT_COUPON_REQUEST: 'GET_PRODUCT_COUPON_REQUEST',
|
|
|
GET_PRODUCT_COUPON_SUCCESS: 'GET_PRODUCT_COUPON_SUCCESS',
|
|
|
GET_PRODUCT_COUPON_FAILED: 'GET_PRODUCT_COUPON_FAILED',
|
|
|
};
|
|
|
|
|
|
export default function() {
|
...
|
...
|
@@ -11,7 +15,8 @@ export default function() { |
|
|
namespaced: true,
|
|
|
state: {
|
|
|
fetchingCoupon: false,
|
|
|
serverTime: ''
|
|
|
serverTime: '',
|
|
|
fetchingProductCoupon: false
|
|
|
},
|
|
|
mutations: {
|
|
|
[Types.GET_COUPON_REQUEST](state) {
|
...
|
...
|
@@ -26,7 +31,18 @@ export default function() { |
|
|
[Types.GET_SERVER_TIME_SUCCESS](state, {time}) {
|
|
|
state.serverTime = time;
|
|
|
console.log('mutationServerTime', time);
|
|
|
}
|
|
|
},
|
|
|
|
|
|
// 这一块是商品详情页的领券,后来换的接口
|
|
|
[Types.GET_PRODUCT_COUPON_REQUEST](state) {
|
|
|
state.fetchingProductCoupon = true;
|
|
|
},
|
|
|
[Types.GET_PRODUCT_COUPON_SUCCESS](state) {
|
|
|
state.fetchingProductCoupon = false;
|
|
|
},
|
|
|
[Types.GET_PRODUCT_COUPON_FAILED](state) {
|
|
|
state.fetchingProductCoupon = false;
|
|
|
},
|
|
|
},
|
|
|
actions: {
|
|
|
async getCoupon({commit}, {couponToken}) {
|
...
|
...
|
@@ -43,12 +59,27 @@ export default function() { |
|
|
|
|
|
return result || {};
|
|
|
},
|
|
|
|
|
|
async getServerTime() {
|
|
|
const result = await this.$api.get('/app/ufo/getServerTime');
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
},
|
|
|
|
|
|
// 商品详情页领券接口
|
|
|
async getProductCoupon({commit}, { couponTokens }) {
|
|
|
|
|
|
commit(Types.GET_PRODUCT_COUPON_REQUEST);
|
|
|
|
|
|
const result = await this.$api.get('/api/ufo/coupons/getCoupon', { couponTokens: couponTokens });
|
|
|
|
|
|
if (result && result.code === 200) {
|
|
|
commit(Types.GET_PRODUCT_COUPON_SUCCESS);
|
|
|
} else {
|
|
|
commit(Types.GET_PRODUCT_COUPON_FAILED);
|
|
|
}
|
|
|
|
|
|
return result || {};
|
|
|
},
|
|
|
}
|
|
|
};
|
|
|
}; |
...
|
...
|
|