goods-statistics.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('components/screen-contain', __DIR__);
  4. ComponentHelper::loadComponentView('components/header-time', __DIR__);
  5. ComponentHelper::loadComponentView('components/my-table', __DIR__);
  6. ComponentHelper::loadComponentView('components/mini-echarts', __DIR__);
  7. ?>
  8. <style>
  9. .screen-container {
  10. min-width: 100%;
  11. }
  12. .el-main {
  13. padding: 0;
  14. }
  15. .echrats-cols-item {
  16. width: 482px;
  17. height: 282px;
  18. }
  19. .echrats-cols-item1 {
  20. /* width: 1114px; */
  21. width: 100%;
  22. height: 282px;
  23. margin-bottom: 15px;
  24. }
  25. .echrats-cols-item3 {
  26. height: 328px;
  27. }
  28. .echrats-item-bg {
  29. background: linear-gradient(137deg, #0034E4 0%, #14141A 20%, rgba(7, 7, 9, 0.89) 80%, #0034E4 100%);
  30. border: 1px solid #0034E4;
  31. border-radius: 16px;
  32. }
  33. .echrats-cols-item2 {
  34. padding: 30px;
  35. margin: 15px 0;
  36. background: linear-gradient(135deg, #0034E4 0%, #14141A 4%, rgba(7, 7, 9, 0.89) 91%, rgba(20, 101, 255, 0.11) 100%);
  37. border: 1px solid #0034E4;
  38. }
  39. .echrats-cols-item .title,
  40. .echrats-cols-item1 .bold-font,
  41. .echrats-cols-item1 .title,
  42. .echrats-cols-item3 .title {
  43. height: 30px;
  44. line-height: 30px;
  45. font-size: 30px;
  46. font-family: Source Han Sans CN;
  47. font-weight: 500;
  48. color: #F8F8F8;
  49. }
  50. .echrats-cols-item .title {
  51. margin-bottom: 20px;
  52. }
  53. #echarts3 {
  54. width: 100%;
  55. height: 100%;
  56. }
  57. .item {
  58. width: 203px;
  59. height: 92px;
  60. background: linear-gradient(90deg, rgba(0, 52, 228, 0.4) 0%, rgba(0, 0, 3, 0) 100%);
  61. border-radius: 8px;
  62. padding-left: 11px;
  63. }
  64. .item-number {
  65. font-size: 26px;
  66. font-family: DIN;
  67. font-weight: bold;
  68. line-height: 32px;
  69. color: #F8F8F8;
  70. }
  71. .item-label {
  72. font-size: 15px;
  73. font-family: Source Han Sans CN;
  74. font-weight: 400;
  75. line-height: 25px;
  76. color: #CCCFDA;
  77. opacity: 1;
  78. }
  79. .item-img {
  80. width: 60px;
  81. height: 45px;
  82. margin-bottom: 6px;
  83. }
  84. .echrats-cols-item3 {
  85. padding: 30px;
  86. }
  87. .visitor,
  88. .payment-amount,
  89. .sale {
  90. width: 30%;
  91. }
  92. .visitor .title,
  93. .payment-amount .title,
  94. .sale .title {
  95. height: 23px;
  96. font-size: 23px;
  97. line-height: 23px;
  98. color: #F8F8F8;
  99. margin: 30px 0 20px;
  100. }
  101. </style>
  102. <div id="commodity-data" v-cloak>
  103. <screen-contain text-left="商品数据">
  104. <template v-slot:right>
  105. <header-time></header-time>
  106. </template>
  107. <div style="padding:40px 88px;">
  108. <div class="echrats-item-bg echrats-cols-item2" flex="wrap:wrap main:justify cross:center">
  109. <div class="item" flex="cross:center main:justify" v-for="(item,index) in flowList" :key="index" :style=" index >= flowList.length - 2 ? 'margin-bottom:0': '' ">
  110. <div>
  111. <div class="item-number" v-if="echartsData.goods_data">{{echartsData.goods_data[item.key]}}</div>
  112. <div class="item-label">{{item.text}}</div>
  113. </div>
  114. <div flex="wrap:wrap main:right">
  115. <div class="item-img">
  116. <mini-echarts></mini-echarts>
  117. </div>
  118. <!-- <div>
  119. <span style="color: #1BBC26;"><i class="el-icon-arrow-down"></i>1.2%</span>
  120. <span style="color: #C12727;"><i class="el-icon-arrow-up"></i>1.2%</span>
  121. </div> -->
  122. </div>
  123. </div>
  124. </div>
  125. <div flex="main:justify">
  126. <!-- <div class="echrats-cols-item echrats-item-bg" flex="dir:top" style="padding: 30px;">
  127. <div class="title">商品偏好排行</div>
  128. <div style="flex:1;height:0">
  129. <my-table :data="tableData" :options="options">
  130. <template v-slot:sort="{ item,index }">
  131. <div>{{index+1}}</div>
  132. </template>
  133. </my-table>
  134. </div>
  135. </div> -->
  136. <div class="echrats-cols-item1 echrats-item-bg" flex="dir:top">
  137. <div flex="main:justify" style="padding: 30px 30px 0;">
  138. <div class="title">GMV</div>
  139. <!-- <div class="bold-font">41.00</div> -->
  140. </div>
  141. <div style="flex:1;height:0">
  142. <div id="echarts3"></div>
  143. </div>
  144. </div>
  145. </div>
  146. <div class="echrats-cols-item3 echrats-item-bg" flex="dir:top">
  147. <!-- <div class="title">商品排行</div> -->
  148. <div flex="main:justify" style="height:0;flex: 1;">
  149. <div class="visitor" flex="dir:top" style="height: 100%">
  150. <div class="title">访客排行</div>
  151. <div style="flex:1;height:0">
  152. <my-table :data="echartsData.access_rankings" :options="visitorOptions">
  153. <template v-slot:sort="{ item,index }">
  154. <div>{{index+1}}</div>
  155. </template>
  156. </my-table>
  157. </div>
  158. </div>
  159. <div class="sale" flex="dir:top" style="height: 100%">
  160. <div class="title">支付排行</div>
  161. <div style="flex:1;height:0">
  162. <my-table :data="echartsData.paymoney_rankings" :options="payOptions">
  163. <template v-slot:sort="{ item,index }">
  164. <div>{{index+1}}</div>
  165. </template>
  166. </my-table>
  167. </div>
  168. </div>
  169. <div class="payment-amount" flex="dir:top" style="height: 100%">
  170. <div class="title">销量排行</div>
  171. <div style="flex:1;height:0">
  172. <my-table :data="echartsData.sales_rankings" :options="salesOptions">
  173. <template v-slot:sort="{ item,index }">
  174. <div>{{index+1}}</div>
  175. </template>
  176. </my-table>
  177. </div>
  178. </div>
  179. </div>
  180. </div>
  181. </div>
  182. </screen-contain>
  183. </div>
  184. <script src="/resources/unpkg/echarts@5.2.2/dist/echarts.min.js"></script>
  185. <script>
  186. let tabOptions = [
  187. {
  188. props: "sort",
  189. label: '排行',
  190. slot: true,
  191. width: 50,
  192. textAlign: 'left'
  193. }, {
  194. props: "goods_name",
  195. label: '商品名称',
  196. textAlign: 'left'
  197. },
  198. ]
  199. const app = new Vue({
  200. el: '#commodity-data',
  201. data() {
  202. return {
  203. flowList: [{
  204. text: '商品浏览量',
  205. key: "goods_total_views",
  206. }, {
  207. text: '支付人数',
  208. key: "total_pay_people",
  209. }, {
  210. number: 0,
  211. text: '客单价',
  212. key: "customer_unit_price",
  213. }, {
  214. text: '上架商品数',
  215. key: "goods_listings",
  216. }, {
  217. text: '复购人数',
  218. key: "repurchase_people",
  219. }, {
  220. text: '复购金额',
  221. key: "repurchase_money",
  222. }],
  223. visitorOptions: [
  224. ...tabOptions,
  225. {
  226. props: "access_times",
  227. label: '访客数',
  228. },
  229. ],
  230. payOptions: [
  231. ...tabOptions,
  232. {
  233. props: "pay_amounts",
  234. label: '支付金额',
  235. },
  236. ],
  237. salesOptions: [
  238. ...tabOptions,
  239. {
  240. props: "sales_volumes",
  241. label: '销量(件)',
  242. },
  243. ],
  244. echartsData: {},
  245. }
  246. },
  247. mounted() {
  248. this.getEchartsData();
  249. },
  250. methods: {
  251. getEchartsData(){
  252. let that = this;
  253. request({
  254. params: {
  255. r: 'mall/data-census/goods-statistics',
  256. },
  257. method: 'get'
  258. }).then(e => {
  259. if (e.data.code === 0) {
  260. console.info(e.data.data);
  261. this.echartsData = e.data.data;
  262. } else {
  263. this.$message.error(e.data.msg);
  264. }
  265. that.echarts3Init()
  266. });
  267. },
  268. echarts3Init() {
  269. var chartDom = document.getElementById('echarts3');
  270. var myChart = echarts.init(chartDom);
  271. // 指定图表的配置项和数据
  272. var option = {
  273. grid: {
  274. left: '30px',
  275. right: '30px',
  276. top: '30px',
  277. bottom: '30px',
  278. containLabel: true
  279. },
  280. textStyle: {
  281. color: "#DCDFEB"
  282. },
  283. tooltip: {
  284. trigger: 'item',
  285. formatter: '{a} <br/>{b} : {c} ({d}%)'
  286. },
  287. symbolOffset: [0, '-50%'],
  288. color: ['#0034E4', '#ED7453'],
  289. tooltip: {
  290. trigger: 'axis',
  291. axisPointer: {
  292. type: 'cross',
  293. label: {
  294. backgroundColor: '#6a7985'
  295. }
  296. }
  297. },
  298. xAxis: [{
  299. type: 'category',
  300. boundaryGap: false,
  301. data: this.echartsData.gmvs.keys
  302. }],
  303. yAxis: [{
  304. type: 'value',
  305. splitLine: {
  306. lineStyle: {
  307. color: "rgba(250,250,250,0.4)"
  308. }
  309. }
  310. }, ],
  311. series: [{
  312. name: 'GMV',
  313. type: 'line',
  314. smooth: true,
  315. lineStyle: {
  316. width: '2',
  317. color: "#0034E4"
  318. },
  319. showSymbol: false,
  320. areaStyle: {
  321. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  322. offset: 0,
  323. color: 'rgba(0, 52, 228, 0.56)'
  324. },
  325. {
  326. offset: 0.42,
  327. color: 'rgba(0, 52, 228, 0.28)'
  328. },
  329. {
  330. offset: 0.82,
  331. color: 'rgba(0, 52, 228, 0.08)'
  332. },
  333. {
  334. offset: 1,
  335. color: 'rgba(0, 52, 228, 0)'
  336. }
  337. ])
  338. },
  339. emphasis: {
  340. focus: 'series'
  341. },
  342. data: this.echartsData.gmvs.values,
  343. }, ]
  344. };
  345. myChart.setOption(option);
  346. },
  347. }
  348. })
  349. </script>