Explorar o código

chore: 首页展示 user/get 完整 JSON 便于调试

sync 内部成员时返回 internalUserRaw;换票成功后弹窗展示接口原始响应。

Made-with: Cursor
haifeng.zhang hai 1 semana
pai
achega
16506e777c
Modificáronse 2 ficheiros con 48 adicións e 0 borrados
  1. 3 0
      src/api/wecom/index.ts
  2. 45 0
      src/pages/home/index.vue

+ 3 - 0
src/api/wecom/index.ts

@@ -315,6 +315,7 @@ export async function syncExternalVisitorProfile(code: string) {
       profile,
       userInfo,
       externalContact,
+      internalUserRaw: undefined,
     }
   }
 
@@ -333,6 +334,7 @@ export async function syncExternalVisitorProfile(code: string) {
       profile,
       userInfo,
       externalContact: null,
+      internalUserRaw: internal,
     }
   }
 
@@ -341,5 +343,6 @@ export async function syncExternalVisitorProfile(code: string) {
     profile: null,
     userInfo,
     externalContact: null,
+    internalUserRaw: undefined,
   }
 }

+ 45 - 0
src/pages/home/index.vue

@@ -34,6 +34,8 @@ const stripOAuthCodeFromUrl = () => {
 const externalUserid = ref('');
 const unionidValue = ref('');
 const ownerId = ref('');
+const internalUserGetPopupVisible = ref(false);
+const internalUserGetJsonText = ref('');
 
 const applyVisitorFromSyncResult = (result: Awaited<ReturnType<typeof syncExternalVisitorProfile>>) => {
   externalUserid.value = result.externalUserId
@@ -84,6 +86,10 @@ const bootstrapWithCode = async (code: string) => {
     throw new Error('identity incomplete')
   }
   applyVisitorFromSyncResult(result)
+  if (result.internalUserRaw) {
+    internalUserGetJsonText.value = JSON.stringify(result.internalUserRaw, null, 2)
+    internalUserGetPopupVisible.value = true
+  }
 }
 
 const cacheLooksUsable = (cached: WecomVisitorProfile | null): cached is WecomVisitorProfile =>
@@ -151,6 +157,13 @@ const getQuestionPage = () => {
       </navigator>
     </view>
     <img class="box_bg_bottom" src="@/assets/bg_bottom.png" alt="" srcset="">
+
+    <van-popup v-model:show="internalUserGetPopupVisible" round closeable class="user-get-popup">
+      <view class="user-get-popup__header">user/get 返回</view>
+      <scroll-view scroll-y class="user-get-popup__content">
+        <text selectable class="user-get-popup__json">{{ internalUserGetJsonText }}</text>
+      </scroll-view>
+    </van-popup>
   </view>
 
 </template>
@@ -236,4 +249,36 @@ const getQuestionPage = () => {
     width: 100%;
   }
 }
+
+.user-get-popup {
+  width: 88vw;
+  max-height: 75vh;
+  padding: 20px 16px 16px;
+  box-sizing: border-box;
+
+  &__header {
+    margin-bottom: 12px;
+    padding-right: 24px;
+    font-size: 16px;
+    font-weight: 600;
+    color: #333;
+  }
+
+  &__content {
+    max-height: 60vh;
+    background: #f7f8fa;
+    border-radius: 8px;
+    padding: 12px;
+    box-sizing: border-box;
+  }
+
+  &__json {
+    display: block;
+    white-space: pre-wrap;
+    word-break: break-all;
+    font-size: 12px;
+    line-height: 1.6;
+    color: #333;
+  }
+}
 </style>