diff --git a/src/api/query.ts b/src/api/query.ts index 720f597..d4578b8 100644 --- a/src/api/query.ts +++ b/src/api/query.ts @@ -1,7 +1,7 @@ /* eslint-disable indent */ +import { apiFail } from '@/data/constants' import { useLocalStorage } from '@vueuse/core' import { APIRoot, PaginationResponse } from './api-models' -import { apiFail } from '@/data/constants' const cookie = useLocalStorage('JWT_Token', '') @@ -62,16 +62,21 @@ export async function QueryGetAPI( return await QueryGetAPIInternal>(urlString, params, headers) } async function QueryGetAPIInternal(urlString: string, params?: any, headers?: [string, string][]) { - const url = new URL(urlString) - url.search = getParams(params) - if (cookie.value) { - headers ??= [] - if (cookie.value) headers?.push(['Authorization', `Bearer ${cookie.value}`]) + try { + const url = new URL(urlString) + url.search = getParams(params) + if (cookie.value) { + headers ??= [] + if (cookie.value) headers?.push(['Authorization', `Bearer ${cookie.value}`]) + } + return await QueryAPIInternal(url, { + method: 'get', + headers: headers, + }) + } catch (err) { + console.log(`url:${urlString}, error:${err}`) + throw err } - return await QueryAPIInternal(url, { - method: 'get', - headers: headers, - }) } function getParams(params: any) { const urlParams = new URLSearchParams(window.location.search) diff --git a/src/views/manage/point/PointSubItemManage.vue b/src/views/manage/point/PointSubItemManage.vue new file mode 100644 index 0000000..f2d25df --- /dev/null +++ b/src/views/manage/point/PointSubItemManage.vue @@ -0,0 +1,8 @@ + + + \ No newline at end of file diff --git a/src/views/manage/point/PointUserManage.vue b/src/views/manage/point/PointUserManage.vue index 3c8ac85..313715a 100644 --- a/src/views/manage/point/PointUserManage.vue +++ b/src/views/manage/point/PointUserManage.vue @@ -31,6 +31,7 @@ import { computed, h, onMounted, ref } from 'vue' import PointUserDetailCard from './PointUserDetailCard.vue' import { Info24Filled } from '@vicons/fluent' import { objectsToCSV } from '@/Utils' +import { format } from 'date-fns' const props = defineProps<{ goods: ResponsePointGoodModel[] @@ -245,6 +246,22 @@ async function deleteUser(user: ResponsePointUserModel) { isLoading.value = false } } +function exportData() { +/* const text = objectsToCSV( + users.value.map((s) => { + const gift = props.goods.find((g) => g.id == s.goodsId) + return { + } + }), + ) + const BOM = new Uint8Array([0xef, 0xbb, 0xbf]) + const utf8encoder = new TextEncoder() + const utf8array = utf8encoder.encode(text) + saveAs( + new Blob([BOM, utf8array], { type: 'text/csv;charset=utf-8;' }), + `用户积分_${format(Date.now(), 'yyyy-MM-dd HH:mm:ss')}_${accountInfo.value?.name}_.csv`, + )*/ +} onMounted(async () => { await refresh() @@ -266,6 +283,7 @@ onMounted(async () => { 刷新 给予/扣除积分 + 导出积分数据 diff --git a/src/views/pointViews/PointGoodsView.vue b/src/views/pointViews/PointGoodsView.vue index a36e3b8..f4d453d 100644 --- a/src/views/pointViews/PointGoodsView.vue +++ b/src/views/pointViews/PointGoodsView.vue @@ -2,37 +2,35 @@ import { NavigateToNewTab } from '@/Utils' import { useAccount } from '@/api/account' import { - AddressInfo, - GoodsTypes, - ResponsePointGoodModel, - ResponsePointOrder2UserModel, - UserInfo, +AddressInfo, +GoodsTypes, +ResponsePointGoodModel, +ResponsePointOrder2UserModel, +UserInfo, } from '@/api/api-models' import AddressDisplay from '@/components/manage/AddressDisplay.vue' import PointGoodsItem from '@/components/manage/PointGoodsItem.vue' import { POINT_API_URL } from '@/data/constants' import { useAuthStore } from '@/store/useAuthStore' import { - NAlert, - NButton, - NCard, - NDivider, - NEmpty, - NFlex, - NForm, - NFormItem, - NGrid, - NGridItem, - NInputNumber, - NModal, - NSelect, - NSpin, - NTag, - NText, - NTooltip, - SelectOption, - useDialog, - useMessage, +NAlert, +NButton, +NCard, +NDivider, +NEmpty, +NFlex, +NForm, +NFormItem, +NInputNumber, +NModal, +NSelect, +NSpin, +NTag, +NText, +NTooltip, +SelectOption, +useDialog, +useMessage } from 'naive-ui' import { computed, h, onMounted, ref } from 'vue' import { useRouter } from 'vue-router' @@ -62,6 +60,15 @@ const selectedAddress = ref() const canDoBuy = computed(() => { return currentGoods.value && currentGoods.value.price * buyCount.value <= currentPoint.value }) +const tags = computed(() => { + return Array.from(new Set(goods.value.flatMap((g) => g.tags))) +}) +const selectedTag = ref() +const selectedItems = computed(() => { + return selectedTag.value + ? goods.value.filter((g) => g.tags.includes(selectedTag.value)) + : goods.value +}) const addressOptions = computed(() => { if (!biliAuth.value.id) return [] @@ -208,10 +215,23 @@ onMounted(async () => { 你在 {{ userInfo.extra?.streamerInfo?.name ?? userInfo.name }} 的直播间的积分为 {{ currentPoint }} + + + + {{ tag }} + + + + - 暂无礼物 + 暂无礼物 - +