index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div class="p-4">
  3. <!-- <GrowCard :loading="loading" :list="growCardList" class="enter-y" /> -->
  4. <div class="md:flex !my-4 enter-y">
  5. <div class="md:w-1/3 w-full !md:mt-0 !mt-4 !md:mr-4 topItem">
  6. <div class="deadline">截止至昨日24时</div>
  7. <div class="preview">
  8. <div class="item">
  9. <div class="title">带看房间</div>
  10. <div class="value">{{topData.roomCount}}</div>
  11. </div>
  12. <div class="item">
  13. <div class="title">访问总人数</div>
  14. <div class="value">{{topData.visitManCount}}</div>
  15. </div>
  16. </div>
  17. <div class="preview">
  18. <div class="item">
  19. <div class="title">访问总次数</div>
  20. <div class="value">{{topData.visitCount}}</div>
  21. </div>
  22. <div class="item">
  23. <div class="title">分享总次数</div>
  24. <div class="value">{{topData.shareCount}}</div>
  25. </div>
  26. </div>
  27. </div>
  28. <div class="md:w-1/3 w-full !md:mt-0 !mt-4 !md:mr-4 topItem">
  29. <div class="deadline">截止至昨日24时</div>
  30. <div class="shuffleTitle">观看次数排行(前5)</div>
  31. <shuffle :nameObj="{ name: '名称', value: '留言次数' }" :list="topData.takeLookList" />
  32. </div>
  33. <div class="md:w-1/3 w-full !md:mt-0 !mt-4 !md:mr-4 topItem">
  34. <div class="deadline">截止至昨日24时</div>
  35. <div class="shuffleTitle">留言数排行(前5)</div>
  36. <shuffle :nameObj="{ name: '微信昵称', value: '留言次数' }" :list="topData.danmakuList" />
  37. </div>
  38. </div>
  39. <div class="!my-4 enter-y">
  40. <Card title="房间使用情况">
  41. <template #extra>
  42. <div class="condition">
  43. <div class="selct" style="display: inline-block">
  44. <!-- <span style="margin-right:15px"></span> -->
  45. <Input
  46. v-model:value="roomTitle"
  47. style="width: 150px; margin-right: 30px"
  48. placeholder="请输入房间名称"
  49. ></Input>
  50. </div>
  51. <div class="selct" style="display: inline-block; margin-right: 15px">
  52. <RangePicker
  53. v-model:value="selectTime"
  54. @calendarChange="calendarPriceRangeChange"
  55. valueFormat="YYYY-MM-DD"
  56. :disabled-date="disabledDate"
  57. format="YYYY-MM-DD"
  58. />
  59. </div>
  60. <a-button @click="getData(true)" type="primary">确认</a-button>
  61. <a-button @click="export" type="primary">导出</a-button>
  62. </div>
  63. </template>
  64. <div class="echartList">
  65. <div class="echars">
  66. <VisitAnalysisBar
  67. :loading="loading"
  68. :viewStatics="viewStaticsData"
  69. :shareStatics="shareStaticsData"
  70. />
  71. </div>
  72. <div class="echars">
  73. <VisitAnalysis
  74. :loading="loading"
  75. :bulletChatAmounts="bulletChatAmountsData"
  76. :userAmount="userAmountData"
  77. />
  78. </div>
  79. </div>
  80. </Card>
  81. </div>
  82. </div>
  83. </template>
  84. <script lang="ts" setup>
  85. import { onMounted, reactive, ref } from 'vue';
  86. import shuffle from '../components/shuffle.vue';
  87. import { Input, DatePicker, Card } from 'ant-design-vue';
  88. import VisitAnalysisBar from './VisitAnalysisBar.vue';
  89. import VisitAnalysis from './VisitAnalysis.vue';
  90. const { RangePicker } = DatePicker;
  91. import type { Dayjs } from 'dayjs';
  92. import dayjs from 'dayjs';
  93. import { roomData, takeLookTop5, roomVisitData } from '/@/api/statistics/index';
  94. type RangeValue = [Dayjs, Dayjs];
  95. const loading = ref(true);
  96. const roomTitle = ref('');
  97. const selectPriceDate = ref(dayjs().subtract(6, 'month').format('YYYY-MM-DD'));
  98. const selectTime = ref<RangeValue>([
  99. dayjs().subtract(1, 'month').format('YYYY-MM-DD'),
  100. dayjs().format('YYYY-MM-DD'),
  101. ]);
  102. const viewStaticsData = ref([]);
  103. const shareStaticsData = ref([]);
  104. const bulletChatAmountsData = ref([]);
  105. const userAmountData = ref([]);
  106. const topData = reactive({
  107. roomCount: 0,
  108. visitManCount: 0,
  109. visitCount: 0,
  110. shareCount: 0,
  111. takeLookList: [],
  112. danmakuList: [],
  113. });
  114. async function getData(type) {
  115. try {
  116. loading.value = true;
  117. if (type) {
  118. let { roomCount, shareCount, visitCount, visitManCount } = await roomData({});
  119. topData.roomCount = roomCount
  120. topData.shareCount = shareCount
  121. topData.visitCount = visitCount
  122. topData.visitManCount = visitManCount
  123. let { takeLookList, danmakuList } = await takeLookTop5({});
  124. topData.takeLookList = takeLookList
  125. topData.danmakuList = danmakuList
  126. }
  127. const {userMsgCountList,userMsgManList,userShareList,userVisitList} = await roomVisitData({
  128. roomTitle: roomTitle.value,
  129. timeList: selectTime.value,
  130. });
  131. viewStaticsData.value = userMsgManList
  132. shareStaticsData.value = userShareList
  133. bulletChatAmountsData.value = userMsgManList
  134. userAmountData.value = userMsgCountList
  135. console.log('visitData', visitData);
  136. loading.value = false;
  137. } catch (error) {
  138. loading.value = false;
  139. }
  140. }
  141. const disabledDate = (current: Dayjs) => {
  142. if (selectPriceDate.value) {
  143. return (
  144. current > dayjs(selectPriceDate.value).add(2, 'year') ||
  145. current < dayjs(selectPriceDate.value).subtract(2, 'year')
  146. );
  147. } else {
  148. return false;
  149. }
  150. };
  151. function calendarPriceRangeChange(date) {
  152. selectPriceDate.value = date[0];
  153. }
  154. onMounted(() => {
  155. getData(true);
  156. });
  157. </script>
  158. <style lang="less" scoped>
  159. .topItem {
  160. background: #fff;
  161. padding: 30px 20px;
  162. width: 100%;
  163. .preview {
  164. display: flex;
  165. width: 100%;
  166. align-items: center;
  167. .item {
  168. width: 50%;
  169. flex: 1;
  170. text-align: center;
  171. line-height: 30px;
  172. font-size: 24px;
  173. .title {
  174. font-size: 14px;
  175. padding: 20px 0 10px 0;
  176. }
  177. }
  178. }
  179. .preview {
  180. }
  181. .deadline {
  182. text-align: right;
  183. }
  184. .shuffleTitle{
  185. font-size:14px;
  186. }
  187. }
  188. .echartList {
  189. .echars {
  190. height: 280px;
  191. width: 100%;
  192. margin-bottom: 30px;
  193. }
  194. }
  195. </style>