vue路由传对象刷新会报错,数据丢失,用json字符串解决

我的订单页面---------》订单详情页面

我的订单页面:

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

猜你喜欢

转载自blog.csdn.net/weixin_39818813/article/details/82954431