cuiqian2004
4 天以前 2af5f043b60c1f7ac38ecccc8f5bf44743134325
pages/my/log-detail.vue
@@ -1,26 +1,26 @@
<template>
   <view class="pages-my-log-detail">
      <view class="title"> {{'接口 '+ info.date}}
      <view class="title"> {{ info.date+" " +info.method }}
      </view>
      <view class="content">{{info.method + " " + info.url}}
      <view class="content">{{ info.url}}
      </view>
      <template v-if="info.method == 'POST'">
         <view class="title">参数
         <view class="title">{{translate('parameter')}}
         </view>
         <textarea class="param" disabled :value="paramText"></textarea>
      </template>
      <template v-if="info.statusCode!=200">
         <view class="title">错误码
      <template v-if="isError">
         <view class="title">{{translate('error_code')}}
         </view>
         <view class="content error">{{info.statusCode}}
         </view>
         <view class="title">错误信息
         <view class="title">{{translate('error_msg')}}
         </view>
         <textarea class="content error" disabled :value="result"></textarea>
      </template>
      <template v-else>
         <view class="title">结果
         <view class="title">{{translate('result')}}
         </view>
         <textarea class="result" disabled :value="result"></textarea>
         <!-- <view class="result">{{result}}
@@ -32,6 +32,9 @@
   import {
      session,
   } from "@/comm/utils.js"
   import {
      Base64
   } from '@/comm/Base64.js';
   export default {
      name: "PagesMyLogDetail",
      data() {
@@ -41,18 +44,25 @@
         }
      },
      onLoad(option) {
         this.info = JSON.parse(option.info) || {}
         console.log(   this.info)
         if(this.info.data_key)
         {
         this.info = getApp().globalData.pageBigData || {}
         getApp().globalData.pageBigData = {}
         if (this.info.data_key) {
            const maxData = session.getValue("request_log_max_data") || {}
            this.info.data = maxData[this.info.data_key]
         }
         const list = (this.info.url || "").split("/")
         let title = ""
         for (let i in list) {
            if (list[i] == "api") {
               title = "api"
            } else
               title += "/" + list[i]
         }
         uni.setNavigationBarTitle({
            title: this.info.method || "接口日志详情"
            title: title || "接口日志详情"
         })
      },
      computed: {
         paramText() {
@@ -62,10 +72,31 @@
         result() {
            const res = this.info.data
            return typeof res == 'string' ? res : JSON.stringify(res)
         },
         isError() {
            if (this.info.statusCode == 200) {
               const res = typeof this.info.data == 'string' ? this.parseJson(this.info.data) : this.info.data
               if (res?.code)
                  return true
               return false
            }
            return true
         }
      },
      methods: {
         parseJson(str) {
            try {
               const obj = JSON.parse(str)
               return obj
            } catch (ex) {
               console.log(ex)
               return str
            }
         },
         translate(t) {
            if (typeof this.$t == "function") return this.$t(`page.${t}`)
            else return t;
         },
      }
   }
</script>
@@ -79,7 +110,7 @@
      background-color: #F5F5F5;
      .title {
         margin: 5rpx;
         margin: 10rpx;
         font-size: 32rpx;
         font-weight: 700;
      }