myCouponDetail.vue 3.72 KB
<template>
    <div class="zj-main">
        <mt-header title="优惠券详情">
			   <span @click="gotoback" slot="left">
                <mt-button icon="back"></mt-button>
            </span>
        </mt-header>
        <div class="my-coupon-content">
            <div class="ctopbg-l"></div>
            <div class="top" :style="{'background':myCouponDetail.cplBgcolor}">
                <div class="title">{{myCouponDetail.cplName}}</div>
                <div class="time">使用期限:{{startTime}} 至 {{endTime}}</div>
                <div class="num-tel"><span class="num"><span class="big-num">{{myCouponDetail.cplValue }}</span>折<span
                        class="tel">券号:{{myCouponDetail.cplCode}}</span></span></div>
                <span class="double-line-left"></span><span class="double-line-right"></span>
            </div>
            <div class="ctopbg-r"></div>
            <div class="middle">
                <div id="qrcode"></div>
                <div id="barcode"></div>
                <div class="use-if">
                    <span class="left">使用条件:</span>
                    <div class="right">
                        <p>&nbsp;1、只能在使用网店使用;</p>
                        <p>&nbsp;2、优惠券在使用期限内使用;</p>
                        <p>&nbsp;3、线上线下都可使用。</p>
                    </div>
                </div>
                <div class="bottom">
                    <mt-cell title="适用网点" to="/matchNet" is-link></mt-cell>
                </div>
            </div>
            <div class="bottom-bg" :style="{'background':myCouponDetail.cplBgcolor}">
                <div class="cbottombg-l"></div>
                <div class="cbottombg-r"></div>
            </div>
        </div>
    </div>
</template>
<script type="text/ecmascript-6">
    import {getmyCouponDetail} from '../../vuex/actions';

    export default {
        data() {
            return {
                startTime: '',
                endTime: ''
            }
        },
        computed: {
            cplCode(){
                return this.myCouponDetail.cplCode;
            }
        },
        methods: {
            gotoback(){
                this.$router.go(-1)
            },
            createQRcode(){

                // 设置参数方式
                var qrcode = new QRCode('qrcode', {
                    text: this.cplCode,
                    width: 150,
                    height: 150,
                    colorDark: '#000000',
                    colorLight: '#ffffff',
                    correctLevel: QRCode.CorrectLevel.H
                });
                return qrcode;
            },
            createBarCode(){
                $("#barcode").empty().barcode("22222", "code11", {barWidth: 2, barHeight: 30});
            },
            beginTime(){
                this.startTime = this.myCouponDetail.cplStartTime.substring(0, 11);
            },
            finishTime(){
                this.endTime = this.myCouponDetail.cplEndTime.substring(0, 11);
            }
        },
        vuex: {
            getters: {
                myCouponDetail: ({personCenterData}) => {
                    return personCenterData.myCouponDetail;
                },
            },
            actions: {
                getmyCouponDetail

            }
        },
        beforeRouteEnter(to, from, next) {
            next(vm => {
                vm.getmyCouponDetail(vm.$route.params.cplId).then(function () {
                    vm.beginTime();
                    vm.finishTime();
                    vm.createQRcode();
                    vm.createBarCode();
                });
            });
        },
        beforeRouteLeave(to, from, next) {
            next();
        }
    }
</script>