index.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <div id="app" v-cloak>
  2. <el-card shadow="never" style="border:0;min-width: 900px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  3. <div slot="header">
  4. <span>数据概况</span>
  5. </div>
  6. <div class="table-body" >
  7. <div style="border-bottom: 2px solid #DCDEE2;padding-bottom: 10px;">数据展示</div>
  8. <el-row :gutter="20" style="margin-top: 20px;" v-loading="dataLoading">
  9. <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4">
  10. <div class="grid-content bg-purple">
  11. <div style="margin-bottom: 25px;">用户浏览量</div>
  12. <div style="display: flex;align-items: flex-end;justify-content: space-between;">
  13. <div style="font-size: 30px;color: #4D4F5C;font-weight: bold;">{{allData.browse_num}}</div>
  14. <img style="width: 60px;height: 20px;" :src="diy_img_prefix+'/static/addons/business-card/liulanshuliang.png'" />
  15. </div>
  16. </div>
  17. </el-col>
  18. <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4">
  19. <div class="grid-content bg-purple">
  20. <div style="margin-bottom: 25px;">名片数量</div>
  21. <div style="display: flex;align-items: flex-end;justify-content: space-between;">
  22. <div style="font-size: 30px;color: #4D4F5C;font-weight: bold;">{{allData.card_num}}</div>
  23. <img style="width: 60px;height: 20px;" :src="diy_img_prefix+'/static/addons/business-card/mingpianshuliang.png'" />
  24. </div>
  25. </div>
  26. </el-col>
  27. </el-row>
  28. <div style="display: flex;align-items: center;">
  29. <div>请点击筛选:</div>
  30. <el-select v-model="selectValue" placeholder="近7天" @change="handle('selectDate', $event)">
  31. <el-option label="近7天" value="7"></el-option>
  32. <el-option label="近15天" value="15"></el-option>
  33. <el-option label="近30天" value="30"></el-option>
  34. </el-select>
  35. </div>
  36. <div class="dataBox" id="echartsBox1" style="width: 15rem;height: 5.5rem;margin-bottom: 20px;" v-loading="chartLoading"></div>
  37. </div>
  38. </el-card>
  39. </div>
  40. <script>
  41. let myChart;
  42. const app = new Vue({
  43. el: '#app',
  44. data: {
  45. selectValue: '',
  46. chartLoading: true,
  47. dataLoading: true,
  48. user_rank: [],
  49. clue_rank: [],
  50. num_rank: [],
  51. diy_img_prefix: '<?= Yii::getAlias('@attachurl') ?>',
  52. money_rank: [],
  53. allData: {
  54. order_money: 0,order_num: 0,card_num: 0,browse_num: 0,clue_num: 0
  55. }
  56. },
  57. created() {
  58. var size = (window.innerWidth || document.documentElement.clientWidth) / 1920 * 100;
  59. document.documentElement.style.fontSize = size + "px";
  60. document.body.style.fontSize = "14px";
  61. },
  62. mounted() {
  63. myChart = echarts.init(document.querySelector("#echartsBox1"));
  64. this.send('chart');
  65. this.send('getData');
  66. },
  67. methods: {
  68. send(type, param1 = null, param2 = null){
  69. switch(type) {
  70. //获取图表数据
  71. case 'chart':
  72. this.chartLoading = true;
  73. request({
  74. params: {
  75. r: 'business-card/default/chart',
  76. date: this.selectValue
  77. },
  78. }).then(e=>{
  79. this.chartLoading = false;
  80. if (e.data.code == 0) {
  81. if(e.data.data){
  82. let obj = {
  83. date: e.data.data.date,
  84. card_num: e.data.data.series.card_num,
  85. clue_num: e.data.data.series.clue_num,
  86. order_num: e.data.data.series.order_num,
  87. order_money: e.data.data.series.order_money,
  88. user_views: e.data.data.series.user_views,
  89. }
  90. this.handle('chart', obj);
  91. }
  92. }
  93. }).catch(e=>{
  94. this.chartLoading = false;
  95. this.$message.error(e.data.msg);
  96. })
  97. break;
  98. //获取数据
  99. case 'getData':
  100. this.dataLoading = false;
  101. request({
  102. params: {
  103. r: 'business-card/default/index'
  104. },
  105. }).then(e=>{
  106. this.chartLoading = false;
  107. if (e.data.code == 0) {
  108. if(e.data.data){
  109. this.user_rank = e.data.data.userRank;
  110. this.clue_rank = e.data.data.clueRank;
  111. this.num_rank = e.data.data.numRank;
  112. this.money_rank = e.data.data.moneyRank;
  113. if(e.data.data.allData) this.allData = e.data.data.allData;
  114. }
  115. }
  116. }).catch(e=>{
  117. this.chartLoading = false;
  118. this.$message.error(e.data.msg);
  119. })
  120. break;
  121. }
  122. },
  123. handle(type, param1 = null, param2 = null) {
  124. switch(type) {
  125. //选择日期
  126. case 'selectDate':
  127. this.selectValue = param1;
  128. this.send('chart');
  129. break;
  130. //渲染图表
  131. case 'chart':
  132. option = {
  133. color: ["#77E0FE", "#B7B5FC","#70E5AA","#FF7161","#FFCB83"],
  134. tooltip: {
  135. trigger: "axis",
  136. axisPointer: {
  137. lineStyle: {
  138. color: "#dddc6b"
  139. }
  140. }
  141. },
  142. legend: {
  143. bottom: "0%",
  144. left:"4%",
  145. itemGap : 60,
  146. data: [ '用户浏览量', '名片数量']
  147. },
  148. grid: {
  149. left: '2%',
  150. right: '4%',
  151. bottom: '8%',
  152. containLabel: true
  153. },
  154. xAxis: [
  155. {
  156. type: 'category',
  157. boundaryGap: false,
  158. data:param1.date
  159. },
  160. ],
  161. yAxis: [
  162. {
  163. type: 'value',
  164. axisTick: { show: false },
  165. }
  166. ],
  167. series: [
  168. {
  169. name: '用户浏览量',
  170. type: 'line',
  171. smooth: true,
  172. symbolSize: 10,
  173. areaStyle: {
  174. normal: {
  175. color: new echarts.graphic.LinearGradient(
  176. 0,
  177. 0,
  178. 0,
  179. 1,
  180. [
  181. {
  182. offset: 0,
  183. color: "#B7B5FC"
  184. },
  185. {
  186. offset: 1,
  187. color: "#ffffff"
  188. }
  189. ],
  190. false
  191. ),
  192. shadowColor: "rgba(0, 0, 0, 0.1)"
  193. }
  194. },
  195. //data: [20, 500, 199, 800, 90, 1000, 300]
  196. data:param1.user_views
  197. },
  198. {
  199. name: '名片数量',
  200. type: 'line',
  201. smooth: true,
  202. symbolSize: 10,
  203. areaStyle: {
  204. normal: {
  205. color: new echarts.graphic.LinearGradient(
  206. 0,
  207. 0,
  208. 0,
  209. 1,
  210. [
  211. {
  212. offset: 0,
  213. color: "#70E5AA"
  214. },
  215. {
  216. offset: 1,
  217. color: "#ffffff"
  218. }
  219. ],
  220. false
  221. ),
  222. shadowColor: "rgba(0, 0, 0, 0.1)"
  223. }
  224. },
  225. //data: [2000, 500, 1200, 100, 90, 50, 30]
  226. data:param1.card_num
  227. }
  228. ]
  229. };
  230. // 使用刚指定的配置项和数据显示图表。
  231. myChart.setOption(option);
  232. window.addEventListener("resize", function() {
  233. var size = (window.innerWidth || document.documentElement.clientWidth) / 1920 * 100;
  234. document.documentElement.style.fontSize = size + "px";
  235. document.body.style.fontSize = "14px";
  236. myChart.resize();
  237. });
  238. break;
  239. }
  240. }
  241. }
  242. })
  243. </script>
  244. <style>
  245. .el-tabs__header {
  246. font-size: 16px;
  247. }
  248. .table-body {
  249. padding: 20px;
  250. background-color: #fff;
  251. }
  252. .table-body .el-button {
  253. padding: 0 !important;
  254. border: 0;
  255. margin: 0 5px;
  256. }
  257. .input-item {
  258. width: 250px;
  259. margin: 0 0 20px;
  260. display: inline-block;
  261. }
  262. .input-item .el-input__inner {
  263. border-right: 0;
  264. }
  265. .input-item .el-input__inner:hover {
  266. border: 1px solid #dcdfe6;
  267. border-right: 0;
  268. outline: 0;
  269. }
  270. .input-item .el-input__inner:focus {
  271. border: 1px solid #dcdfe6;
  272. border-right: 0;
  273. outline: 0;
  274. }
  275. .input-item .el-input-group__append {
  276. background-color: #fff;
  277. border-left: 0;
  278. width: 10%;
  279. padding: 0;
  280. }
  281. .input-item .el-input-group__append .el-button {
  282. padding: 0;
  283. }
  284. .input-item .el-input-group__append .el-button {
  285. margin: 0;
  286. }
  287. .batch {
  288. margin: 0 0 20px;
  289. display: inline-block;
  290. }
  291. .batch .el-button {
  292. padding: 9px 15px !important;
  293. }
  294. .el-row {
  295. margin-bottom: 20px;
  296. &:last-child {
  297. margin-bottom: 0;
  298. }
  299. }
  300. .el-col {
  301. border-radius: 4px;
  302. }
  303. .bg-purple-dark {
  304. background: #99a9bf;
  305. }
  306. .bg-purple {
  307. background: #d3dce6;
  308. }
  309. .bg-purple-light {
  310. background: #e5e9f2;
  311. }
  312. .grid-content {
  313. border-radius: 4px;
  314. min-height: 36px;
  315. padding: 12px;
  316. background: #FFFFFF;
  317. border: 1px solid #DCDEE2;
  318. box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.04);
  319. /* width: 240px; */
  320. margin-bottom: 20px;
  321. }
  322. .row-bg {
  323. padding: 10px 0;
  324. background-color: #f9fafc;
  325. }
  326. .el-table th>.cell{
  327. color: #333;
  328. font-weight: bold;
  329. font-size: 14px;
  330. }
  331. .el-table__footer-wrapper, .el-table__header-wrapper{
  332. border-bottom: 1.4px solid #D6D6D6;
  333. background-color: #F3F5F6;
  334. }
  335. .paihangbang{
  336. margin-top: 10px;
  337. padding-bottom: 50px;
  338. /* display: flex; */
  339. }
  340. .paihangbangItem{
  341. /* width: 350px; */
  342. box-sizing: border-box;
  343. padding: 0 22px;
  344. background-color: #fff;
  345. /* margin-right: 20px; */
  346. margin-bottom: 20px;
  347. }
  348. .paihangbangItem .title{
  349. color: #17233D;
  350. font-size: 16px;
  351. text-align: center;
  352. padding: 15px 0;
  353. border-bottom: 1px solid #DCDEE2;
  354. }
  355. </style>