Authored by htoooth

add api code

... ... @@ -5,6 +5,7 @@ import {
} from 'store/yoho/types';
import {createApp} from './app';
import {createApi} from 'create-api';
import {Style, Toast} from 'cube-ui';
import Lazy from 'vue-lazyload';
import 'statics/scss/common.scss';
import 'statics/font/iconfont.css';
... ...
<template>
<div class="exchange-box">
<input type="text" name="couponCodeInput" placeholder="请输入优惠券码" :value="code" @input="onCodeInput">
<CubuInput :value="code" placeholder="请输入优惠券码" :clearable="inputOption"></CubuInput>
<button :class="btnCls" @click="onClick">兑换</button>
</div>
</template>
<script>
import {Input} from 'cube-ui';
export default {
name: 'ExchangeBox',
data() {
return {
code: ''
code: '',
inputOption: {
visible: true,
blurHidden: false
}
};
},
methods: {
... ... @@ -28,6 +34,9 @@ export default {
active: this.code !== ''
}];
}
},
components: {
CubuInput: Input
}
};
</script>
... ... @@ -42,7 +51,7 @@ export default {
left: 0;
z-index: 2;
input {
.code {
width: 570px;
height: 60px;
margin-right: 12px;
... ...
... ... @@ -69,4 +69,20 @@ export default {
commit(Types.FETCH_YOHO_COUPON_FAILED);
}
},
async getCouponCode({commit}, {code}) {
commit(Types.FETCH_YOHO_COUPON_REQUEST);
const result = await this.$api.post('/api/coupon/yoho/', {
coupon_code: code
});
if (result && result.code === 200) {
commit(Types.FETCH_YOHO_COUPON_CODE_SUCCESS);
} else {
commit(Types.FETCH_YOHO_COUPON_FAILED);
}
return result || {};
}
};
... ...
... ... @@ -2,6 +2,6 @@ export const FETCH_YOHO_COUPON_REQUEST = 'FETCH_YOHO_COUPON_REQUEST';
export const FETCH_YOHO_COUPON_FAILED = 'FETCH_YOHO_COUPON_FAILED';
export const FETCH_YOHO_COUPON_SUCCESS = 'FETCH_YOHO_COUPON_SUCCESS';
export const FETCH_YOHO_COUPON_NUM_SUCCESS = 'FETCH_YOHO_COUPON_NUM_SUCCESS';
export const FETCH_YOHO_COUPON_CODE_SUCCESS = 'FETCH_YOHO_COUPON_NUM_SUCCESS';
export const FETCH_YOHO_COUPON_CODE_SUCCESS = 'FETCH_YOHO_COUPON_CODE_SUCCESS';
export const FETCH_UFO_COUPON_SUCCESS = 'FETCH_UFO_COUPON_SUCCESS';
... ...
... ... @@ -21,7 +21,7 @@ module.exports = {
params: {}
},
'/api/coupon/yoho/getcoupon': {
api: 'app.Buynow.useCoupon',
api: 'app.coupons.bindPCoupon',
params: {
coupon_code: {type: String}
}
... ...