newHome.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915
  1. <template>
  2. <div class="homePage">
  3. <div >
  4. <a-row :gutter="16">
  5. <a-col :sm="24" :md="12" :xl="6" :xxl="6" class="topBox">
  6. <div class="showBox">
  7. <div class="title">
  8. Top7项目消耗
  9. <a-tooltip>
  10. <template slot="title">最近七天的top7项目消耗</template>
  11. <span class="icon">
  12. <a-icon type="exclamation-circle" />
  13. </span>
  14. </a-tooltip>
  15. </div>
  16. <div id="topChart" style="width:100%;height:100px" ref="topChart"></div>
  17. <div class="footerInfo">TOP1: <span class="num">¥{{this.topOption.series[0].data[0] | decimalsHandle}}</span> </div>
  18. </div>
  19. </a-col>
  20. <a-col :sm="24" :md="12" :xl="6" :xxl="6" class="topBox">
  21. <div class="showBox">
  22. <div class="title">
  23. 总消耗
  24. <p class="numshow">¥{{cost.weekCostSum | decimalsHandle}}</p>
  25. <a-tooltip>
  26. <template slot="title">最近七天的总消耗</template>
  27. <span>
  28. <a-icon type="exclamation-circle" />
  29. </span>
  30. </a-tooltip>
  31. </div>
  32. <div id="costChart" style="width:100%;height:70px" ref="costChart"></div>
  33. <div class="footerInfo">
  34. 周环比
  35. <span class="num">
  36. <span v-if="cost.weekCostSumLink">{{cost.weekCostSumLink|toPercentage}}</span>
  37. <span v-else>{{'-'}}</span>
  38. <span
  39. class="redIcon"
  40. v-if="cost.weekCostSumLink>0"
  41. ></span>
  42. <span class="greenIcon" v-else></span>
  43. </span>
  44. </div>
  45. </div>
  46. </a-col>
  47. <a-col :sm="24" :md="12" :xl="6" :xxl="6" class="topBox">
  48. <div class="showBox">
  49. <div class="title">
  50. 点击数
  51. <p class="numshow">{{click.weekClickSum | formatCurrency}}</p>
  52. <a-tooltip>
  53. <template slot="title">最近七天的点击数</template>
  54. <span>
  55. <a-icon type="exclamation-circle" />
  56. </span>
  57. </a-tooltip>
  58. </div>
  59. <div id="clickChart" style="width:100%;height:70px" ref="clickChart"></div>
  60. <div class="footerInfo">
  61. 周环比
  62. <span class="num">
  63. <span v-if="click.weekClickSumLink">{{click.weekClickSumLink|toPercentage}}</span>
  64. <span v-else>{{'-'}}</span>
  65. <span
  66. class="redIcon"
  67. v-if="click.weekClickSumLink>0"
  68. ></span>
  69. <span class="greenIcon" v-else></span>
  70. </span>
  71. </div>
  72. </div>
  73. </a-col>
  74. <a-col :sm="24" :md="12" :xl="6" :xxl="6" class="topBox">
  75. <div class="showBox">
  76. <div class="title">
  77. 展示数
  78. <p class="numshow">{{showNum.weekShowNumSum | formatCurrency}}</p>
  79. <a-tooltip>
  80. <template slot="title">最近七天的展示数</template>
  81. <span>
  82. <a-icon type="exclamation-circle" />
  83. </span>
  84. </a-tooltip>
  85. </div>
  86. <div id="showChart" style="width:100%;height:70px" ref="showChart"></div>
  87. <div class="footerInfo">
  88. 周环比
  89. <span class="num">
  90. <span v-if="showNum.weekShowNumSumLink">{{showNum.weekShowNumSumLink | toPercentage}}</span>
  91. <span v-else>{{'-'}}</span>
  92. <span
  93. class="redIcon"
  94. v-if="showNum.weekShowNumSumLink>0"
  95. ></span>
  96. <span class="greenIcon" v-else></span>
  97. </span>
  98. </div>
  99. </div>
  100. </a-col>
  101. </a-row>
  102. </div>
  103. <!-- 折线图模块 -->
  104. <div class="section">
  105. <a-tabs default-active-key="cost" @change="callback" >
  106. <a-tab-pane key="cost" tab="总消耗">
  107. </a-tab-pane>
  108. <a-tab-pane key="click" tab="点击数" >
  109. </a-tab-pane>
  110. <a-tab-pane key="showNum" tab="展示数">
  111. </a-tab-pane>
  112. </a-tabs>
  113. <div id="sectionChart" style='width:100%;height:300px' ref="sectionChart"></div>
  114. <a-button class="duibi" @click="comparehandle" type='default' >对比</a-button>
  115. <div class="time" @click="opendate" >
  116. <DatePicker :openOptions='openOptions' :left='0' />
  117. </div>
  118. </div>
  119. <!-- table数据 -->
  120. <div class="tableshow">
  121. <p><span>{{dateValue[0].format('YYYY-MM-DD')+'~'+dateValue[1].format('YYYY-MM-DD')}}</span></p>
  122. <a-table
  123. size="middle"
  124. :columns="columns"
  125. :dataSource="tableData"
  126. :pagination=false
  127. bordered
  128. id="outTable"
  129. :loading="loading"
  130. style="word-break: break-all;"
  131. >
  132. <span slot="costProportion" slot-scope="costProportion">{{ costProportion | toPercentage }}</span>
  133. <span slot="cost" slot-scope="cost">{{ cost | decimalsHandle }}</span>
  134. <span slot="click" slot-scope="click">{{ click | formatCurrency }}</span>
  135. <span slot="showNum" slot-scope="showNum">{{ showNum | formatCurrency }}</span>
  136. <!-- <span slot="statDatetime" slot-scope>{{ dateValue[0].format('YYYY-MM-DD')+'~'+dateValue[1].format('YYYY-MM-DD')}}</span> -->
  137. </a-table>
  138. </div>
  139. <!-- <p class="footertip">我们是有底线的~</p> -->
  140. <CompareData :compareVisiable.sync='compareVisiable' @close_modal='close_modal' ref="compareData"/>
  141. </div>
  142. </template>
  143. <script>
  144. import moment from 'moment'
  145. import DatePicker from '@/components/DatePicker.vue'
  146. import CompareData from './CompareData.vue'
  147. import { getAction, postAction, downFile, downFilePost } from '@/api/manage'
  148. // import vueEchart from './components/vueEchart'
  149. // 引入基本模板
  150. var echarts = require('echarts')
  151. // 引入柱状图组件
  152. require('echarts/lib/chart/bar')
  153. require('echarts/lib/chart/pie')
  154. require('echarts/lib/chart/line')
  155. // 引入提示框和title组件
  156. require('echarts/lib/component/tooltip')
  157. require('echarts/lib/component/title')
  158. require('echarts/lib/component/graphic')
  159. require('echarts/lib/component/toolbox')
  160. require('echarts/lib/component/legend')
  161. let option = {
  162. color: ['#1890ff'],
  163. tooltip: {
  164. trigger: 'axis',
  165. axisPointer: {
  166. // 坐标轴指示器,坐标轴触发有效
  167. type: 'line' // 默认为直线,可选为:'line' | 'shadow'
  168. }
  169. },
  170. grid: {
  171. left: '0%',
  172. right: '0%',
  173. bottom: '0%',
  174. top: '12%',
  175. containLabel: false,
  176. },
  177. xAxis: [
  178. {
  179. type: 'category',
  180. data: [],
  181. show: true,
  182. axisTick: {
  183. alignWithLabel: true
  184. }
  185. }
  186. ],
  187. yAxis: [
  188. {
  189. type: 'value',
  190. show: false
  191. }
  192. ],
  193. series: [
  194. {
  195. name: '',
  196. type: 'bar',
  197. barWidth: '40%',
  198. smooth: true,
  199. areaStyle:{},
  200. itemStyle: {
  201. color: new echarts.graphic.LinearGradient(
  202. 0, 0, 0, 1,
  203. [
  204. {offset: 0, color: '#1890ff'},
  205. {offset: 1, color: '#FFF'}
  206. ]
  207. )
  208. },
  209. data: []
  210. }
  211. ]
  212. }
  213. let lineStyle= {
  214. color:{
  215. type: 'linear',
  216. x: 0,
  217. y: 0,
  218. x2: 0,
  219. y2: 1,
  220. colorStops: [{
  221. offset: 0, color: '#1890ff' // 0% 处的颜色
  222. }, {
  223. offset: 1, color: '#fff' // 100% 处的颜色
  224. }],
  225. global: false // 缺省为 false
  226. },
  227. // color: '#1890ff'
  228. }
  229. let sectionOption={
  230. tooltip: {
  231. trigger: 'axis',
  232. axisPointer: {
  233. // 坐标轴指示器,坐标轴触发有效
  234. type: 'line' // 默认为直线,可选为:'line' | 'shadow'
  235. }
  236. },
  237. legend: {
  238. data: ['总消耗']
  239. },
  240. grid: {
  241. left: '2%',
  242. right: '0%',
  243. bottom: '0%',
  244. top: '12%',
  245. containLabel: true
  246. },
  247. xAxis: [
  248. {
  249. type: 'category',
  250. data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
  251. axisTick: {
  252. alignWithLabel: true
  253. }
  254. }
  255. ],
  256. yAxis: [
  257. {
  258. type: 'value',
  259. show: true
  260. }
  261. ],
  262. series: [
  263. {
  264. name: '总消耗',
  265. type: 'line',
  266. smooth: true,
  267. data: [820, 932, 901, 934, 1290, 1330, 1320],
  268. color:'#32CD32'
  269. },
  270. {
  271. name: '',
  272. type: 'line',
  273. smooth: true,
  274. data: [],
  275. color:'#8A2BE2'
  276. },
  277. ]
  278. }
  279. let init={
  280. today:{
  281. x:['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00','07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00','19:00', '20:00', '21:00', '22:00', '23:00'],
  282. y:[],
  283. name:"今天"
  284. },
  285. yesterday:{
  286. x:['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00','07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00','19:00', '20:00', '21:00', '22:00', '23:00'],
  287. y:[],
  288. name:"昨天"
  289. }
  290. }
  291. let columns = [
  292. {
  293. title: '日期/时间',
  294. dataIndex: 'statDate',
  295. scopedSlots: { customRender: 'statDate' },
  296. align: 'center',
  297. key:'statDate'
  298. },
  299. {
  300. title: '消耗(元)',
  301. dataIndex: 'cost',
  302. scopedSlots: { customRender: 'cost' },
  303. align: 'center',
  304. key:'cost'
  305. },
  306. {
  307. title: '消耗环比',
  308. dataIndex: 'costProportion',
  309. scopedSlots: { customRender: 'costProportion' },
  310. align: 'center',
  311. key:"costProportion"
  312. },
  313. {
  314. title: '点击数',
  315. dataIndex: 'click',
  316. align: 'center',
  317. scopedSlots: { customRender: 'click' },
  318. key:'click'
  319. },
  320. {
  321. title: '点击率',
  322. dataIndex: 'clickRate',
  323. align: 'center',
  324. scopedSlots: { customRender: 'clickRate' },
  325. key:'clickRate'
  326. },
  327. {
  328. title: '展示数',
  329. dataIndex: 'showNum',
  330. align: 'center',
  331. scopedSlots: { customRender: 'showNum' },
  332. key:"showNum"
  333. },
  334. {
  335. title: '平均千次展现费用(元)',
  336. dataIndex: 'cpm',
  337. align: 'center',
  338. scopedSlots: { customRender: 'cpm' },
  339. key:'cpm'
  340. },
  341. {
  342. title: '平均点击单价(元)',
  343. dataIndex: 'cp',
  344. align: 'center',
  345. scopedSlots: { customRender: 'cp' },
  346. key:"cp"
  347. },
  348. ]
  349. export default {
  350. components:{
  351. DatePicker,
  352. CompareData
  353. },
  354. data() {
  355. return {
  356. //echart的配置项option
  357. topOption: JSON.parse(JSON.stringify(option)),
  358. costOption: JSON.parse(JSON.stringify(option)),
  359. clickOption: JSON.parse(JSON.stringify(option)),
  360. showOption: JSON.parse(JSON.stringify(option)),
  361. sectionOption:JSON.parse(JSON.stringify(sectionOption)),
  362. //页面四个块的数据
  363. cost: {},
  364. click: {},
  365. showNum: {},
  366. //tab的选中key
  367. tabKey:'',
  368. tabCost:{},
  369. tabClick:{},
  370. tabShowNum:{},
  371. //对比的模态框
  372. compareVisiable:false,
  373. //table
  374. loading: false,
  375. columns,
  376. tableData:[],
  377. //子元素的数据存储
  378. type:1,
  379. dateValue:[moment(),moment()],
  380. //日期矿打开
  381. openOptions:false,
  382. }
  383. },
  384. watch:{
  385. type(n,o){
  386. // console.log(n,o)
  387. // console.log(this.type)
  388. if(this.type<9){
  389. this.sectionHttp({type:this.type})
  390. }else if(this.type==9){
  391. this.sectionHttp({
  392. type:this.type,
  393. startDate:this.dateValue[0].format('YYYY-MM-DD'),
  394. endDate:this.dateValue[1].format('YYYY-MM-DD')
  395. })
  396. }
  397. },
  398. },
  399. methods: {
  400. //获取echart的值
  401. getEchartData(idName, optionName) {
  402. const chart = this.$refs[idName]
  403. // console.log(chart)
  404. if (chart) {
  405. const myChart = echarts.init(document.getElementById(idName))
  406. myChart.setOption(optionName)
  407. window.addEventListener('resize', function() {
  408. myChart.resize()
  409. })
  410. }
  411. },
  412. //网络请求方法
  413. echartsHttp() {
  414. return new Promise((resolve, reject) => {
  415. postAction('/ctop/byteDance/homePage/report/week', {}).then(res => {
  416. // console.log(res)
  417. if (res.success) {
  418. this.loading = false
  419. this.cost = res.result.costWeekLink
  420. this.click = res.result.clickWeekLink
  421. this.showNum = res.result.showNumWeekLink
  422. res.result.top.top7.forEach((element, index) => {
  423. this.topOption.xAxis[0].data.push(element.authName)
  424. this.topOption.series[0].data.push(element.cost)
  425. })
  426. res.result.costWeek.forEach((ele)=>{
  427. this.costOption.xAxis[0].data.push(ele.statDate)
  428. this.costOption.series[0].data.push(ele.cost)
  429. })
  430. res.result.clickWeek.forEach((ele)=>{
  431. this.clickOption.xAxis[0].data.push(ele.statDate)
  432. this.clickOption.series[0].data.push(ele.click)
  433. })
  434. res.result.showNumWeek.forEach((ele)=>{
  435. this.showOption.xAxis[0].data.push(ele.statDate)
  436. this.showOption.series[0].data.push(ele.showNum)
  437. })
  438. this.getEchartData('topChart', this.topOption)
  439. this.getEchartData('costChart', this.costOption)
  440. this.getEchartData('clickChart', this.clickOption)
  441. this.getEchartData('showChart', this.showOption)
  442. }
  443. })
  444. })
  445. },
  446. //处理echart
  447. sectionHttp(params) {
  448. this.loading = true
  449. this.sectionOption=JSON.parse(JSON.stringify(sectionOption));
  450. return new Promise((resolve, reject) => {
  451. postAction('/ctop/byteDance/homePage/report/chart', params).then(res => {
  452. // console.log(res)
  453. if (res.success) {
  454. this.loading = false
  455. //处理今天
  456. if(res.result){
  457. if(res.result.chart[0].afterData && res.result.chart[0].afterData.statDate==moment().format('YYYY-MM-DD')){
  458. this.tabCost=JSON.parse(JSON.stringify(init))
  459. this.tabClick=JSON.parse(JSON.stringify(init))
  460. this.tabShowNum=JSON.parse(JSON.stringify(init))
  461. res.result.chart.forEach((item,index)=>{
  462. this.tabClick.yesterday.y.push(item.click)
  463. this.tabCost.yesterday.y.push(item.cost)
  464. this.tabShowNum.yesterday.y.push(item.showNum)
  465. if(item.afterData){
  466. this.tabClick.today.y.push(item.afterData.click)
  467. this.tabCost.today.y.push(item.afterData.cost)
  468. this.tabShowNum.today.y.push(item.afterData.showNum)
  469. }else{
  470. this.tabClick.today.y.push(0)
  471. this.tabCost.today.y.push(0)
  472. this.tabShowNum.today.y.push(0)
  473. }
  474. });
  475. this.sectionOption.legend.data=['今天','昨天'];
  476. this.sectionOption.xAxis[0].data=this.tabCost.today.x;
  477. this.sectionOption.series[0].data=this.tabCost.today.y;
  478. this.sectionOption.series[0].name=this.tabCost.today.name;
  479. this.sectionOption.series[1].data=this.tabCost.yesterday.y;
  480. this.sectionOption.series[1].name=this.tabCost.yesterday.name;
  481. }else if(res.result.chart[0].afterData&& res.result.chart[0].afterData.statDate==moment().subtract(1,'days').format('YYYY-MM-DD')){
  482. //处理昨天
  483. this.tabCost=[]
  484. this.tabClick=[]
  485. this.tabShowNum=[]
  486. res.result.chart.forEach((item,index)=>{
  487. if(item.afterData){
  488. this.tabClick.push(item.afterData.click)
  489. this.tabCost.push(item.afterData.cost)
  490. this.tabShowNum.push(item.afterData.showNum)
  491. }else{
  492. this.tabClick.push(0)
  493. this.tabCost.push(0)
  494. this.tabShowNum.push(0)
  495. }
  496. });
  497. if(this.tabKey=='click'){
  498. this.sectionOption.legend.data=['点击数'];
  499. this.sectionOption.xAxis[0].data=init.today.x;
  500. this.sectionOption.series[0].data=this.tabClick;
  501. this.sectionOption.series[0].name='点击数';
  502. }else if(this.tabKey=='showNum'){
  503. this.sectionOption.legend.data=['展示数'];
  504. this.sectionOption.xAxis[0].data=init.today.x;
  505. this.sectionOption.series[0].data=this.tabShowNum;
  506. this.sectionOption.series[0].name='展示数';
  507. }else{
  508. this.sectionOption.xAxis[0].data=init.today.x;
  509. this.sectionOption.series[0].data=this.tabCost;
  510. }
  511. }else{
  512. this.tabCost={x:[],y:[]}
  513. this.tabClick={x:[],y:[]}
  514. this.tabShowNum={x:[],y:[]}
  515. res.result.chart.forEach((item,index)=>{
  516. this.tabClick.y.push(item.click)
  517. this.tabCost.y.push(item.cost)
  518. this.tabShowNum.y.push(item.showNum)
  519. this.tabClick.x.push(item.statDate)
  520. this.tabCost.x.push(item.statDate)
  521. this.tabShowNum.x.push(item.statDate)
  522. });
  523. if(this.tabKey=='click'){
  524. this.sectionOption.legend.data=['点击数'];
  525. this.sectionOption.xAxis[0].data=this.tabClick.x;
  526. this.sectionOption.series[0].data=this.tabClick.y;
  527. this.sectionOption.series[0].name='点击数';
  528. }else if(this.tabKey=='showNum'){
  529. this.sectionOption.legend.data=['展示数'];
  530. this.sectionOption.xAxis[0].data=this.tabShowNum.x;
  531. this.sectionOption.series[0].data=this.tabShowNum.y;
  532. this.sectionOption.series[0].name='展示数';
  533. }else{
  534. this.sectionOption.xAxis[0].data=this.tabCost.x;
  535. this.sectionOption.series[0].data=this.tabCost.y;
  536. }
  537. }
  538. this.getEchartData('sectionChart', this.sectionOption);
  539. //处理表格数据
  540. let total={
  541. statDate:'总计',
  542. cost:0,
  543. click:0,
  544. clickRate:0,
  545. costProportion:'-',
  546. cp:0,
  547. cpm:0,
  548. showNum:0
  549. }
  550. res.result.list.forEach((ele,index)=>{
  551. if(!ele.costProportion){
  552. ele.costProportion='-'
  553. }
  554. if(ele.statHour||ele.statHour==0){
  555. ele.statHour=ele.statHour > 9 ? `${ele.statHour}:00` : ` 0${ele.statHour}:00`
  556. ele.statDate=ele.statDate+' '+ele.statHour
  557. }
  558. ele.key=index+1
  559. total.click+=ele.click
  560. total.cost+=ele.cost
  561. total.showNum+=ele.showNum
  562. })
  563. total.cost=(total.cost).toFixed(2)
  564. total.clickRate=(total.click/total.showNum*100).toFixed(2)+'%'
  565. total.cp=(total.cost/total.click).toFixed(2)
  566. total.cpm=(total.cost/total.showNum*1000).toFixed(2)
  567. this.tableData=[total,...res.result.list]
  568. }
  569. }
  570. })
  571. })
  572. },
  573. //tab切换页的事件
  574. callback(key) {
  575. // console.log(key);
  576. this.tabKey=key;
  577. this.sectionOption=JSON.parse(JSON.stringify(sectionOption))
  578. if(key=='cost'){
  579. if(this.type==1){
  580. this.sectionOption.legend.data=['今天','昨天'];
  581. this.sectionOption.xAxis[0].data=this.tabCost.today.x;
  582. this.sectionOption.series[0].data=this.tabCost.today.y;
  583. this.sectionOption.series[0].name=this.tabCost.today.name;
  584. this.sectionOption.series[1].data=this.tabCost.yesterday.y;
  585. this.sectionOption.series[1].name=this.tabCost.yesterday.name;
  586. }else if(this.type==2){
  587. this.sectionOption.xAxis[0].data=init.today.x;
  588. this.sectionOption.series[0].data=this.tabCost;
  589. }else{
  590. this.sectionOption.xAxis[0].data=this.tabCost.x;
  591. this.sectionOption.series[0].data=this.tabCost.y;
  592. }
  593. }else if(key=='click'){
  594. if(this.type==1){
  595. this.sectionOption.legend.data=['今天','昨天'];
  596. this.sectionOption.xAxis[0].data=this.tabClick.today.x;
  597. this.sectionOption.series[0].data=this.tabClick.today.y;
  598. this.sectionOption.series[0].name=this.tabClick.today.name;
  599. this.sectionOption.series[1].data=this.tabClick.yesterday.y;
  600. this.sectionOption.series[1].name=this.tabClick.yesterday.name;
  601. }else if(this.type==2){
  602. this.sectionOption.legend.data=['点击数'];
  603. this.sectionOption.xAxis[0].data=init.today.x;
  604. this.sectionOption.series[0].data=this.tabClick;
  605. this.sectionOption.series[0].name='点击数';
  606. }else{
  607. this.sectionOption.legend.data=['点击数'];
  608. this.sectionOption.xAxis[0].data=this.tabClick.x;
  609. this.sectionOption.series[0].data=this.tabClick.y;
  610. this.sectionOption.series[0].name='点击数';
  611. }
  612. }else{
  613. if(this.type==1){
  614. this.sectionOption.legend.data=['今天','昨天'];
  615. this.sectionOption.xAxis[0].data=this.tabShowNum.today.x;
  616. this.sectionOption.series[0].data=this.tabShowNum.today.y;
  617. this.sectionOption.series[0].name=this.tabShowNum.today.name;
  618. this.sectionOption.series[1].data=this.tabShowNum.yesterday.y;
  619. this.sectionOption.series[1].name=this.tabShowNum.yesterday.name;
  620. }else if(this.type==2){
  621. this.sectionOption.legend.data=['展示数'];
  622. this.sectionOption.xAxis[0].data=init.today.x;
  623. this.sectionOption.series[0].data=this.tabShowNum;
  624. this.sectionOption.series[0].name='展示数';
  625. }else{
  626. this.sectionOption.legend.data=['展示数'];
  627. this.sectionOption.xAxis[0].data=this.tabShowNum.x;
  628. this.sectionOption.series[0].data=this.tabShowNum.y;
  629. this.sectionOption.series[0].name='展示数';
  630. }
  631. }
  632. this.getEchartData('sectionChart', this.sectionOption)
  633. },
  634. //打开日期框
  635. opendate(){
  636. this.openOptions=!this.openOptions;
  637. // console.log(this.openOptions)
  638. },
  639. opendateClose(){
  640. this.openOptions=false;
  641. // console.log(this.openOptions)
  642. },
  643. //对比按钮的事件
  644. comparehandle(){
  645. this.compareVisiable=true;
  646. this.$refs.compareData.sectionHttp({
  647. type: 10,
  648. sign: 'month',
  649. smallDate: moment()
  650. .subtract(1, 'months')
  651. .format('YYYY-MM'),
  652. bigDate: moment().format('YYYY-MM')
  653. })
  654. },
  655. close_modal(n){
  656. // console.log(n)
  657. this.compareVisiable=n;
  658. },
  659. //对比模块的tab事件
  660. compareTab(key){
  661. console.log(key)
  662. }
  663. },
  664. mounted() {
  665. //处理四个图标的样式
  666. this.costOption.series[0].type = 'line';
  667. this.costOption.series[0].itemStyle = {};
  668. this.costOption.series[0].areaStyle = lineStyle;
  669. this.costOption.xAxis[0].boundaryGap = false
  670. this.showOption.series[0].type = 'line'
  671. this.showOption.series[0].itemStyle = {};
  672. this.showOption.series[0].areaStyle = lineStyle;
  673. this.showOption.xAxis[0].boundaryGap = false
  674. this.echartsHttp();
  675. this.sectionHttp({type:this.type});
  676. },
  677. filters: {
  678. toPercentage(val) {
  679. if(typeof val != 'string'){
  680. return (val * 100).toFixed(2) + '%'
  681. }else{
  682. return val
  683. }
  684. },
  685. //保留两位小数并且变成货币格式
  686. decimalsHandle(val){
  687. // console.log(val)
  688. if(val){
  689. val=parseFloat(val).toFixed(2);
  690. let numberStr = val.toString()
  691. let str = numberStr.split('.')
  692. let str0=str[0].split('').reverse();
  693. for (let i = 0; i < str0.length; i++) {
  694. if ((i + 1) % 4 === 0) {
  695. str0.splice(i, 0, ',')
  696. }
  697. }
  698. str0.reverse()
  699. let handleResult = ''
  700. for (let j = 0; j < str0.length; j++) {
  701. handleResult += str0[j]
  702. }
  703. return handleResult+'.'+str[1]
  704. }
  705. },
  706. //变成货币格式
  707. formatCurrency(val){
  708. if(val){
  709. let numberStr = val.toString()
  710. let str = numberStr.split('').reverse()
  711. for (let i = 0; i < str.length; i++) {
  712. if ((i + 1) % 4 === 0) {
  713. str.splice(i, 0, ',')
  714. }
  715. }
  716. str.reverse()
  717. let handleResult = ''
  718. for (let j = 0; j < str.length; j++) {
  719. handleResult += str[j]
  720. }
  721. return handleResult
  722. }
  723. }
  724. }
  725. }
  726. </script>
  727. <style lang="scss" scoped>
  728. .homePage {
  729. .topBox{
  730. margin-bottom: 20px;
  731. }
  732. .showBox {
  733. width: 98%;
  734. box-sizing: border-box;
  735. margin-right: 20px;
  736. padding: 25px 25px 0;
  737. background-color: #fff;
  738. .title {
  739. color: #999;
  740. font-size: 16px;
  741. position: relative;
  742. span {
  743. font-size: 1rem;
  744. // color: #1890ff;
  745. position: absolute;
  746. top: 0;
  747. right: 0;
  748. cursor: pointer;
  749. }
  750. }
  751. .num{
  752. color: #000;
  753. font-size: 16px;;
  754. }
  755. .numshow {
  756. color:#333 ;
  757. font-weight: 500;
  758. font-size: 24px;
  759. padding: 5px 0;
  760. height: 30px;
  761. margin-bottom: 0;
  762. }
  763. }
  764. .footerInfo {
  765. margin-top: 10px;
  766. border-top: 1px solid #eee;
  767. padding: 10px 0;
  768. color: #666;
  769. font-size: 16px;
  770. position: relative;
  771. white-space: nowrap;
  772. overflow: hidden;
  773. text-overflow: ellipsis;
  774. .num {
  775. display: inline-block;
  776. margin-left: 10px;
  777. padding-right: 15px;
  778. position: relative;
  779. font-weight: 500;
  780. }
  781. .redIcon {
  782. width: 0;
  783. height: 0;
  784. border-left: 4px solid transparent;
  785. border-right: 4px solid transparent;
  786. border-bottom: 8px solid red;
  787. position: absolute;
  788. top: 40%;
  789. right: 0;
  790. }
  791. .greenIcon {
  792. width: 0;
  793. height: 0;
  794. border-left: 4px solid transparent;
  795. border-right: 4px solid transparent;
  796. border-top: 8px solid green;
  797. position: absolute;
  798. top: 40%;
  799. right: 0;
  800. }
  801. }
  802. .section{
  803. width: 100%;
  804. background-color: #fff;
  805. padding: 10px 15px 20px;
  806. position: relative;
  807. margin-bottom: 20px;;
  808. .duibi{
  809. position: absolute;
  810. height: 30px;
  811. line-height: 30px;
  812. padding: 0 15px;
  813. top: 15px;
  814. right: 300px;
  815. // border: 1px solid #666;
  816. cursor: pointer;
  817. }
  818. .time{
  819. position: absolute;
  820. width:280px;
  821. top: 15px;
  822. right: 0px;
  823. cursor: pointer;
  824. }
  825. }
  826. .tableshow{
  827. width: 100%;
  828. padding: 20px 15px;
  829. background-color: #fff;
  830. p{
  831. width: 100%;
  832. border-bottom: 1px solid #ccc;
  833. padding-bottom: 20px;
  834. span{
  835. display: inline-block;
  836. border: 1px solid #ccc;
  837. padding: 5px 15px;
  838. border-radius: 5px;
  839. }
  840. }
  841. }
  842. .footertip{
  843. background: #fff;
  844. padding: 0 15px 20px;
  845. font-size: 16px;
  846. text-align: center;
  847. }
  848. }
  849. </style>