• 137.(前端)订单管理显示物流信息——前端利用axios调用后端接口并且使用timeline时间线效果展示


    1.流程概述

    上篇文章,我们已经实现了如何去从后端获取数据,这一次,我们主要有两部分内容需要实现。

    1. 我们编写一个函数,利用axios去调用后端接口获取数据,放到我们已经实现好的dialog弹窗中。但是,此时我们的数据是一个列表结果,是不利于查看的
    2. 我们使用 时间线,去对物流信息数据根据时间的顺序排列下来,进行前端的展示

    2.最终效果展示

    在这里插入图片描述

    3.代码展示

    
    <template>
        <div>
            
            <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item :to="{ path: '/home' }">首页el-breadcrumb-item>
                <el-breadcrumb-item>订单管理el-breadcrumb-item>
                <el-breadcrumb-item>订单列表el-breadcrumb-item>
            el-breadcrumb>
            
            <el-card>
                
                <el-row>
                    
                    <el-col :span="8">
                        <el-input v-model="qid" placeholder="请输入搜索名称" clearable @clear="getOrderList">
                            
                            <el-button slot="append" icon="el-icon-search" @click="getOrderList">el-button>
                        el-input>
                    el-col>
                el-row>
                
                <el-row>
                    <el-table :data="orderList" border>
                        <el-table-column type="index">el-table-column>
                        <el-table-column prop="id" label="id">el-table-column>
                        <el-table-column prop="uname" label="订单用户">el-table-column>
                        <el-table-column prop="price" label="金额">el-table-column>
                        <el-table-column prop="pay_status" label="是否支付">
                            <template slot-scope="scope">
                                <el-tag v-if="scope.row.pay_status === 0" type="success">未支付el-tag>
                                <el-tag v-else type="danger">已支付el-tag>
                            template>
                        el-table-column>
                        <el-table-column prop="is_send" label="是否发件">
                            <template slot-scope="scope">
                                <el-tag v-if="scope.row.is_send === 0" type="success">未发货el-tag>
                                <el-tag v-else type="danger">已发货el-tag>
                            template>
                        el-table-column>
                        <el-table-column prop="操作" width="200px">
                            <template slot-scope="scope">
                                <el-button size="mini" type="primary" icon="el-icon-s-tools">地址el-button>
                                <el-button size="mini" type="success" icon="el-icon-location" @click="showExpress(scope.row.id)">物流el-button>
                            template>
                        el-table-column>
                    el-table>
                el-row>
            el-card>
            <el-dialog title="物流信息" :visible.sync="expressVisible">
                <el-timeline :reverse="reverse">
                    <el-timeline-item v-for="(activity, index) in expressList" :key="index" :timestamp="activity.updatetime">
                        {{activity.content}}
                    el-timeline-item>
                el-timeline>
            el-dialog>
        div>
        
            
    template>
    
    <script>
    export default {
        data() {
            return{
                qid: '',
                orderList:'',
                expressVisible: false,
                expressList: [],
                reverse: true
            }
        },
        created(){
            this.getOrderList()
        },
        methods: {
            // 发送请求获取订单列表
            async getOrderList() {
                const { data: res } = await this.$axios.get('/api/order_list')
                if (res.status !== 200) return this.$msg.error(res.msg)
                // console.log(res.data);
                this.$msg.success(res.msg)
                this.orderList = res.data
            },
            showExpress(oid) {
                this.expressVisible = true
                this.getExpressList(oid)
            },
            async getExpressList(oid){
                const {data: resp } = await this.$axios.get('/api/express',{params: {oid: oid}})
                if (resp.status !== 200) return this.$msg.error(resp.msg)
                console.log(resp.data);
                this.expressList = resp.data
            }
        }
    
    }
    script>
    
    <style>
    .el-table{
        margin-top: 10px;
    }
    style>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
  • 相关阅读:
    笔记本无线网卡MAC一直改动
    Spring Security 自定义资源服务器实践
    给你安利一个程序员上岸公务员的开源项目
    【车载开发系列】汽车嵌入式开发常用工具介绍
    jenkins
    Python基础篇(十三)-- 进程和线程
    Linux进程信号
    一起Talk编程语言吧
    RobotFramework框架+Selenium实现UI自动化测试(十六)
    学习java的第十八天。。。(子类)
  • 原文地址:https://blog.csdn.net/m0_63953077/article/details/127681083