logistics.vue 2.71 KB
<template>
    <div class="edit-logistics-page">
        <div class="edit-logistics">
            <label @click="companylist">选择快递公司<input class="company-val" type="text" :value="company_name" readonly><span class="iconfont">&#xe604;</span></label>
            <label>快递单号<input class="num" maxlength="20" v-model='num'></label>
        </div>
        <div class="submit" @click="submit">确认</div>
    </div>
</template>

<script>
    const $ = require('yoho-jquery');
    const tip = require('js/plugin/tip');
    const modal = require('js/plugin/modal2');
    const bus = require('js/plugin/vue-bus');

    module.exports = {
        props: ['applyid', 'type', 'company_id', 'company_name'],
        data() {
            return {
                num: '',
            };
        },
        methods: {
            companylist() {
                bus.$emit('changeView', {
                    view: 'logisticsCompany'
                });
            },
            submit() {
                if (!this.company_name) {
                    tip.show('请选择快递公司');
                    return false;
                }
                if (!this.num || !/^[0-9]*$/.test(this.num)) {
                    tip.show('请输入正确的快递单号');
                    return false;
                }

                const text = `快递公司:${this.company_name} <br>单号:${this.num}`;
                const _this = this;

                modal.confirm(text, '请确认寄回信息是否正确?', function() {
                    this.hide();
                    $.ajax({
                        url: '/home/return/save-logistics',
                        type: 'post',
                        data: {
                            applyid: _this.applyid,
                            type: _this.type,
                            expressId: _this.company_id,
                            expressCompany: _this.company_name,
                            expressNumber: _this.num
                        }
                    }).then(res => {
                        if ($.type(res) !== 'object') {
                            res = {};
                        }
                        if (res.code !== 200) {
                            tip.show(res.message || '网络错误');
                        } else {
                            let type = _this.type === 'change' ? 'exchange' : _this.type;

                            location.href = `http://m.yohobuy.com/home/return/${type}/detail/${_this.applyid}`;
                            return false;
                        }
                    });
                });
            }
        }
    };
</script>

<style lang="scss">
    @import "~scss/home/refund/logistics.scss";
</style>