data-tatistics.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. $urlManager = Yii::$app->urlManager;
  4. ComponentHelper::loadComponentView('com-search', __DIR__);
  5. ?>
  6. <style>
  7. .el-tabs__nav-wrap::after {
  8. height: 1px;
  9. }
  10. .table-body {
  11. background-color: #fff;
  12. position: relative;
  13. padding-bottom: 50px;
  14. margin-bottom: 10px;
  15. border: 1px solid #EBEEF5;
  16. }
  17. .table-body .el-tabs {
  18. margin-left: 10px;
  19. }
  20. .table-body .el-tabs__nav-scroll {
  21. width: 120px;
  22. margin-left: 30px;
  23. }
  24. .table-body .el-tabs__item {
  25. height: 32px;
  26. line-height: 32px;
  27. }
  28. .table-body .clean {
  29. color: #92959B;
  30. margin-left: 20px;
  31. cursor: pointer;
  32. font-size: 15px;
  33. }
  34. .num-info {
  35. display: flex;
  36. width: 100%;
  37. height: 60px;
  38. font-size: 28px;
  39. color: #303133;
  40. }
  41. .num-info .num-info-item {
  42. text-align: center;
  43. width: 25%;
  44. border-left: 1px dashed #EFF1F7;
  45. }
  46. .num-info .num-info-item:first-of-type {
  47. border-left: 0;
  48. }
  49. .info-item-name {
  50. font-size: 16px;
  51. color: #92959B;
  52. }
  53. .tab-pay {
  54. position: absolute;
  55. bottom: 0;
  56. right: 50px;
  57. }
  58. .tab-pay .el-tabs__item {
  59. height: 56px;
  60. line-height: 56px;
  61. }
  62. .pay-info {
  63. padding: 40px 0;
  64. display: flex;
  65. justify-content: space-between;
  66. }
  67. .pay-info .pay-info-item {
  68. padding-top: 45px;
  69. width: 22%;
  70. margin: 0 1.5%;
  71. text-align: center;
  72. font-size: 26px;
  73. border: 1px solid #EBEEF5;
  74. border-radius: 10px;
  75. height: 150px;
  76. position: relative;
  77. cursor: pointer;
  78. }
  79. .pay-info .pay-info-item.active {
  80. border: 1px solid #3399FF;
  81. }
  82. .pay-info .pay-info-item img {
  83. display: none;
  84. }
  85. .pay-info .pay-info-item.active img {
  86. position: absolute;
  87. top: 0;
  88. left: 0;
  89. display: block;
  90. }
  91. .echarts-title {
  92. color: #92959B;
  93. display: flex;
  94. font-size: 16px;
  95. margin-left: 45px;
  96. }
  97. .echarts-title-item {
  98. margin-right: 45px;
  99. display: flex;
  100. align-items: center;
  101. }
  102. .echarts-title-item .echarts-title-icon {
  103. height: 16px;
  104. width: 16px;
  105. margin-right: 10px;
  106. background-color: #3399ff;
  107. }
  108. .table-area {
  109. margin-top: 20px;
  110. display: flex;
  111. justify-content: space-between;
  112. }
  113. .table-area .el-card {
  114. width: 49.5%;
  115. color: #303133;
  116. }
  117. .el-tabs__header {
  118. margin-bottom: 0 !important;
  119. }
  120. .el-card__header {
  121. position: relative;
  122. }
  123. .sort-active {
  124. color: #3399ff;
  125. }
  126. .select-item {
  127. border: 1px solid #3399ff;
  128. margin-top: -1px !important;
  129. }
  130. .el-popper .popper__arrow, .el-popper .popper__arrow::after {
  131. display: none;
  132. }
  133. .el-select-dropdown__item.hover, .el-select-dropdown__item:hover {
  134. background-color: #3399ff;
  135. color: #fff;
  136. }
  137. .table-area .el-card__header {
  138. padding: 14px 20px;
  139. }
  140. .text-omit {
  141. width: 380px;
  142. overflow: hidden;
  143. text-overflow: ellipsis;
  144. white-space: nowrap;
  145. }
  146. </style>
  147. <div id="app" v-cloak>
  148. <el-card v-loading="loading" shadow="never" style="border:0;min-width: 1200px;"
  149. body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  150. <div slot="header">
  151. <span>数据概况</span>
  152. </div>
  153. <div class="table-body">
  154. <com-search
  155. @to-search="toSearch"
  156. @search="searchList"
  157. :new-search="search"
  158. :is-show-keyword="false"
  159. :day-data="{'today':today, 'weekDay': weekDay, 'monthDay': monthDay}">
  160. <!-- <template slot="select">
  161. <div>
  162. <el-select size="small" popper-class="select-item" @change="tabMch" style="width: 160px"
  163. v-model="search.mch" placeholder="请选择">
  164. <el-option label="全部" value="0"></el-option>
  165. <el-option v-for="item in mch_list" :key="item.id" :label="item.name"
  166. :value="item.id"></el-option>
  167. </el-select>
  168. </div>
  169. </template> -->
  170. </com-search>
  171. <!-- 数据总览 -->
  172. <div class="num-info">
  173. <div class="num-info-item">
  174. <div>{{all_data.user_count}}</div>
  175. <div class="info-item-name">
  176. <span>用户数</span>
  177. <el-tooltip class="item" effect="dark" content="统计全平台用户数" placement="bottom">
  178. <i class="el-icon-question"></i>
  179. </el-tooltip>
  180. </div>
  181. </div>
  182. <div class="num-info-item">
  183. <div>{{all_data.goods_num}}</div>
  184. <div class="info-item-name">商品数
  185. <el-tooltip class="item" effect="dark" content="统计某时间段内添加的商品总数" placement="bottom">
  186. <i class="el-icon-question"></i>
  187. </el-tooltip>
  188. </div>
  189. </div>
  190. <div class="num-info-item">
  191. <div>{{all_data.order_num}}</div>
  192. <div class="info-item-name">订单数</div>
  193. </div>
  194. <!-- <div class="num-info-item">
  195. <div>{{all_data.wait_send_num}}</div>
  196. <div class="info-item-name">待发货订单数</div>
  197. </div> -->
  198. <div class="num-info-item">
  199. <div>{{all_data.pro_order}}</div>
  200. <div class="info-item-name">发起售后订单数</div>
  201. </div>
  202. </div>
  203. </div>
  204. <!-- 销售情况 -->
  205. <el-card shadow="never">
  206. <div slot="header">
  207. <span>销售情况</span>
  208. <div class="tab-pay">
  209. <el-tabs v-model="activeDay" @tab-click="tab_pay">
  210. <el-tab-pane label="昨日" name="one"></el-tab-pane>
  211. <el-tab-pane label="7日" name="seven"></el-tab-pane>
  212. </el-tabs>
  213. </div>
  214. </div>
  215. <!-- 选择框 -->
  216. <div class="pay-info">
  217. <div class="pay-info-item" :class="{active:order}" @click="chooseInfo('order')">
  218. <img src="statics/img/mall/statistic/active.png" alt="">
  219. <div>{{table_data.order_num}}</div>
  220. <div class="info-item-name">支付订单数</div>
  221. </div>
  222. <div class="pay-info-item" :class="{active:price}" @click="chooseInfo('price')">
  223. <img src="statics/img/mall/statistic/active.png" alt="">
  224. <div>{{table_data.total_pay_price.toFixed(2)}}</div>
  225. <div class="info-item-name">支付金额</div>
  226. </div>
  227. <div class="pay-info-item" :class="{active:people}" @click="chooseInfo('people')">
  228. <img src="statics/img/mall/statistic/active.png" alt="">
  229. <div>{{table_data.user_count}}</div>
  230. <div class="info-item-name">支付人数</div>
  231. </div>
  232. <div class="pay-info-item" :class="{active:num}" @click="chooseInfo('num')">
  233. <img src="statics/img/mall/statistic/active.png" alt="">
  234. <div>{{table_data.goods_num}}</div>
  235. <div class="info-item-name">支付件数</div>
  236. </div>
  237. </div>
  238. <div class="echarts-title">
  239. <div class="echarts-title-item" v-if="order">
  240. <div class="echarts-title-icon"></div>
  241. <div>支付订单数</div>
  242. </div>
  243. <div class="echarts-title-item" v-if="price">
  244. <div style="background-color: #FFA360;" class="echarts-title-icon"></div>
  245. <div>支付金额</div>
  246. </div>
  247. <div class="echarts-title-item" v-if="people">
  248. <div style="background-color: #4BC282;" class="echarts-title-icon"></div>
  249. <div>支付人数</div>
  250. </div>
  251. <div class="echarts-title-item" v-if="num">
  252. <div style="background-color: #FF8585;" class="echarts-title-icon"></div>
  253. <div>支付件数</div>
  254. </div>
  255. </div>
  256. <div id="echarts" style="height:18rem;"></div>
  257. </el-card>
  258. <div class="table-area">
  259. <el-card shadow="never">
  260. <div slot="header">
  261. <span style="float: left;height: 32px;line-height: 32px">商品购买力TOP排行</span>
  262. <div flex="dir:right" style="">
  263. <button @click="exportData('goods_rank')" class="el-button el-button--primary el-button--small">导出TOP100
  264. </button>
  265. </div>
  266. </div>
  267. <el-table v-loading="goods_loading" :row-style="{height:'63px'}" @sort-change="changeGoods"
  268. :header-cell-style="{background:'#F3F5F6','color':'#303133'}" :data="goods_top_list">
  269. <el-table-column align="center" label="排名">
  270. <template slot-scope="scope">
  271. <img style="margin-top: 3px" v-if="scope.$index == 0"
  272. src="resources/img/mall/statistic/first.png" alt="">
  273. <img style="margin-top: 3px" v-else-if="scope.$index == 1"
  274. src="resources/img/mall/statistic/sec.png" alt="">
  275. <img style="margin-top: 3px" v-else-if="scope.$index == 2"
  276. src="resources/img/mall/statistic/third.png" alt="">
  277. <span v-else-if="scope.$index < 9">0{{scope.$index+1}}</span>
  278. <span v-else>{{scope.$index+1}}</span>
  279. </template>
  280. </el-table-column>
  281. <el-table-column prop="name" width="400" label="商品">
  282. <template slot-scope="scope">
  283. <div class="text-omit">{{scope.row.goods_name}}</div>
  284. </template>
  285. </el-table-column>
  286. <el-table-column prop="pay_money" label="销售额" width="150" sortable='custom'
  287. :label-class-name="goodsProp == 'pay_money' ? 'sort-active': ''">
  288. <template slot-scope="scope">
  289. {{scope.row.pay_money ? scope.row.pay_money.toFixed(2) : 0}}
  290. </template>
  291. </el-table-column>
  292. <el-table-column prop="sales_num" label="销量" width="150" sortable='custom'
  293. :label-class-name="goodsProp == 'sales_num' ? 'sort-active': ''">
  294. <template slot-scope="scope">
  295. {{scope.row.sales_num ? scope.row.sales_num : 0}}
  296. </template>
  297. </el-table-column>
  298. </el-table>
  299. </el-card>
  300. <el-card shadow="never">
  301. <div slot="header">
  302. <span style="float: left;height: 32px;line-height: 32px">用户购买力TOP排行</span>
  303. <div flex="dir:right" style="">
  304. <button @click="exportData('user_rank')" class="el-button el-button--primary el-button--small">导出TOP100
  305. </button>
  306. </div>
  307. </div>
  308. <el-table v-loading="user_loading" :row-style="{height:'63px'}" @sort-change="changeUser"
  309. :header-cell-style="{background:'#F3F5F6','color':'#303133'}" :data="user_top_list">
  310. <el-table-column align="center" label="排名">
  311. <template slot-scope="scope">
  312. <img style="margin-top: 3px" v-if="scope.$index == 0"
  313. src="resources/img/mall/statistic/first.png" alt="">
  314. <img style="margin-top: 3px" v-else-if="scope.$index == 1"
  315. src="resources/img/mall/statistic/sec.png" alt="">
  316. <img style="margin-top: 3px" v-else-if="scope.$index == 2"
  317. src="resources/img/mall/statistic/third.png" alt="">
  318. <span v-else-if="scope.$index < 9">0{{scope.$index+1}}</span>
  319. <span v-else>{{scope.$index+1}}</span>
  320. </template>
  321. </el-table-column>
  322. <el-table-column prop="name" label="用户" width="400">
  323. <template slot-scope="scope">
  324. <com-image style="margin-right: 10px;float: left;" :src="scope.row.avatar_url" :default_src = "'/resources/img/common/default-avatar.png'" width="32px"
  325. height="32px">
  326. </com-image>
  327. <span class="text-omit"
  328. style="height: 32px;line-height: 32px;display: inline-block;width: 280px">{{scope.row.nickname}}</span>
  329. </template>
  330. </el-table-column>
  331. <el-table-column prop="pay_money" label="支付金额" width="150"
  332. :label-class-name="userProp == 'pay_money.toFixed(2)' ? 'sort-active': ''"
  333. sortable='custom'>
  334. </el-table-column>
  335. <el-table-column prop="pay_goods_num" label="支付件数" width="150"
  336. :label-class-name="userProp == 'pay_goods_num' ? 'sort-active': ''" sortable='custom'>
  337. </el-table-column>
  338. </el-table>
  339. </el-card>
  340. </div>
  341. </el-card>
  342. </div>
  343. <script>
  344. const app = new Vue({
  345. el: '#app',
  346. data() {
  347. return {
  348. // 今天
  349. today: '',
  350. // 七天前
  351. weekDay: '',
  352. // 30天前
  353. monthDay: '',
  354. // 加载动画
  355. loading: false,
  356. goods_loading: false,
  357. user_loading: false,
  358. // 销售情况选中情况
  359. order: true,
  360. price: true,
  361. people: true,
  362. num: true,
  363. // 日期选中状态
  364. activeName: '',
  365. day:1,
  366. // 搜索内容
  367. search: {
  368. mch: null,
  369. time: null,
  370. date_start: null,
  371. date_end: null,
  372. platform: '',
  373. pay_type: '',
  374. },
  375. // 总体数据
  376. all_data: {
  377. goods_num: "0",
  378. order_num: "0",
  379. pro_order: "0",
  380. user_count: "0",
  381. wait_send_num: "0"
  382. },
  383. // 店铺列表
  384. mch_list: [],
  385. // 销售总计
  386. table_data: {
  387. order_num: 0,
  388. total_pay_price: 0,
  389. user_count: 0,
  390. goods_num: 0,
  391. },
  392. // 销售情况
  393. table_list: {
  394. order_num: '0',
  395. total_pay_price: '0',
  396. user_num: '0',
  397. goods_num: '0',
  398. },
  399. // 商品排行
  400. goods_top_list: [],
  401. // 用户排行
  402. user_top_list: [],
  403. // 时段
  404. pay_day: [],
  405. // 图表X轴
  406. echarts_item: ['支付订单数', '支付金额', '支付人数', '支付件数'],
  407. // 图表参数
  408. series: [
  409. {
  410. name: '支付订单数',
  411. type: 'line',
  412. data: []
  413. },
  414. {
  415. name: '支付金额',
  416. type: 'line',
  417. data: []
  418. },
  419. {
  420. name: '支付人数',
  421. type: 'line',
  422. data: []
  423. },
  424. {
  425. name: '支付件数',
  426. type: 'line',
  427. data: []
  428. },
  429. ],
  430. activeDay: 'one',
  431. sort_order: null,
  432. userProp: '',
  433. goodsProp: '',
  434. user_url: '<?= $urlManager->createUrl('mall/data-statistics/users_top')?>',
  435. goods_url: '<?= $urlManager->createUrl('mall/data-statistics/goods_top')?>',
  436. is_mch_role: true
  437. };
  438. },
  439. methods: {
  440. // 修改用户购买力排行榜排序
  441. changeUser(column) {
  442. this.user_loading = true;
  443. this.goodsProp = null;
  444. var para = {
  445. order_type : 'user_rank',
  446. }
  447. if (column && column.order == 'descending'){
  448. para['order_by'] = column.prop + ' DESC';
  449. } else if (column && column.order == "ascending") {
  450. para['order_by'] = column.prop + ' ASC';
  451. }
  452. para['r'] = 'mall/statistics/top-rank';
  453. request({
  454. params: para,
  455. method: 'get',
  456. }).then(e => {
  457. this.user_loading = false;
  458. if (e.data.code == 0) {
  459. this.user_top_list = e.data.data.user_rank;
  460. } else {
  461. this.$message.error(e.data.msg);
  462. }
  463. }).catch(e => {
  464. this.loading = false;
  465. });
  466. },
  467. // 修改商品排序
  468. changeGoods(column) {
  469. this.userProp = null;
  470. this.goods_loading = true;
  471. var para = {
  472. order_type : 'goods_rank',
  473. }
  474. if (column && column.order == 'descending'){
  475. para['order_by'] = column.prop + ' DESC';
  476. } else if (column && column.order == "ascending") {
  477. para['order_by'] = column.prop + ' ASC';
  478. }
  479. para['r'] = 'mall/statistics/top-rank';
  480. request({
  481. params: para,
  482. data: para,
  483. method: 'get',
  484. }).then(res => {
  485. this.goods_loading = false;
  486. if (res.data.code == 0) {
  487. this.goods_top_list = res.data.data.goods_rank;
  488. }
  489. }).catch(res => {
  490. this.goods_loading = false;
  491. })
  492. },
  493. // 获取数据
  494. getList() {
  495. this.loading = true;
  496. this.series[0].data = [];
  497. this.series[1].data = [];
  498. this.series[2].data = [];
  499. this.series[3].data = [];
  500. this.order_num = 0;
  501. this.total_pay_price = 0;
  502. this.user_num = 0;
  503. this.goods_num = 0;
  504. this.pay_day = [];
  505. const _csrf = '<?=Yii::$app->request->csrfToken?>';
  506. request({
  507. params: {
  508. r: 'mall/statistics/data-statistics',
  509. },
  510. data: {
  511. _csrf,
  512. date_start: this.search.date_start,
  513. date_end: this.search.date_end,
  514. mch_id: this.search.mch,
  515. platform: this.search.platform,
  516. pay_type: this.search.pay_type,
  517. },
  518. method: 'post',
  519. }).then(e => {
  520. this.loading = false;
  521. if (e.data.code == 0) {
  522. this.all_data = e.data.data;
  523. //this.mch_list = e.data.data.mch_list;
  524. //this.goods_top_list = e.data.data.goods_top_list;
  525. //this.user_top_list = e.data.data.user_top_list;
  526. this.table_list = e.data.data.table_list;
  527. //this.is_mch_role = e.data.data.is_mch_role;
  528. this.tab_pay();
  529. } else {
  530. this.$message.error(e.data.msg);
  531. }
  532. }).catch(e => {
  533. this.loading = false;
  534. });
  535. },
  536. //排行榜数据
  537. getRank() {
  538. const _csrf = '<?=Yii::$app->request->csrfToken?>';
  539. request({
  540. params: {
  541. r: 'mall/statistics/top-rank',
  542. },
  543. method: 'get',
  544. }).then(e => {
  545. if (e.data.code == 0) {
  546. this.user_top_list = e.data.data.user_rank;
  547. this.goods_top_list = e.data.data.goods_rank;
  548. } else {
  549. this.$message.error(e.data.msg);
  550. }
  551. }).catch(e => {
  552. });
  553. },
  554. // 选择图表显示内容
  555. chooseInfo(row) {
  556. let that = this;
  557. var myChart = echarts.init(document.getElementById('echarts'));
  558. switch (row) {
  559. case 'order':
  560. that.order = !that.order;
  561. myChart.setOption({
  562. legend: {
  563. show: false,
  564. data: that.echarts_item,
  565. selected: {
  566. '支付订单数': that.order,
  567. '支付金额': that.price,
  568. '支付人数': that.people,
  569. '支付件数': that.num
  570. }
  571. }
  572. })
  573. break;
  574. case 'price':
  575. that.price = !that.price;
  576. myChart.setOption({
  577. legend: {
  578. show: false,
  579. data: that.echarts_item,
  580. selected: {
  581. '支付订单数': that.order,
  582. '支付金额': that.price,
  583. '支付人数': that.people,
  584. '支付件数': that.num
  585. }
  586. }
  587. })
  588. break;
  589. case 'people':
  590. that.people = !that.people;
  591. myChart.setOption({
  592. legend: {
  593. show: false,
  594. data: that.echarts_item,
  595. selected: {
  596. '支付订单数': that.order,
  597. '支付金额': that.price,
  598. '支付人数': that.people,
  599. '支付件数': that.num
  600. }
  601. }
  602. })
  603. break;
  604. case 'num':
  605. that.num = !that.num;
  606. myChart.setOption({
  607. legend: {
  608. show: false,
  609. data: that.echarts_item,
  610. selected: {
  611. '支付订单数': that.order,
  612. '支付金额': that.price,
  613. '支付人数': that.people,
  614. '支付件数': that.num
  615. }
  616. }
  617. })
  618. break;
  619. }
  620. },
  621. // 生成图表
  622. form() {
  623. let that = this;
  624. var myChart = echarts.init(document.getElementById('echarts'));
  625. myChart.setOption({
  626. tooltip: {
  627. trigger: 'axis',
  628. backgroundColor: '#fff',
  629. textStyle: {color: '#303133'},
  630. padding: 20,
  631. extraCssText: 'box-shadow: 0 0 4px rgba(0, 0, 0.1);'
  632. },
  633. legend: {
  634. show: false,
  635. data: that.echarts_item
  636. },
  637. color: ['#3399FF', '#FFA360', '#4BC282', '#FF8585'],
  638. grid: {
  639. left: '0',
  640. right: '4%',
  641. bottom: '3%',
  642. containLabel: true
  643. },
  644. xAxis: {
  645. type: 'category',
  646. boundaryGap: false,
  647. data: that.pay_day
  648. },
  649. yAxis: {
  650. splitLine: {
  651. show: true,
  652. lineStyle: {
  653. type: 'dashed'
  654. }
  655. },
  656. axisLine: {
  657. show: false
  658. },
  659. axisLabel: {
  660. show: false
  661. },
  662. axisLabel: {
  663. show: false
  664. },
  665. type: 'value'
  666. },
  667. series: that.series
  668. });
  669. myChart.showLoading({text: '正在加载数据'});
  670. },
  671. // 切换图表区间
  672. tab_pay() {
  673. this.order = true;
  674. this.price = true;
  675. this.people = true;
  676. this.num = true;
  677. this.series[0].data = [];
  678. this.series[1].data = [];
  679. this.series[2].data = [];
  680. this.series[3].data = [];
  681. this.order_num = 0;
  682. this.total_pay_price = 0;
  683. this.user_num = 0;
  684. this.goods_num = 0;
  685. this.pay_day = [];
  686. this.form();
  687. let date_start;
  688. let date_end;
  689. if (this.activeDay == 'seven') {
  690. this.day = 7;
  691. } else {
  692. this.day = 1;
  693. }
  694. request({
  695. params: {
  696. r: 'mall/statistics/sale-info',
  697. mch_id: this.search.mch,
  698. day: this.day,
  699. platform: this.search.platform,
  700. pay_type: this.search.pay_type,
  701. },
  702. method: 'get',
  703. }).then(e => {
  704. this.loading = false;
  705. if (e.data.code == 0) {
  706. this.table_list = e.data.data.table_list;
  707. this.table_data = e.data.data.table_data;
  708. console.log(e.data.data.table_data);
  709. for (let i = 0; i < this.table_list.length; i++) {
  710. this.pay_day.push(this.table_list[i].created_at)
  711. this.series[0].data.push(this.table_list[i].order_num);
  712. this.series[1].data.push(this.table_list[i].total_pay_price);
  713. this.series[2].data.push(this.table_list[i].user_num);
  714. this.series[3].data.push(this.table_list[i].goods_num);
  715. //支付订单数 支付金额 支付人数 支付件数
  716. }
  717. this.form();
  718. var myChart = echarts.init(document.getElementById('echarts'));
  719. myChart.hideLoading();
  720. } else {
  721. this.$message.error(e.data.msg);
  722. }
  723. }).catch(e => {
  724. this.loading = false;
  725. });
  726. },
  727. exportData(type) {
  728. if (type == 'goods_rank'){
  729. this.goods_loading = true;
  730. } else {
  731. this.user_loading = true;
  732. }
  733. request({
  734. params: {
  735. r: 'mall/statistics/export'
  736. },
  737. data : {type: type},
  738. method: 'post',
  739. }).then(e => {
  740. if (e.data.code == 0) {
  741. this.$message.success(e.data.msg);
  742. } else {
  743. this.$message.error(e.data.msg);
  744. }
  745. this.goods_loading = false;
  746. this.user_loading = false;
  747. }).catch(e => {
  748. this.goods_loading = false;
  749. this.user_loading = false;
  750. this.$message.error('未知错误');
  751. });
  752. },
  753. searchList(searchData) {
  754. this.search = searchData;
  755. this.page = 1;
  756. this.getList();
  757. },
  758. toSearch(searchData) {
  759. this.search = searchData;
  760. this.getList();
  761. this.tab_pay();
  762. this.changeUser();
  763. },
  764. tabMch() {
  765. this.getList();
  766. },
  767. },
  768. created() {
  769. this.getRank();
  770. this.getList();
  771. let date = new Date();
  772. let timestamp = date.getTime();
  773. let seperator1 = "-";
  774. let year = date.getFullYear();
  775. let nowMonth = date.getMonth() + 1;
  776. let strDate = date.getDate();
  777. if (nowMonth >= 1 && nowMonth <= 9) {
  778. nowMonth = "0" + nowMonth;
  779. }
  780. if (strDate >= 0 && strDate <= 9) {
  781. strDate = "0" + strDate;
  782. }
  783. this.today = year + seperator1 + nowMonth + seperator1 + strDate;
  784. let week = new Date(timestamp - 7 * 24 * 3600 * 1000)
  785. let weekYear = week.getFullYear();
  786. let weekMonth = week.getMonth() + 1;
  787. let weekStrDate = week.getDate();
  788. if (weekMonth >= 1 && weekMonth <= 9) {
  789. weekMonth = "0" + weekMonth;
  790. }
  791. if (weekStrDate >= 0 && weekStrDate <= 9) {
  792. weekStrDate = "0" + weekStrDate;
  793. }
  794. this.weekDay = weekYear + seperator1 + weekMonth + seperator1 + weekStrDate;
  795. let month = new Date(timestamp - 30 * 24 * 3600 * 1000);
  796. let monthYear = month.getFullYear();
  797. let monthMonth = month.getMonth() + 1;
  798. let monthStrDate = month.getDate();
  799. if (monthMonth >= 1 && monthMonth <= 9) {
  800. monthMonth = "0" + monthMonth;
  801. }
  802. if (monthStrDate >= 0 && monthStrDate <= 9) {
  803. monthStrDate = "0" + monthStrDate;
  804. }
  805. this.monthDay = monthYear + seperator1 + monthMonth + seperator1 + monthStrDate;
  806. },
  807. })
  808. </script>