|
@@ -2,6 +2,7 @@
|
|
|
import { addQuestionReportData,REPORTDATA, getQuestionTypeList, pageQuestionReportData,getPerson } from '@/api/questionReqort'
|
|
import { addQuestionReportData,REPORTDATA, getQuestionTypeList, pageQuestionReportData,getPerson } from '@/api/questionReqort'
|
|
|
import { AddQuestionReportDataReq, PageQuestionReportDataReq, QuestionListRes, QuestionType, QuestionTypeListRes } from '@/api/questionReqort/types'
|
|
import { AddQuestionReportDataReq, PageQuestionReportDataReq, QuestionListRes, QuestionType, QuestionTypeListRes } from '@/api/questionReqort/types'
|
|
|
import type { ApiResponse, PageResp } from '@/api/types'
|
|
import type { ApiResponse, PageResp } from '@/api/types'
|
|
|
|
|
+import type { AuthTokenChannelSnapshot } from '@/utils/request/requestHandler'
|
|
|
import { getCachedWecomVisitorProfile, getWecomInternalUser } from '@/api/wecom'
|
|
import { getCachedWecomVisitorProfile, getWecomInternalUser } from '@/api/wecom'
|
|
|
import { computed, onMounted, ref, watch } from 'vue'
|
|
import { computed, onMounted, ref, watch } from 'vue'
|
|
|
import GridAddress from '@/components/address/gridAddress/index.vue'
|
|
import GridAddress from '@/components/address/gridAddress/index.vue'
|
|
@@ -9,6 +10,7 @@ import { showNotify } from 'vant'
|
|
|
import dayjs from 'dayjs';
|
|
import dayjs from 'dayjs';
|
|
|
import { onLoad } from '@dcloudio/uni-app'
|
|
import { onLoad } from '@dcloudio/uni-app'
|
|
|
import useUserState from '@/store/userState'
|
|
import useUserState from '@/store/userState'
|
|
|
|
|
+import { getAuthTokenChannelSnapshot, resolveUserAuthToken } from '@/utils/request/requestHandler'
|
|
|
|
|
|
|
|
const active = ref(0)
|
|
const active = ref(0)
|
|
|
const userState = useUserState()
|
|
const userState = useUserState()
|
|
@@ -222,6 +224,12 @@ const finished = ref(false)
|
|
|
const listInitialized = ref(false)
|
|
const listInitialized = ref(false)
|
|
|
const listRequesting = ref(false)
|
|
const listRequesting = ref(false)
|
|
|
|
|
|
|
|
|
|
+/** 列表重置代数:reset 后递增,用于丢弃 reset 之前发出的请求的响应,避免乱序写回 */
|
|
|
|
|
+const listLoadVersion = ref(0)
|
|
|
|
|
+
|
|
|
|
|
+/** 合并并发 init,避免 watch 与重复进入导致多次 reset/请求交错 */
|
|
|
|
|
+let listInitPromise: Promise<void> | null = null
|
|
|
|
|
+
|
|
|
/** 列表接口调试:最近一次请求参数与完整响应 */
|
|
/** 列表接口调试:最近一次请求参数与完整响应 */
|
|
|
const showListRawJsonPopup = ref(false)
|
|
const showListRawJsonPopup = ref(false)
|
|
|
const listLastReqParams = ref<PageQuestionReportDataReq | null>(null)
|
|
const listLastReqParams = ref<PageQuestionReportDataReq | null>(null)
|
|
@@ -237,28 +245,42 @@ const listApiRawJson = computed(() => {
|
|
|
return JSON.stringify(listLastApiResponse.value, null, 2)
|
|
return JSON.stringify(listLastApiResponse.value, null, 2)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+/** 最近一次列表请求时的 token 各渠道快照(脱敏,用于弹窗诊断) */
|
|
|
|
|
+const listLastTokenDiag = ref<AuthTokenChannelSnapshot | null>(null)
|
|
|
|
|
+
|
|
|
|
|
+const listTokenDiagJson = computed(() => {
|
|
|
|
|
+ if (!listLastTokenDiag.value) return '{}'
|
|
|
|
|
+ return JSON.stringify(listLastTokenDiag.value, null, 2)
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
const resetQuestionList = () => {
|
|
const resetQuestionList = () => {
|
|
|
list.value = []
|
|
list.value = []
|
|
|
pageInfo.value.pageNumber = 1
|
|
pageInfo.value.pageNumber = 1
|
|
|
finished.value = false
|
|
finished.value = false
|
|
|
loading.value = false
|
|
loading.value = false
|
|
|
listRequesting.value = false
|
|
listRequesting.value = false
|
|
|
|
|
+ listLoadVersion.value += 1
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const questList = async () => {
|
|
const questList = async () => {
|
|
|
if (listRequesting.value || finished.value) return
|
|
if (listRequesting.value || finished.value) return
|
|
|
|
|
|
|
|
|
|
+ const requestVersion = listLoadVersion.value
|
|
|
listRequesting.value = true
|
|
listRequesting.value = true
|
|
|
loading.value = true
|
|
loading.value = true
|
|
|
try {
|
|
try {
|
|
|
const currentPage = pageInfo.value.pageNumber
|
|
const currentPage = pageInfo.value.pageNumber
|
|
|
|
|
+ listLastTokenDiag.value = getAuthTokenChannelSnapshot()
|
|
|
|
|
+ const effectiveToken = resolveUserAuthToken()
|
|
|
const reqParams: PageQuestionReportDataReq = {
|
|
const reqParams: PageQuestionReportDataReq = {
|
|
|
pageNumber: currentPage,
|
|
pageNumber: currentPage,
|
|
|
pageSize: pageInfo.value.pageSize,
|
|
pageSize: pageInfo.value.pageSize,
|
|
|
- token: userState.getUserTokenInfo || '',
|
|
|
|
|
|
|
+ token: effectiveToken,
|
|
|
}
|
|
}
|
|
|
- listLastReqParams.value = reqParams
|
|
|
|
|
const res = await pageQuestionReportData(reqParams)
|
|
const res = await pageQuestionReportData(reqParams)
|
|
|
|
|
+ if (requestVersion !== listLoadVersion.value) return
|
|
|
|
|
+
|
|
|
|
|
+ listLastReqParams.value = reqParams
|
|
|
listLastApiResponse.value = res
|
|
listLastApiResponse.value = res
|
|
|
const records = res.data.records || []
|
|
const records = res.data.records || []
|
|
|
|
|
|
|
@@ -271,10 +293,16 @@ const questList = async () => {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const initQuestionList = async () => {
|
|
|
|
|
- resetQuestionList()
|
|
|
|
|
- await questList()
|
|
|
|
|
- listInitialized.value = true
|
|
|
|
|
|
|
+const initQuestionList = (): Promise<void> => {
|
|
|
|
|
+ if (listInitPromise) return listInitPromise
|
|
|
|
|
+ listInitPromise = (async () => {
|
|
|
|
|
+ resetQuestionList()
|
|
|
|
|
+ await questList()
|
|
|
|
|
+ listInitialized.value = true
|
|
|
|
|
+ })().finally(() => {
|
|
|
|
|
+ listInitPromise = null
|
|
|
|
|
+ })
|
|
|
|
|
+ return listInitPromise
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/** 跳转问题详情 */
|
|
/** 跳转问题详情 */
|
|
@@ -385,7 +413,13 @@ watch(active, async (value) => {
|
|
|
<view class="mb-[8px]">
|
|
<view class="mb-[8px]">
|
|
|
<van-button size="small" plain type="primary" @click="showListRawJsonPopup = true">查看接口原始JSON</van-button>
|
|
<van-button size="small" plain type="primary" @click="showListRawJsonPopup = true">查看接口原始JSON</van-button>
|
|
|
</view>
|
|
</view>
|
|
|
- <van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="questList">
|
|
|
|
|
|
|
+ <van-list
|
|
|
|
|
+ v-model:loading="loading"
|
|
|
|
|
+ :finished="finished"
|
|
|
|
|
+ :immediate-check="false"
|
|
|
|
|
+ finished-text="没有更多了"
|
|
|
|
|
+ @load="questList"
|
|
|
|
|
+ >
|
|
|
<view v-for="item in list" :key="item.uuid" class="list-item-style">
|
|
<view v-for="item in list" :key="item.uuid" class="list-item-style">
|
|
|
<view class="top">
|
|
<view class="top">
|
|
|
<view class="title">{{ item.questionContent }}</view>
|
|
<view class="title">{{ item.questionContent }}</view>
|
|
@@ -416,6 +450,10 @@ watch(active, async (value) => {
|
|
|
<scroll-view scroll-y class="json-scroll json-scroll--small">
|
|
<scroll-view scroll-y class="json-scroll json-scroll--small">
|
|
|
<text class="json-text">{{ listReqParamsJson }}</text>
|
|
<text class="json-text">{{ listReqParamsJson }}</text>
|
|
|
</scroll-view>
|
|
</scroll-view>
|
|
|
|
|
+ <view class="json-title">token 渠道诊断(明文)</view>
|
|
|
|
|
+ <scroll-view scroll-y class="json-scroll json-scroll--small">
|
|
|
|
|
+ <text class="json-text">{{ listTokenDiagJson }}</text>
|
|
|
|
|
+ </scroll-view>
|
|
|
<view class="json-title">列表接口完整JSON</view>
|
|
<view class="json-title">列表接口完整JSON</view>
|
|
|
<scroll-view scroll-y class="json-scroll">
|
|
<scroll-view scroll-y class="json-scroll">
|
|
|
<text class="json-text">{{ listApiRawJson }}</text>
|
|
<text class="json-text">{{ listApiRawJson }}</text>
|