Authored by htoooth

api

<template>
<div class="exchange-box">
<CubuInput :value="code" placeholder="请输入优惠券码" :clearable="inputOption"></CubuInput>
<input type="text" name="couponCodeInput" placeholder="请输入优惠券码" v-model="code">
<button :class="btnCls" @click="onClick">兑换</button>
</div>
</template>
<script>
import {Input} from 'cube-ui';
<script>
export default {
name: 'ExchangeBox',
data() {
return {
code: '',
inputOption: {
visible: true,
blurHidden: false
}
code: ''
};
},
methods: {
onClick() {
this.$emit('click');
},
onCodeInput(e) {
this.code += e.data;
this.$emit('input', this.code);
}
},
computed: {
btnCls() {
... ... @@ -35,8 +27,10 @@ export default {
}];
}
},
components: {
CubuInput: Input
watch: {
code() {
this.$emit('input', this.code);
}
}
};
</script>
... ... @@ -51,7 +45,7 @@ export default {
left: 0;
z-index: 2;
.code {
input {
width: 570px;
height: 60px;
margin-right: 12px;
... ...
... ... @@ -51,7 +51,7 @@
<script>
import {createNamespacedHelpers} from 'vuex';
const {mapState} = createNamespacedHelpers('coupon/yoho');
const {mapState, mapActions} = createNamespacedHelpers('coupon/yoho');
import Tabs from '../components/tabs';
import FilterBar from '../components/filter-bar';
... ... @@ -98,7 +98,7 @@ export default {
}
],
scrollOptions: {
directionLockThreshold: 0
directionLockThreshold: 0,
},
slideOptions: {
listenScroll: true,
... ... @@ -123,6 +123,7 @@ export default {
this.getNum();
},
methods: {
...mapActions(['getCouponCode']),
changePage(current) {
const tab = this.tabLabels[current];
... ... @@ -149,7 +150,19 @@ export default {
this.$refs.tabs.showFilter = false;
},
onSubmitCode() {
this.getCouponCode({code: this.inputCouponCode}).then(result => {
if (result.code === 200) {
this.$createToast({
txt: result.message,
type: 'correct'
});
} else {
this.$createToast({
txt: result.message,
type: 'error'
});
}
});
}
},
watch: {
... ...
... ... @@ -73,7 +73,7 @@ export default {
async getCouponCode({commit}, {code}) {
commit(Types.FETCH_YOHO_COUPON_REQUEST);
const result = await this.$api.post('/api/coupon/yoho/', {
const result = await this.$api.post('/api/coupon/yoho/getcoupon', {
coupon_code: code
});
... ...