index.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  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. <!-- 数据总览 -->
  155. <div class="num-info">
  156. <div class="num-info-item">
  157. <div class="info-item-name">
  158. <span>待自提订单(笔)</span>
  159. </div>
  160. <div>{{store.no_take_counts}}</div>
  161. </div>
  162. <div class="num-info-item">
  163. <div class="info-item-name">
  164. <span>待配送订单(笔)</span>
  165. </div>
  166. <div>{{store.no_delivery_counts}}</div>
  167. </div>
  168. <div class="num-info-item">
  169. <div class="info-item-name">待售后订单(笔)</div>
  170. <div>{{store.after_sale_counts}}</div>
  171. </div>
  172. <div class="num-info-item">
  173. <div class="info-item-name">待付款订单(笔)</div>
  174. <div>{{store.no_pay_counts}}</div>
  175. </div>
  176. <div class="num-info-item">
  177. <div class="info-item-name">已售罄商品(个)</div>
  178. <div>{{store.sell_out_counts}}</div>
  179. </div>
  180. </div>
  181. </div>
  182. <!-- 销售情况 -->
  183. <el-card shadow="never">
  184. <div slot="header">
  185. <span>经营概况</span>
  186. <div class="tab-pay">
  187. <el-tabs v-model="activeDay" @tab-click="tab_pay">
  188. <el-tab-pane label="昨日" name="one"></el-tab-pane>
  189. <el-tab-pane label="近7天" name="seven"></el-tab-pane>
  190. <el-tab-pane label="近30天" name="thirty"></el-tab-pane>
  191. </el-tabs>
  192. </div>
  193. </div>
  194. <!-- 选择框 -->
  195. <div class="pay-info">
  196. <div class="pay-info-item" >
  197. <img src="statics/img/mall/statistic/active.png" alt="">
  198. <div >成交额</div>
  199. <div class="info-item-name">¥:{{today_data.sales_money}}</div>
  200. <div class="info-item-name">昨日:{{yesterday_data.sales_money}}</div>
  201. </div>
  202. <div class="pay-info-item" >
  203. <img src="statics/img/mall/statistic/active.png" alt="">
  204. <div >新增会员</div>
  205. <div class="info-item-name">{{today_data.add_user_nums}}</div>
  206. <div class="info-item-name">昨日:{{yesterday_data.add_user_nums}}</div>
  207. </div>
  208. <div class="pay-info-item" >
  209. <img src="statics/img/mall/statistic/active.png" alt="">
  210. <div >订单数</div>
  211. <div class="info-item-name">{{today_data.order_nums}}</div>
  212. <div class="info-item-name">昨日:{{yesterday_data.order_nums}}</div>
  213. </div>
  214. </div>
  215. </el-card>
  216. <br/>
  217. <el-card shadow="never">
  218. <div slot="header">
  219. <span>图表</span>
  220. <div class="tab-pay">
  221. </div>
  222. </div>
  223. <div class="echarts-title">
  224. <div class="echarts-title-item" v-if="order">
  225. <div class="echarts-title-icon"></div>
  226. <div>门店销售额</div>
  227. </div>
  228. </div>
  229. <div id="echarts" style="height:18rem;"></div>
  230. </el-card>
  231. <div class="table-area">
  232. <el-card shadow="never">
  233. <div slot="header">
  234. <span style="float: left;height: 32px;line-height: 32px">商品销量排行(TOP5)</span>
  235. <div flex="dir:right" style="">
  236. </div>
  237. </div>
  238. <el-table v-loading="goods_loading" :row-style="{height:'63px'}"
  239. :header-cell-style="{background:'#F3F5F6','color':'#303133'}" :data="goods_top_list">
  240. <el-table-column align="center" label="排名">
  241. <template slot-scope="scope">
  242. <img style="margin-top: 3px" v-if="scope.$index == 0"
  243. src="resources/img/mall/statistic/first.png" alt="">
  244. <img style="margin-top: 3px" v-else-if="scope.$index == 1"
  245. src="resources/img/mall/statistic/sec.png" alt="">
  246. <img style="margin-top: 3px" v-else-if="scope.$index == 2"
  247. src="resources/img/mall/statistic/third.png" alt="">
  248. <span v-else-if="scope.$index < 9">0{{scope.$index+1}}</span>
  249. <span v-else>{{scope.$index+1}}</span>
  250. </template>
  251. </el-table-column>
  252. <el-table-column prop="name" width="400" label="商品">
  253. <template slot-scope="scope">
  254. <div class="text-omit">{{scope.row.goods_name}}</div>
  255. </template>
  256. </el-table-column>
  257. <el-table-column prop="pay_money" label="销售额" width="150"
  258. :label-class-name="goodsProp == 'pay_money' ? 'sort-active': ''">
  259. <template slot-scope="scope">
  260. {{scope.row.sales_money ? scope.row.sales_money.toFixed(2) : 0}}
  261. </template>
  262. </el-table-column>
  263. </el-table>
  264. </el-card>
  265. <el-card shadow="never">
  266. <div slot="header">
  267. <span style="float: left;height: 32px;line-height: 32px">会员消费排行(TOP5)</span>
  268. <div flex="dir:right" style="">
  269. </div>
  270. </div>
  271. <el-table v-loading="user_loading" :row-style="{height:'63px'}"
  272. :header-cell-style="{background:'#F3F5F6','color':'#303133'}" :data="user_top_list">
  273. <el-table-column align="center" label="排名">
  274. <template slot-scope="scope">
  275. <img style="margin-top: 3px" v-if="scope.$index == 0"
  276. src="resources/img/mall/statistic/first.png" alt="">
  277. <img style="margin-top: 3px" v-else-if="scope.$index == 1"
  278. src="resources/img/mall/statistic/sec.png" alt="">
  279. <img style="margin-top: 3px" v-else-if="scope.$index == 2"
  280. src="resources/img/mall/statistic/third.png" alt="">
  281. <span v-else-if="scope.$index < 9">0{{scope.$index+1}}</span>
  282. <span v-else>{{scope.$index+1}}</span>
  283. </template>
  284. </el-table-column>
  285. <el-table-column prop="name" label="用户" width="400">
  286. <template slot-scope="scope">
  287. <com-image style="margin-right: 10px;float: left;" :src="scope.row.avatar_url" :default_src = "'/resources/img/common/default-avatar.png'" width="32px"
  288. height="32px">
  289. </com-image>
  290. <span class="text-omit"
  291. style="height: 32px;line-height: 32px;display: inline-block;width: 280px">{{scope.row.nickname}}</span>
  292. </template>
  293. </el-table-column>
  294. <el-table-column prop="pay_money" label="消费总金额" width="150"
  295. :label-class-name="userProp == 'pay_money.toFixed(2)' ? 'sort-active': ''"
  296. >
  297. </el-table-column>
  298. </el-table>
  299. </el-card>
  300. </div>
  301. </el-card>
  302. </div>
  303. <script>
  304. const app = new Vue({
  305. el: '#app',
  306. data() {
  307. return {
  308. // 今天
  309. today: '',
  310. // 七天前
  311. weekDay: '',
  312. // 30天前
  313. monthDay: '',
  314. // 加载动画
  315. loading: false,
  316. goods_loading: false,
  317. user_loading: false,
  318. // 销售情况选中情况
  319. order: true,
  320. price: true,
  321. people: true,
  322. num: true,
  323. // 日期选中状态
  324. activeName: '',
  325. day:1,
  326. // 搜索内容
  327. search: {
  328. mch: null,
  329. time: null,
  330. date_start: null,
  331. date_end: null,
  332. platform: '',
  333. pay_type: '',
  334. },
  335. // 总体数据
  336. all_data: {
  337. goods_num: "0",
  338. order_num: "0",
  339. pro_order: "0",
  340. user_count: "0",
  341. wait_send_num: "0"
  342. },
  343. // 店铺列表
  344. mch_list: [],
  345. // 销售总计
  346. table_data: {
  347. order_num: 0,
  348. total_pay_price: 0,
  349. user_count: 0,
  350. goods_num: 0,
  351. },
  352. // 销售情况
  353. table_list: {
  354. order_num: '0',
  355. total_pay_price: '0',
  356. user_num: '0',
  357. goods_num: '0',
  358. },
  359. // 商品排行
  360. goods_top_list: [],
  361. // 用户排行
  362. user_top_list: [],
  363. // 时段
  364. pay_day: [],
  365. // 图表X轴
  366. echarts_item: ['门店销售额', '收银台销售额'],
  367. // 图表参数
  368. series: [
  369. {
  370. name: '门店销售额',
  371. type: 'line',
  372. data: []
  373. },
  374. {
  375. name: '收银台销售额',
  376. type: 'line',
  377. data: []
  378. },
  379. ],
  380. activeDay: 'one',
  381. sort_order: null,
  382. userProp: '',
  383. goodsProp: '',
  384. user_url: '<?= $urlManager->createUrl('mall/data-statistics/users_top')?>',
  385. goods_url: '<?= $urlManager->createUrl('mall/data-statistics/goods_top')?>',
  386. is_mch_role: true,
  387. store:{},
  388. today_data:{},
  389. yesterday_data:{},
  390. };
  391. },
  392. methods: {
  393. // 获取数据
  394. getList() {
  395. this.loading = true;
  396. this.series[0].data = [];
  397. this.series[1].data = [];
  398. this.order_num = 0;
  399. this.total_pay_price = 0;
  400. this.user_num = 0;
  401. this.goods_num = 0;
  402. this.pay_day = [];
  403. const _csrf = '<?=Yii::$app->request->csrfToken?>';
  404. request({
  405. params: {
  406. r: 'happiness/client/index/index',
  407. },
  408. data: {
  409. _csrf,
  410. date_start: this.search.date_start,
  411. date_end: this.search.date_end,
  412. mch_id: this.search.mch,
  413. platform: this.search.platform,
  414. pay_type: this.search.pay_type,
  415. },
  416. method: 'post',
  417. }).then(e => {
  418. this.loading = false;
  419. if (e.data.code == 0) {
  420. // this.all_data = e.data.data;
  421. //this.mch_list = e.data.data.mch_list;
  422. this.goods_top_list = e.data.data.goods_ranking_list;
  423. this.user_top_list = e.data.data.user_ranking_list;
  424. this.today_data = e.data.data.today_data;
  425. this.yesterday_data = e.data.data.yesterday_data;
  426. this.store = e.data.data.store;
  427. this.tab_pays(e.data.data.table_list,[]);
  428. } else {
  429. this.$message.error(e.data.msg);
  430. }
  431. }).catch(e => {
  432. this.loading = false;
  433. });
  434. },
  435. //排行榜数据
  436. // 生成图表
  437. form() {
  438. let that = this;
  439. var myChart = echarts.init(document.getElementById('echarts'));
  440. myChart.setOption({
  441. tooltip: {
  442. trigger: 'axis',
  443. backgroundColor: '#fff',
  444. textStyle: {color: '#303133'},
  445. padding: 20,
  446. extraCssText: 'box-shadow: 0 0 4px rgba(0, 0, 0.1);'
  447. },
  448. legend: {
  449. show: false,
  450. data: that.echarts_item
  451. },
  452. color: ['#3399FF', '#FFA360', '#4BC282', '#FF8585'],
  453. grid: {
  454. left: '0',
  455. right: '4%',
  456. bottom: '3%',
  457. containLabel: true
  458. },
  459. xAxis: {
  460. type: 'category',
  461. boundaryGap: false,
  462. data: that.pay_day
  463. },
  464. yAxis: {
  465. splitLine: {
  466. show: true,
  467. lineStyle: {
  468. type: 'dashed'
  469. }
  470. },
  471. axisLine: {
  472. show: false
  473. },
  474. axisLabel: {
  475. show: false
  476. },
  477. axisLabel: {
  478. show: false
  479. },
  480. type: 'value'
  481. },
  482. series: that.series
  483. });
  484. myChart.showLoading({text: '正在加载数据'});
  485. },
  486. // 切换图表区间
  487. tab_pays(table_list,table_data) {
  488. this.order = true;
  489. this.price = true;
  490. this.people = true;
  491. this.num = true;
  492. this.series[0].data = [];
  493. this.series[1].data = [];
  494. this.sales_money = 0;
  495. this.cashier_sales_money = 0;
  496. this.user_num = 0;
  497. this.goods_num = 0;
  498. this.pay_day = [];
  499. this.form();
  500. let date_start;
  501. let date_end;
  502. if (this.activeDay == 'seven') {
  503. this.day = 7;
  504. } else {
  505. this.day = 1;
  506. }
  507. this.table_list = table_list;
  508. this.table_data = table_data;
  509. for (let i = 0; i < this.table_list.length; i++) {
  510. this.pay_day.push(this.table_list[i].created_at)
  511. this.series[0].data.push(this.table_list[i].sales_money);
  512. this.series[1].data.push(this.table_list[i].cashier_sales_money);
  513. //支付订单数 支付金额 支付人数 支付件数
  514. }
  515. this.form();
  516. var myChart = echarts.init(document.getElementById('echarts'));
  517. myChart.hideLoading();
  518. },
  519. tab_pay() {
  520. request({
  521. params: {
  522. r: 'happiness/client/index/to-pay',
  523. },
  524. data: {
  525. activeDay: this.activeDay,
  526. },
  527. method: 'post',
  528. }).then(e => {
  529. this.loading = false;
  530. if (e.data.code == 0) {
  531. this.today_data = e.data.data.today_data;
  532. } else {
  533. this.$message.error(e.data.msg);
  534. }
  535. }).catch(e => {
  536. this.loading = false;
  537. });
  538. },
  539. },
  540. created() {
  541. this.getList();
  542. this.tab_pay();
  543. },
  544. })
  545. </script>