index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <view class="person_cards_wrap">
  3. <view class="cards_container">
  4. <view class="tab_container">
  5. <u-tabs :list="tabList" :current="currentTab" @change="changeTab" active-color="#2563eb" :is-scroll="false"></u-tabs>
  6. </view>
  7. <view class="card_item today">
  8. <view class="card_item_content">
  9. <view class="card_header">
  10. <text class="card_title">抖音<br />消耗(元)</text>
  11. </view>
  12. <view class="card_content">
  13. <text class="card_value">{{ formatMoney(cardData.consumeDy) }}</text>
  14. </view>
  15. </view>
  16. <view class="card_item_content">
  17. <view class="card_header">
  18. <text class="card_title">广点通<br />消耗(元)</text>
  19. </view>
  20. <view class="card_content">
  21. <text class="card_value">{{ formatMoney(cardData.consumeGdt) }}</text>
  22. </view>
  23. </view>
  24. <view class="card_item_content">
  25. <view class="card_header">
  26. <text class="card_title">业绩(元)</text>
  27. </view>
  28. <view class="card_content">
  29. <text class="card_value">{{ formatMoney(cardData.performance) }}</text>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 条数统计 -->
  34. <view class="card_item card_item_full">
  35. <view class="card_header count">
  36. <image class="count_icon" src="../../../static/icons/statistics.png" alt=""></image>
  37. <text class="card_title">条数统计</text>
  38. </view>
  39. <view class="card_content">
  40. <view class="count_stats">
  41. <view class="count_item">
  42. <text class="count_value">{{ cardData.countTypeA }}</text>
  43. <text class="count_label">A类</text>
  44. </view>
  45. <view class="count_item">
  46. <text class="count_value">{{ cardData.countTypeB }}</text>
  47. <text class="count_label">B类</text>
  48. </view>
  49. <view class="count_item">
  50. <text class="count_value">{{ cardData.countTypeC }}</text>
  51. <text class="count_label">C类</text>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <!-- 上门 -->
  57. <view class="card_item card_item_full">
  58. <view class="card_content">
  59. <view class="visit_stats">
  60. <view class="visit_item">
  61. <text class="visit_label">上门</text>
  62. <text class="visit_value visitc_count">{{ cardData.visitCount }}</text>
  63. </view>
  64. <view class="visit_item">
  65. <text class="visit_label">上门率</text>
  66. <text class="visit_value">{{ formatPercent(cardData.visitRate) }}</text>
  67. </view>
  68. <view class="visit_item">
  69. <text class="visit_label">成交率</text>
  70. <text class="visit_value">{{ formatPercent(cardData.dealRate) }}</text>
  71. </view>
  72. <view class="visit_item">
  73. <text class="visit_label">投产比</text>
  74. <text class="visit_value">{{ formatMoney(cardData.roi) }}</text>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <!-- 当前排名 -->
  80. <view class="card_item card_item_full">
  81. <view class="card_content">
  82. <view class="ranking_stats">
  83. <view class="ranking_info">
  84. <view class="ranking_icon">
  85. <image class="ranking_icon_img" src="../../../static/icons/trophy.png" alt=""></image>
  86. </view>
  87. <view class="ranking_info_text">
  88. <text class="card_title">当前排名</text>
  89. <text class="ranking_text">击败了{{ formatMoney(cardData.beatRate) }}%的同事</text>
  90. </view>
  91. </view>
  92. <view class="ranking_details">
  93. <view class="ranking_detail_item">
  94. <text class="ranking_detail_value">{{ cardData.level }}</text>
  95. <text class="ranking_detail_label">等级</text>
  96. </view>
  97. <view class="ranking_detail_item">
  98. <text class="ranking_detail_value">{{ cardData.score }}</text>
  99. <text class="ranking_detail_label">评分</text>
  100. </view>
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. <!-- 折线图 -->
  106. <view class="card_item" v-if="false">
  107. <view class="chart_header">
  108. <image class="chart_icon" src="../../../static/icons/line.png" alt=""></image>
  109. <text class="card_title">近7天排名折线图</text>
  110. </view>
  111. <view class="charts_box">
  112. <qiun-data-charts type="line" :chartData="chartData" canvasId="uniqueLineChart" :opts="opts"
  113. width="700rpx" height="350rpx" backgroundColor="#ffffff" />
  114. </view>
  115. </view>
  116. </view>
  117. <!-- 最新线索 -->
  118. <view class="latest_clue" v-if="clueList.length > 0">
  119. <view class="clue_header">
  120. <text class="card_title">最新线索</text>
  121. <view class="more_btn" @click="toPrivateClue">
  122. <text>更多</text>
  123. <u-icon name="arrow-right" size="16" color="#2563eb"></u-icon>
  124. </view>
  125. </view>
  126. <view class="clue_list">
  127. <view class="clue_item" v-for="(item, index) in clueList" :key="index">
  128. <view class="clue_star">
  129. <u-icon name="star-fill" size="20" color="#facc15"></u-icon>
  130. <text class="clue_name">{{ item.star }}</text>
  131. </view>
  132. <text class="clue_name">{{ item.name }}</text>
  133. <view class="clue_info">
  134. <text class="clue_title">{{ item.prodTitle }}</text>
  135. <text class="clue_desc">{{ item.desc }}</text>
  136. </view>
  137. </view>
  138. </view>
  139. </view>
  140. </view>
  141. </template>
  142. <script>
  143. export default {
  144. data() {
  145. return {
  146. // 卡片数据
  147. cardData: {
  148. todayConsume: '-',
  149. todayConsumeDy: '-',
  150. todayConsumeGdt: '-',
  151. performance: '-',
  152. countTypeA: '-',
  153. countTypeB: '-',
  154. countTypeC: '-',
  155. visitCount: '-',
  156. visitRate: '-',
  157. dealRate: '-',
  158. roi: '-',
  159. beatRate: '-',
  160. level: '-',
  161. score: '-'
  162. },
  163. chartData: {},
  164. opts: {
  165. color: ["#1890FF"],
  166. padding: [10, 10, 0, 0],
  167. dataLabel: false,
  168. dataPointShape: false,
  169. enableScroll: false,
  170. legend: {
  171. show: false
  172. },
  173. xAxis: {
  174. disableGrid: true
  175. },
  176. yAxis: {
  177. gridType: "dash",
  178. dashLength: 2,
  179. axisLabel: {
  180. show: false
  181. }
  182. },
  183. extra: {
  184. line: {
  185. type: "curve",
  186. width: 3,
  187. activeType: "hollow",
  188. linearType: "custom",
  189. onShadow: true,
  190. animation: "horizontal"
  191. }
  192. }
  193. },
  194. clueList: [],
  195. currentTab: 0,
  196. tabList: [{
  197. name: '当日',
  198. value: 'today'
  199. }, {
  200. name: '当周',
  201. value: 'week'
  202. }, {
  203. name: '当月',
  204. value: 'month'
  205. }],
  206. };
  207. },
  208. methods: {
  209. changeTab(val) {
  210. this.currentTab = val.index;
  211. this.getCardData();
  212. },
  213. formatMoney(val) {
  214. if (val === null || val === undefined || val === '' || val === '-') return '-';
  215. const num = Number(val);
  216. if (Number.isNaN(num)) return '-';
  217. return num.toFixed(2);
  218. },
  219. // 与 splitSummary 一致:上门率/成交率显示为 xx.xx%
  220. formatPercent(val) {
  221. if (val === null || val === undefined || val === '' || val === '-') return '-';
  222. const num = Number(val);
  223. if (Number.isNaN(num)) return '-';
  224. return num.toFixed(2) + '%';
  225. },
  226. getCardData() {
  227. const time = this.tabList[this.currentTab].value;
  228. uni.$u.api.getPersonCards({
  229. userId: this.$store.state.user.userInfo.userId,
  230. time: time
  231. }).then(res => {
  232. if (res.code === 200) {
  233. this.cardData = res.data;
  234. }
  235. });
  236. },
  237. getClueList() {
  238. uni.$u.api.getPersonLatestClue({ userId: this.$store.state.user.userInfo.userId }).then(res => {
  239. if (res.code === 200) {
  240. this.clueList = res.data;
  241. }
  242. });
  243. },
  244. async getChartData() {
  245. const res = await uni.$u.api.getPersonRanking({ userId: this.$store.state.user.userInfo.userId });
  246. if (res.code === 200) {
  247. let data = {
  248. categories: res.data.map(item => item.x),
  249. series: [
  250. {
  251. name: "近7天排名",
  252. data: res.data.map(item => item.y),
  253. setShadow: [
  254. 3,
  255. 8,
  256. 15,
  257. "#1890FF"
  258. ],
  259. }
  260. ]
  261. }
  262. this.chartData = JSON.parse(JSON.stringify(data))
  263. }
  264. },
  265. // 跳转私有线索页面
  266. toPrivateClue() {
  267. uni.switchTab({ url: '/pages/privateClue/index' });
  268. },
  269. },
  270. mounted() {
  271. this.getCardData();
  272. this.getClueList();
  273. this.$nextTick(() => {
  274. this.getChartData();
  275. })
  276. },
  277. };
  278. </script>
  279. <style lang="scss" scoped>
  280. @import './styles/index.scss';
  281. </style>