Vue.component('order-details', { template: `

订单详情

`, props: { 'show': { type: Boolean, default: false, },//是否展示 'details': { type: Object, default: () => { return {} }, }, 'order_no': { type: String, default: '', }, }, data() { return { detailsData: {} } }, methods: { handleData() { if (this.order_no) { $.ajax({ url: '/index.php/Retail/Component/getOrderDetails', type: 'post', data: { order_no: this.order_no, }, success: (res) => { if (res.status == 1) { this.detailsData = res.data; } else { this.$alert(res.msg ? res.msg : '请求发生错误,请稍后重试!', '错误提示', { confirmButtonText: '确定', callback: action => { } }); } }, error: (res) => { console.log(res); this.$alert('请求发生错误,请稍后重试!', '错误提示', { confirmButtonText: '确定', callback: action => { } }); } }) } else if (!this.detailsData.id) { this.$message({ message: '调用模板参数错误,请传入订单号或订单详细数据', type: 'error' }) } else { this.detailsData = JSON.parse(JSON.stringify(this.details)); } }, //关闭详情 closeDetails: function () { this.$emit('close-details'); } }, watch: { show: function (n) { if (n) { this.handleData(); } } }, });