index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <div class="layout-padding">
  3. <el-row :gutter="12" style="padding: 0 12px 12px; row-gap: 12px;">
  4. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  5. <LayoutHeader title="卸载画像" :style="{ marginBottom: '0' }">
  6. <template #tooltip-content>
  7. 敬请期待
  8. </template>
  9. <template #content>
  10. <div class="content">
  11. <div class="select-form">
  12. <svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
  13. <path d="M33 15H15V30H33V15Z" fill="#167AF0" stroke="#167AF0" stroke-width="2" stroke-linejoin="round" />
  14. <path d="M20 35L24 30L28 35" stroke="#167AF0" stroke-width="2" stroke-linecap="round"
  15. stroke-linejoin="round" />
  16. <path d="M18 25L21.0967 22.034L23.5345 24.3738L29 19" stroke="white" stroke-width="2"
  17. stroke-linecap="round" stroke-linejoin="round" />
  18. <path d="M13 15H35" stroke="#167AF0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
  19. <rect width="48" height="48" rx="14" fill="#167AF0" fill-opacity="0.1" />
  20. </svg>
  21. <el-form :inline="true" :model="form" label-width="0">
  22. <el-form-item label="">
  23. <el-select v-model="form.time" placeholder="" @change="selectTimeChange">
  24. <el-option label="按周查看" value="week" />
  25. <el-option label="按月查看" value="month" />
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item label="">
  29. <el-date-picker disabled :type="'daterange'" style="width: 242px;" v-model="form.dateArray" range-separator="至" @change="selectDateChange"
  30. start-placeholder="开始日期" end-placeholder="结束日期" :disabled-date="disabledDate" />
  31. </el-form-item>
  32. <el-form-item label="">
  33. {{ form.time == 'week' ? '一周内' : '一月内' }},卸载流失设备数<span>{{ uninstallCount.count }}</span>
  34. </el-form-item>
  35. <div class="tips">您可以根据下方的卸载画像报表,查看易卸载用户和高粘性用户的特征,了解什么样的用户留不住。</div>
  36. </el-form>
  37. </div>
  38. </div>
  39. </template>
  40. </LayoutHeader>
  41. </el-col>
  42. </el-row>
  43. <el-row :gutter="12" style="padding: 0 12px 12px; row-gap: 12px;">
  44. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  45. <el-card shadow="none">
  46. <el-row :gutter="12" style="padding: 0 12px 0; row-gap: 12px;">
  47. <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
  48. <el-card shadow="none">
  49. <UserInfo title="易卸载用户特征" :type="true" :tags="easyTags" tips="卸载用户 vs. 活跃用户具备的明显特征,有以下特征的用户易卸载" style="margin-bottom: 24px;"></UserInfo>
  50. <DataTable :data="easyData" :columns="columns"></DataTable>
  51. </el-card>
  52. </el-col>
  53. <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
  54. <el-card shadow="none">
  55. <UserInfo title="不易卸载用户特征" :type="false" :tags="hardTags" tips="活跃用户 vs. 卸载用户具备的明显差异点,有以下特征的人群卸载可能性低" style="margin-bottom: 24px;"></UserInfo>
  56. <DataTable :data="hardData" :columns="columns"></DataTable>
  57. </el-card>
  58. </el-col>
  59. </el-row>
  60. </el-card>
  61. </el-col>
  62. </el-row>
  63. <el-row :gutter="12" style="padding: 0 12px 12px; row-gap: 12px;">
  64. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  65. <el-card shadow="none" style="padding: 10px 0 0;">
  66. <div class="card-header">
  67. <svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
  68. <rect width="60" height="60" rx="14" fill="#167AF0" fill-opacity="0.1" />
  69. <path d="M16.667 19.167H43.3337" stroke="#2B65AA" stroke-width="2" stroke-linecap="round"
  70. stroke-linejoin="round" />
  71. <path d="M25 14.167H35" stroke="#2B65AA" stroke-width="2" stroke-linecap="round"
  72. stroke-linejoin="round" />
  73. <path
  74. d="M20 24.167H40V43.3337C40 44.7144 38.8807 45.8337 37.5 45.8337H22.5C21.1192 45.8337 20 44.7144 20 43.3337V24.167Z"
  75. stroke="#2B65AA" stroke-width="2" stroke-linejoin="round" />
  76. <path d="M26.667 30.833L33.3337 37.4997" stroke="#2B65AA" stroke-width="2" stroke-linecap="round"
  77. stroke-linejoin="round" />
  78. <path d="M33.3337 30.833L26.667 37.4997" stroke="#2B65AA" stroke-width="2" stroke-linecap="round"
  79. stroke-linejoin="round" />
  80. </svg>
  81. <div class="title">新用户卸载高峰阶段</div>
  82. <div class="tips">卸载用户集中在使用App<span>未使用</span>后卸载。(仅计算在当前时间周期内卸载,且卸载前30天内新安装App的设备。)</div>
  83. </div>
  84. <el-row :gutter="12" style="padding: 12px 12px 12px; row-gap: 12px;">
  85. <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
  86. <div style="padding-top: 8px;" v-if="echartsData.length > 0">
  87. <BarChart :data="echartsData" :is-multi-series="true" :series-names="seriesNames" title=""
  88. style="height: 380px;" :chartHeight="380" />
  89. </div>
  90. </el-col>
  91. <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
  92. <div class="">
  93. <DataTable :data="usageTimeData" :columns="columns2"></DataTable>
  94. </div>
  95. </el-col>
  96. </el-row>
  97. </el-card>
  98. </el-col>
  99. </el-row>
  100. </div>
  101. </template>
  102. <script setup lang="ts">
  103. import { ref, onMounted } from 'vue';
  104. import UserInfo from './components/UserInfo.vue';
  105. import DataTable from './components/DataTable.vue';
  106. import BarChart from '/@/views/count/components/BarChart.vue';
  107. import { formatDate } from '/@/utils/formatTime';
  108. import { uninstallPortrait } from '/@/api/count/churn';
  109. import LayoutHeader from '/@/views/count/components/LayoutHeader.vue';
  110. const columns = ref([
  111. { label: '用户特征', prop: 'name', width: '100px' },
  112. { prop: 'percent', type: 'percentDom' },
  113. { label: 'TGI', prop: 'tgi', width: '100px' },
  114. { label: '百分比', prop: 'percent', width: '100px' },
  115. ])
  116. const columns2 = ref([
  117. { label: '卸载前使用App次数', prop: 'phase', width: '150px' },
  118. { prop: 'percent', type: 'percentDom' },
  119. { label: '百分比', prop: 'percent', width: '100px' },
  120. { label: '卸载用户数', prop: 'count', width: '100px' },
  121. ])
  122. const form = ref({
  123. time: 'week',
  124. dateArray: [formatDate(new Date(new Date().setDate(new Date().getDate() - 15)), 'YYYY-mm-dd'), formatDate(new Date(new Date().setDate(new Date().getDate() - 9)), 'YYYY-mm-dd')]
  125. })
  126. const echartsData = ref<any[]>([])
  127. const seriesNames = ref<string[]>(['卸载用户数']);
  128. const easyData = ref<any[]>([])
  129. const hardData = ref<any[]>([])
  130. const usageTimeData = ref<any[]>([])// 使用次数
  131. const uninstallCount = ref({
  132. count: 0,
  133. })
  134. const hardTags = ref<string[]>([])
  135. const easyTags = ref<string[]>([])
  136. const init = () => {
  137. uninstallPortrait({
  138. startDate: formatDate(new Date(form.value.dateArray[0]), 'YYYY-mm-dd'),
  139. endDate: formatDate(new Date(form.value.dateArray[1]), 'YYYY-mm-dd'),
  140. timeUnit: form.value.time,
  141. }).then(res => {
  142. uninstallCount.value = {
  143. count: res.data?.uninstallCount.count,
  144. }
  145. // if (res.data?.uninstallPortraitPhaseList) {
  146. const newData: any[] = [];
  147. easyData.value = [];
  148. hardData.value = [];
  149. easyTags.value = [];
  150. hardTags.value = [];
  151. usageTimeData.value = [];
  152. res.data?.uninstallPortraitPhaseList.forEach((item: any) => {
  153. newData.push({
  154. name: item.phase,
  155. values: [
  156. {
  157. value: item.count,
  158. percentage: item.rate + "%",
  159. }
  160. ]
  161. });
  162. });
  163. echartsData.value = newData;
  164. res.data?.uninstallPortraitPhaseList.forEach((item: any) => {
  165. usageTimeData.value.push({
  166. ...item,
  167. percent: item.rate,
  168. });
  169. })
  170. // }
  171. // if (res.data?.uninstallPortraitCharactList) {
  172. res.data?.uninstallPortraitCharactList.forEach((item: any) => {
  173. if(item.status == 0){
  174. easyData.value.push({
  175. ...item,
  176. percent: item.percent.substring(0, item.percent.length - 1),
  177. });
  178. easyTags.value = [...easyData.value].sort((a: any, b: any) => b.percent - a.percent).map((item: any) => item.name).slice(0, 3);
  179. } else {
  180. hardData.value.push({
  181. ...item,
  182. percent: item.percent.substring(0, item.percent.length - 1),
  183. });
  184. hardTags.value = [...hardData.value].sort((a: any, b: any) => b.percent - a.percent).map((item: any) => item.name).slice(0, 3);
  185. }
  186. })
  187. // }
  188. })
  189. }
  190. const selectTimeChange = () => {
  191. console.log(form.value.time);
  192. if(form.value.time == 'week'){
  193. form.value.dateArray = [formatDate(new Date(new Date().setDate(new Date().getDate() - 15)), 'YYYY-mm-dd'), formatDate(new Date(new Date().setDate(new Date().getDate() - 9)), 'YYYY-mm-dd')]
  194. } else {
  195. form.value.dateArray = [formatDate(new Date(new Date().setDate(new Date().getDate() - 39)), 'YYYY-mm-dd'), formatDate(new Date(new Date().setDate(new Date().getDate() - 9)), 'YYYY-mm-dd')]
  196. }
  197. init();
  198. }
  199. const selectDateChange = () => {
  200. console.log(form.value.dateArray);
  201. init();
  202. }
  203. const disabledDate = (time: Date) => {
  204. return time.getTime() > Date.now() - 86400000*9;
  205. }
  206. onMounted(() => {
  207. init();
  208. })
  209. </script>
  210. <style scoped lang="scss">
  211. @import '/@/views/count/styles/common.scss';
  212. svg {
  213. vertical-align: middle;
  214. margin: 0 0 0 12px;
  215. }
  216. .select-form-card {
  217. .card-title {
  218. color: rgba(18, 18, 18, 1);
  219. font-weight: 500;
  220. font-family: Source Han Sans SC;
  221. }
  222. }
  223. .select-form {
  224. margin-top: 20px;
  225. padding-left: 68px;
  226. position: relative;
  227. font-family: Source Han Sans SC;
  228. font-weight: 400;
  229. font-size: 14px;
  230. color: rgba(100, 100, 100, 1);
  231. line-height: 14px;
  232. :deep(.el-form-item--default) {
  233. margin-bottom: 12px;
  234. }
  235. span {
  236. color: rgba(22, 122, 240, 1);
  237. font-weight: 500;
  238. font-size: 20px;
  239. padding: 0 8px;
  240. }
  241. svg {
  242. position: absolute;
  243. left: 0;
  244. top: 0;
  245. margin: 0 0 0 0!important;
  246. }
  247. .el-form-item__content {
  248. .el-select {
  249. width: 147px !important;
  250. min-width: 147px !important;
  251. }
  252. }
  253. }
  254. .card-header {
  255. padding-left: 92px;
  256. position: relative;
  257. margin-bottom: 12px;
  258. svg {
  259. position: absolute;
  260. top: 0;
  261. left: 0px;
  262. }
  263. .title {
  264. color: rgba(18, 18, 18, 1);
  265. font-family: Source Han Sans SC;
  266. font-weight: 500;
  267. font-size: 16px;
  268. line-height: 23px;
  269. margin-bottom: 12px;
  270. }
  271. .tips {
  272. color: rgba(100, 100, 100, 1);
  273. font-family: Source Han Sans SC;
  274. font-weight: 400;
  275. font-size: 12px;
  276. line-height: 100%;
  277. span {
  278. color: rgba(18, 18, 18, 1);
  279. font-weight: 500;
  280. font-size: 20px;
  281. padding: 0 8px;
  282. }
  283. }
  284. }
  285. .card-content {
  286. display: flex;
  287. gap: 12px;
  288. padding: 0px 12px;
  289. .chart-container {
  290. width: 100%;
  291. height: 300px;
  292. }
  293. }
  294. </style>