index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <route lang="json">
  2. { "style": { "navigationBarTitleText": "主页数据", "navigationBarBackgroundColor": "#fff" } }
  3. </route>
  4. <script setup lang="ts">
  5. import SectionHeading from '@/components/section-heading.vue'
  6. import {
  7. getDesignerInfo,
  8. getBrowseHistories,
  9. getReserveHistory,
  10. countThisYear,
  11. } from '../../../../core/libs/requests'
  12. import { useUserStore } from '../../../../store'
  13. import { storeToRefs } from 'pinia'
  14. import Card from '@/components/card.vue'
  15. import PageHelper from '@/components/page-helper.vue'
  16. import dayjs from 'dayjs'
  17. import PageHelperEvo from '@/components/page-helper-evo.vue'
  18. const userStore = useUserStore()
  19. const { userInfo } = storeToRefs(userStore)
  20. const current = ref('累计')
  21. const request =
  22. ref<
  23. () => Promise<IResData<{ shareCount: number; viewCount: number; winCustomerCount: number }>>
  24. >()
  25. const data = ref()
  26. const info = computed(() => [
  27. { label: '分享', value: data.value?.shareCount || 0, unit: '次' },
  28. { label: '浏览', value: data.value?.viewCount || 0, unit: '次' },
  29. { label: '获客', value: data.value?.winCustomerCount || 0, unit: '人' },
  30. ])
  31. const tab = ref('分享')
  32. const tabs = ref([
  33. { label: '分享明细', value: '分享' },
  34. { label: '浏览明细', value: '浏览' },
  35. { label: '获客明细', value: '获客' },
  36. ])
  37. const query = computed(() => ({}))
  38. const setData = async ({ value }) => {
  39. console.log(1111)
  40. console.log(value)
  41. request.value = {
  42. 累计: () =>
  43. getDesignerInfo(userInfo.value.userId).then((res) => ({
  44. code: res.code,
  45. msg: res.msg,
  46. data: {
  47. shareCount: res.data.shareCount,
  48. viewCount: res.data.viewCount,
  49. winCustomerCount: res.data.winCustomerCount,
  50. },
  51. })),
  52. 本年: () =>
  53. countThisYear({ userId: userInfo.value.userId, year: new Date().getFullYear() }).then(
  54. (res) => ({
  55. code: res.code,
  56. msg: res.msg,
  57. data: {
  58. shareCount: res.data.find((it) => String(it.bizType) === '1')?.quantity || 0,
  59. viewCount: res.data.find((it) => String(it.bizType) === '3')?.quantity || 0,
  60. winCustomerCount: res.data.find((it) => String(it.bizType) === '2')?.quantity || 0,
  61. },
  62. }),
  63. ),
  64. }[value]
  65. const { data: resData } = await request.value()
  66. data.value = resData
  67. console.log(data.value)
  68. }
  69. onMounted(async () => {
  70. console.log(1111)
  71. await setData({ value: current.value })
  72. console.log(data.value)
  73. // await countThisYear({ userId: userInfo.value.userId, year: new Date().getFullYear() })
  74. })
  75. </script>
  76. <template>
  77. <div class="flex-grow flex flex-col gap-5 px-3.5 py-6">
  78. <Card>
  79. <SectionHeading title="主页数据">
  80. <template #append>
  81. <div>
  82. <wd-segmented
  83. v-model:value="current"
  84. :options="['累计', '本年']"
  85. @change="setData"
  86. ></wd-segmented>
  87. </div>
  88. </template>
  89. </SectionHeading>
  90. <div class="flex mt-7">
  91. <template v-for="(it, i) in info" :key="i">
  92. <div class="flex-1 flex flex-col items-center gap-2">
  93. <div class="flex items-end gap-0.5">
  94. <div class="text-black text-2xl font-medium font-['DIN'] leading-6">
  95. {{ it.value }}
  96. </div>
  97. <div class="text-[#333333] text-sm font-normal font-['PingFang_SC']">
  98. {{ it.unit }}
  99. </div>
  100. </div>
  101. <div class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal">
  102. {{ it.label }}
  103. </div>
  104. </div>
  105. </template>
  106. </div>
  107. </Card>
  108. <Card>
  109. <wd-tabs v-model="tab">
  110. <template v-for="(it, i) in tabs" :key="i">
  111. <wd-tab :title="it.label" :name="it.value"></wd-tab>
  112. </template>
  113. </wd-tabs>
  114. <template v-if="tab === '分享'">
  115. <PageHelper :request="getBrowseHistories" :query="{ bizType: 1 }">
  116. <template #default="{ source }">
  117. <template v-for="(it, i) in source.list" :key="i">
  118. <div class="py-4">
  119. <div class="flex">
  120. <div
  121. class="flex-1 text-black text-sm font-normal font-['PingFang_SC'] leading-normal"
  122. >
  123. <!-- 银色飞行船 -->
  124. {{ it.creatorName }}
  125. </div>
  126. <div
  127. class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal"
  128. >
  129. <!-- 浏览时长:{{ (Number(it.duration) / 60).toFixed(2) }}分钟 -->
  130. </div>
  131. </div>
  132. <div class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal">
  133. 分享时间:
  134. <!-- 2024/04/01 14:52 -->
  135. {{ dayjs(it.createTime).format('YYYY/MM/DD HH:mm') }}
  136. </div>
  137. </div>
  138. <div v-if="i < source.list.length - 1" class="bg-[#f6f6f6] h-.25"></div>
  139. </template>
  140. </template>
  141. </PageHelper>
  142. </template>
  143. <template v-if="tab === '浏览'">
  144. <PageHelper :request="getBrowseHistories" :query="query">
  145. <template #default="{ source }">
  146. <template v-for="(it, i) in source.list" :key="i">
  147. <div class="py-4">
  148. <div class="flex">
  149. <div
  150. class="flex-1 text-black text-sm font-normal font-['PingFang_SC'] leading-normal"
  151. >
  152. <!-- 银色飞行船 -->
  153. {{ it.creatorName }}
  154. </div>
  155. <div
  156. class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal"
  157. >
  158. 浏览时长:{{ (Number(it.duration) / 60).toFixed(2) }}分钟
  159. </div>
  160. </div>
  161. <div class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal">
  162. 查看时间:
  163. <!-- 2024/04/01 14:52 -->
  164. {{ dayjs(it.createTime).format('YYYY/MM/DD HH:mm') }}
  165. </div>
  166. </div>
  167. <div v-if="i < source.list.length - 1" class="bg-[#f6f6f6] h-.25"></div>
  168. </template>
  169. </template>
  170. </PageHelper>
  171. </template>
  172. <template v-if="tab === '获客'">
  173. <PageHelperEvo :request="getReserveHistory" :query="query">
  174. <template #default="{ source }">
  175. <template v-for="(it, i) in source.list" :key="i">
  176. <div class="py-4">
  177. <div class="flex gap-3">
  178. <div class="text-black text-sm font-normal font-['PingFang_SC'] leading-normal">
  179. <!-- 银色飞行船 -->
  180. {{ it.appointmentName }}
  181. </div>
  182. <div class="text-black text-sm font-normal font-['PingFang_SC'] leading-normal">
  183. <!-- 浏览时长:{{ (Number(it.duration) / 60).toFixed(2) }}分钟 -->
  184. {{ it.appointmentPhone }}
  185. </div>
  186. </div>
  187. <div class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal">
  188. 获客时间:
  189. <!-- 2024/04/01 14:52 -->
  190. {{ dayjs(it.createTime).format('YYYY/MM/DD HH:mm') }}
  191. </div>
  192. </div>
  193. <div v-if="i < source.list.length - 1" class="bg-[#f6f6f6] h-.25"></div>
  194. </template>
  195. </template>
  196. </PageHelperEvo>
  197. </template>
  198. </Card>
  199. </div>
  200. </template>