|
@@ -1,13 +1,16 @@
|
|
|
<script setup>
|
|
|
-import { ref, computed, onMounted, getCurrentInstance } from 'vue'
|
|
|
+import { ref, computed, onMounted, getCurrentInstance, nextTick } from 'vue'
|
|
|
import { Tabs, Tab } from 'vant'
|
|
|
import { useStore } from '@/store'
|
|
|
import AppEmpty from '@/ui/empty/index.vue'
|
|
|
-import { getUserAccountInfo } from '@/api/modules'
|
|
|
+import { getUserAccountInfo, vipGiftRecordAjax } from '@/api/modules'
|
|
|
+import { dateFormatter, formatMonthsToYearsMonths } from '@/utils/utils'
|
|
|
|
|
|
const { getters } = useStore()
|
|
|
const that = getCurrentInstance().proxy
|
|
|
|
|
|
+const queryTab = that.$route.query?.activeTab
|
|
|
+
|
|
|
// 是否是免费用户
|
|
|
const isFree = computed(() => {
|
|
|
return getters['user/isFree']
|
|
@@ -23,31 +26,11 @@ const expireTime = computed(() => {
|
|
|
return superInfo.value.endTime
|
|
|
})
|
|
|
// tab索引
|
|
|
-const activeName = ref(0)
|
|
|
+const activeName = ref(1)
|
|
|
// 赠送列表
|
|
|
-const giftList = ref([
|
|
|
- {
|
|
|
- id: '111',
|
|
|
- phone: '1333333333',
|
|
|
- duration: 2,
|
|
|
- time: '2023-07-01'
|
|
|
- },
|
|
|
- {
|
|
|
- id: '222',
|
|
|
- phone: '1333333333',
|
|
|
- duration: 1,
|
|
|
- time: '2023-09-01'
|
|
|
- }
|
|
|
-])
|
|
|
+const giftList = ref([])
|
|
|
// 接收列表
|
|
|
-const receiveList = ref([
|
|
|
- {
|
|
|
- id: '333',
|
|
|
- phone: '1333333333',
|
|
|
- duration: 1,
|
|
|
- time: '2023-09-01'
|
|
|
- }
|
|
|
-])
|
|
|
+const receiveList = ref([])
|
|
|
// 赠送为空提示
|
|
|
const giftEmpty = computed(() => {
|
|
|
if (isSuper.value) {
|
|
@@ -73,14 +56,59 @@ const giftEmpty = computed(() => {
|
|
|
}
|
|
|
})
|
|
|
// 通知好友
|
|
|
-const onNotify = (item) => {
|
|
|
- that.$router.push(`/giving/notify?id=${item.id}`)
|
|
|
+const onNotify = (id) => {
|
|
|
+ that.$router.push(`/giving/notify/${id}`)
|
|
|
}
|
|
|
// 跳转页面
|
|
|
const goTargetPage = (link) => {
|
|
|
that.$router.push(link)
|
|
|
}
|
|
|
|
|
|
+// 获取赠送记录
|
|
|
+const getGiftRecordList = async (type = '1') => {
|
|
|
+ const { error_code: code, data } = await vipGiftRecordAjax({
|
|
|
+ giftType: type
|
|
|
+ })
|
|
|
+ if (code === 0 && data && data.list) {
|
|
|
+ if(type === '1') {
|
|
|
+ const convertedList = data.list.map(subArr => {
|
|
|
+ if (subArr.length === 0) return null
|
|
|
+ const { createTime } = subArr[0]
|
|
|
+ const arr = subArr.map(({ createTime, ...rest }) => rest);
|
|
|
+ return { arr, createTime }
|
|
|
+ }).filter(item => item !== null)
|
|
|
+ giftList.value = convertedList.map((item) => {
|
|
|
+ item.createTime = dateFormatter(item.createTime, 'yyyy.MM.dd HH:mm:ss')
|
|
|
+ item.arr = item.arr.map((v) => {
|
|
|
+ return {
|
|
|
+ id: v.id,
|
|
|
+ phone: v.recipientUserPhone,
|
|
|
+ duration: v.duration
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return item
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ receiveList.value = data.list.flat().map((item) => {
|
|
|
+ return {
|
|
|
+ id: item.id,
|
|
|
+ phone: item.giftUserPhone,
|
|
|
+ duration: formatMonthsToYearsMonths(item.duration),
|
|
|
+ createTime: dateFormatter(item.createTime, 'yyyy.MM.dd HH:mm:ss')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ giftList.value = []
|
|
|
+ receiveList.value = []
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const onTabChange = (name) => {
|
|
|
+ activeName.value = name
|
|
|
+ getGiftRecordList(name)
|
|
|
+}
|
|
|
+
|
|
|
onMounted(async () => {
|
|
|
if (isSuper.value) {
|
|
|
const { data } = await getUserAccountInfo()
|
|
@@ -88,26 +116,31 @@ onMounted(async () => {
|
|
|
superInfo.value = data?.list.find((v) => v.name === '超级订阅')
|
|
|
}
|
|
|
}
|
|
|
+ if (queryTab) {
|
|
|
+ activeName.value = queryTab
|
|
|
+ }
|
|
|
+ await nextTick()
|
|
|
+ getGiftRecordList(activeName.value)
|
|
|
})
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
<div class="j-container gift-record">
|
|
|
- <Tabs class="j-container" v-model="activeName">
|
|
|
- <Tab title="我赠送的" name="0">
|
|
|
+ <Tabs class="j-container" v-model="activeName" @change="onTabChange">
|
|
|
+ <Tab title="我赠送的" name="1">
|
|
|
<div v-if="giftList.length" class="gift-list">
|
|
|
- <div class="gift-item" v-for="item in giftList" :key="item.id">
|
|
|
- <div class="gift-item-time">赠送时间:{{ item.time }}</div>
|
|
|
- <div class="flex flex-items-center">
|
|
|
+ <div class="gift-item" v-for="gift in giftList" :key="gift.createTime">
|
|
|
+ <div class="gift-item-time">赠送时间:{{ gift.createTime }}</div>
|
|
|
+ <div v-for="item in gift.arr" :key="item.id" class="flex flex-items-center">
|
|
|
<div class="gift-item-info">
|
|
|
<span class="gift-item-label">手机号:</span>
|
|
|
<span class="gift-item-value">{{ item.phone }}</span>
|
|
|
</div>
|
|
|
<div class="flex-1 gift-item-info">
|
|
|
<span class="gift-item-label">时长:</span>
|
|
|
- <span class="gift-item-value">{{ item.duration }} 个月</span>
|
|
|
+ <span class="gift-item-value">{{ item.duration }}个月</span>
|
|
|
</div>
|
|
|
- <div class="flex flex-items-center" @click.stop="onNotify(item)">
|
|
|
+ <div class="flex flex-items-center" @click.stop="onNotify(item.id)">
|
|
|
<span class="gift-item-notify">告知朋友</span>
|
|
|
<i class="j-icon j-base-icon icon-notify-active"></i>
|
|
|
</div>
|
|
@@ -123,7 +156,7 @@ onMounted(async () => {
|
|
|
</AppEmpty>
|
|
|
</div>
|
|
|
</Tab>
|
|
|
- <Tab title="我接收的" name="1">
|
|
|
+ <Tab title="我接收的" name="2">
|
|
|
<div v-if="receiveList.length" class="receive-list">
|
|
|
<ul
|
|
|
class="receive-item"
|
|
@@ -131,7 +164,7 @@ onMounted(async () => {
|
|
|
:key="receive.id"
|
|
|
>
|
|
|
<li class="receive-item-time pb-4px">
|
|
|
- 赠送时间:{{ receive.time }}
|
|
|
+ 赠送时间:{{ receive.createTime }}
|
|
|
</li>
|
|
|
<li class="flex flex-items-center pt-4px">
|
|
|
<span class="receive-item-label">来自好友:</span>
|
|
@@ -140,7 +173,7 @@ onMounted(async () => {
|
|
|
<li class="flex flex-items-center pt-4px">
|
|
|
<span class="receive-item-label">得赠时长:</span>
|
|
|
<span class="receive-item-value"
|
|
|
- >{{ receive.duration }} 个月</span
|
|
|
+ >{{ receive.duration }}</span
|
|
|
>
|
|
|
</li>
|
|
|
</ul>
|
|
@@ -235,7 +268,8 @@ onMounted(async () => {
|
|
|
@include valueStyle;
|
|
|
}
|
|
|
}
|
|
|
- .gift-empty {
|
|
|
+ .gift-empty,
|
|
|
+ .receive-empty {
|
|
|
height: 100%;
|
|
|
background: #fff;
|
|
|
}
|