Authored by 张文文

商品详情页领券接口fix review by lea.guo

... ... @@ -60,7 +60,7 @@ export default {
});
},
methods: {
...mapActions(['getCoupon']),
...mapActions(['getProductCoupon']),
onHidden() {
this.$emit('hidden');
},
... ... @@ -77,8 +77,7 @@ export default {
const user = await this.$yoho.auth();
if (user && user.uid) {
this.getCoupon({couponToken: couponToken}).then(result => {
console.log(result);
this.getProductCoupon({couponTokens: couponToken}).then(result => {
this.$createDialog({
type: 'alert',
title: result.code === 200 ? '领取优惠券成功' : result.message,
... ...
... ... @@ -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 || {};
},
}
};
};
... ...
... ... @@ -68,6 +68,7 @@ export default {
productId: productId,
page: 1,
limit: 500,
api_version : 1
}
const result = await this.$api.get('/api/ufo/product/coupon', params);
... ... @@ -81,6 +82,7 @@ export default {
async fetchProductCouponTopList({ commit }, { productId }) {
let params = {
productId: productId,
api_version : 1
}
const result = await this.$api.get('/api/ufo/product/couponTopList', params);
... ...
... ... @@ -23,4 +23,17 @@ module.exports = {
coupon_tokens: {type: String}
},
},
// 商品详情页领券
'/api/ufo/coupons/getCoupon': {
auth: true,
accessLog: true,
checkSign: true,
ufo: true,
path: 'coupon',
api: 'ufo.coupons.getCoupon',
params: {
couponTokens: {type: String}
},
},
};
... ...
... ... @@ -59,16 +59,17 @@ module.exports = {
},
},
// 对应商品的券
// 商品详情页couponList
'/api/ufo/product/coupon': {
ufo: true,
auth: true,
path: '/couponCenter',
path: '/ufo-gateway/couponCenter', // 测试环境'/ufo-gateway/couponCenter',线上'/couponCenter'
api: 'ufo.couponsInPrdDetail.list',
params: {
productId: {type: Number}, // 商品id
productId: {type: Number},
limit: { type: Number },
page: { type: Number },
api_version: { type: Number} // 商品详情页券单独添加的字段
},
},
... ... @@ -76,10 +77,11 @@ module.exports = {
'/api/ufo/product/couponTopList': {
ufo: true,
auth: false,
path: '/couponCenter',
path: '/ufo-gateway/couponCenter', // 测试环境'/ufo-gateway/couponCenter',线上'/couponCenter'
api: 'ufo.couponTopListOfPrdDetail.list',
params: {
productId: {type: Number}, // 商品id
productId: {type: Number},
api_version: { type: Number} // 商品详情页券单独添加的字段
},
},
... ...