vue路由傳物件重新整理會報錯,資料丟失,用json字串解決
阿新 • • 發佈:2018-12-13
我的訂單頁面---------》訂單詳情頁面
我的訂單頁面:
encodeURIComponent(JSON.stringify(this.detailMsg))------變成json字串,且加密
toDetail(index) { request.post('/orderDetails', { orderNo: this.air_ticket[index].orderNo,//訂單號 id: this.air_ticket[index].id, language: this.curLang, }).then(response => { if (response.data.code == 200) { this.detailMsg = response.data.data; this.$router.push({ path: '/schedule/details', query: { createTimeStr: this.air_ticket[index].createTimeStr,//訂單建立時間 id: this.air_ticket[index].id,//id // id: 122,//id 先寫死。這個id有資料 status: this.detailMsg.orderDetailInfo.status,//購票狀態 statusStr: this.detailMsg.orderDetailInfo.statusStr,//購票狀態 ticketAmount: this.air_ticket[index].ticketAmount,//購票金額 orderNo: this.air_ticket[index].orderNo,//訂單號 startAddress: this.air_ticket[index].depSegment.startAddress,//出發地址 endAddress: this.air_ticket[index].depSegment.endAddress,//目的地址 detailMsg: encodeURIComponent(JSON.stringify(this.detailMsg)),//詳情資訊集合 createUserId: this.useId,//使用者id } }) } if (response.data.code !== 200) { } } );
訂單詳情頁面:
JSON.parse(decodeURIComponent(this.$route.query.detailMsg))---解析json字串,且解密
this.selcetPager(this.$route.query.id); this.JudgementStage(this.$route.query) this.id = this.$route.query.id this.createTimeStr = this.$route.query.createTimeStr this.status = this.$route.query.status this.statusStr = this.$route.query.statusStr this.detailMsg = JSON.parse(decodeURIComponent(this.$route.query.detailMsg)) this.ticketAmount = this.$route.query.ticketAmount this.orderNo = this.$route.query.orderNo this.startAddress = this.$route.query.startAddress this.endAddress = this.$route.query.endAddress this.createUserId = this.$route.query.createUserId