index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. <template>
  2. <view class="container">
  3. <!-- 上层部分 -->
  4. <view class="top-bg">
  5. <view class="top-title">靖安县乡村民宿</view>
  6. <!-- 具体数据 -->
  7. <view class="top-list-bg">
  8. <view class="minsuxinsi" v-for="(item,index) in minsu" :key="index">
  9. <view class="list-num">{{item.num}}</view>
  10. <view class="list-txt">{{item.name}}</view>
  11. </view>
  12. </view>
  13. </view>
  14. <!-- 订单状态占比图 -->
  15. <uni-section title="订单状态占比">
  16. <template v-slot:decoration>
  17. <view class="decoration"></view>
  18. </template>
  19. <dingdanzhuangtai class="echarts" :dinglength="dinglength" :dingzhuang="dingzhuang" :dingnum="dingnum">
  20. </dingdanzhuangtai>
  21. </uni-section>
  22. <!-- 民宿统计图 -->
  23. <uni-section title="民宿统计">
  24. <template v-slot:decoration>
  25. <view class="decoration"></view>
  26. </template>
  27. <minsutongji class="echarts2" :xianmin="xianmin" :hotelnum="hotelnum">
  28. </minsutongji>
  29. </uni-section>
  30. <!-- 访问量趋势图 -->
  31. <uni-section title="访问量趋势">
  32. <template v-slot:decoration>
  33. <view class="decoration"></view>
  34. </template>
  35. <!-- 切换 -->
  36. <view class="qiehuankuang">
  37. <view :class="{'xuanzhong':fangtype==1,'list':fangtype!=1}" @click="fangwen(1)">今日</view>
  38. <view :class="{'xuanzhong':fangtype==2,'list':fangtype!=2}" @click="fangwen(2)">本周</view>
  39. <view :class="{'xuanzhong':fangtype==3,'list':fangtype!=3}" @click="fangwen(3)">本月</view>
  40. <view :class="{'xuanzhong':fangtype==4,'list':fangtype!=4}" @click="fangwen(4)">本年</view>
  41. </view>
  42. <fangwenliang class="echarts3" :fangQu="fangQu" :fangquTime="fangquTime">
  43. </fangwenliang>
  44. </uni-section>
  45. <!-- 性别占比图 -->
  46. <uni-section title="性别占比">
  47. <template v-slot:decoration>
  48. <view class="decoration"></view>
  49. </template>
  50. <!-- 切换 -->
  51. <view class="qiehuankuang">
  52. <view :class="{'xuanzhong3':xuanzhong==true,'list3':xuanzhong==false}">今天</view>
  53. <view class="list3">本月</view>
  54. <view class="list3">本年</view>
  55. </view>
  56. <xingbiezhanbi class="echarts4">
  57. </xingbiezhanbi>
  58. </uni-section>
  59. <!-- 年龄占比图 -->
  60. <uni-section title="年龄占比">
  61. <template v-slot:decoration>
  62. <view class="decoration"></view>
  63. </template>
  64. <!-- 切换 -->
  65. <view class="qiehuankuang">
  66. <view :class="{'xuanzhong3':xuanzhong==true,'list3':xuanzhong==false}">今天</view>
  67. <view class="list3">本月</view>
  68. <view class="list3">本年</view>
  69. </view>
  70. <nianlingzhanbi class="echarts5">
  71. </nianlingzhanbi>
  72. </uni-section>
  73. <!-- 订单量排行 -->
  74. <view class="dingdan">
  75. <!-- 订单量排行图 -->
  76. <uni-section title="订单量排行">
  77. <template v-slot:decoration>
  78. <view class="decoration"></view>
  79. </template>
  80. <!-- 切换 -->
  81. <view class="qiehuankuang">
  82. <view :class="{'xuanzhong3':dingtype==1,'list3':dingtype!=1}" @click="dingqie(1)">今天</view>
  83. <view :class="{'xuanzhong3':dingtype==2,'list3':dingtype!=2}" @click="dingqie(2)">本月</view>
  84. <view :class="{'xuanzhong3':dingtype==3,'list3':dingtype!=3}" @click="dingqie(3)">本年</view>
  85. </view>
  86. <dingdanliang class="dingdanliang" :dingPai="dingPai">
  87. </dingdanliang>
  88. </uni-section>
  89. <view style="width:100%;height:20px"></view>
  90. <!-- 销售额排行图 -->
  91. <uni-section title="销售额排行">
  92. <template v-slot:decoration>
  93. <view class="decoration"></view>
  94. </template>
  95. <!-- 切换 -->
  96. <view class="qiehuankuang">
  97. <view :class="{'xuanzhong3':xiaotype==1,'list3':xiaotype!=1}" @click="xiaoqie(1)">今天</view>
  98. <view :class="{'xuanzhong3':xiaotype==2,'list3':xiaotype!=2}" @click="xiaoqie(2)">本月</view>
  99. <view :class="{'xuanzhong3':xiaotype==3,'list3':xiaotype!=3}" @click="xiaoqie(3)">本年</view>
  100. </view>
  101. <xiaoshoue class="xiaoshoue" :xiaoshou="xiaoshou">
  102. </xiaoshoue>
  103. </uni-section>
  104. </view>
  105. </view>
  106. </template>
  107. <script>
  108. import dingdanzhuangtai from '@/components/echarts/dingdanzhuangtai.vue'
  109. import minsutongji from '@/components/echarts/minsutongji.vue'
  110. import fangwenliang from '@/components/echarts/fangwenliang.vue'
  111. import xingbiezhanbi from '@/components/echarts/xingbiezhanbi.vue'
  112. import nianlingzhanbi from '@/components/echarts/nianlingzhanbi.vue'
  113. import dingdanliang from '@/components/liebiao/dingdanliang.vue'
  114. import xiaoshoue from '@/components/liebiao/xiaoshoue.vue'
  115. export default {
  116. components:{
  117. dingdanzhuangtai,
  118. minsutongji,
  119. fangwenliang,
  120. xingbiezhanbi,
  121. nianlingzhanbi,
  122. dingdanliang,
  123. xiaoshoue
  124. },
  125. data() {
  126. return {
  127. minsu:[
  128. {num:0,name:'民宿'},
  129. {num:0,name:'今日访问量'},
  130. {num:0,name:'今日销售额'},
  131. {num:0,name:'今日订单量'},
  132. ],//民宿信息
  133. xuanzhong:true,
  134. // 订单状态
  135. dinglength:0,//订单长度
  136. dingzhuang:[],// 订单状态
  137. dingnum:[],// 订单状态数量
  138. // 民宿统计
  139. xianmin:[],//县名
  140. hotelnum:[],//民宿数量
  141. // 访问量趋势
  142. fangQu:[],
  143. fangquTime:[],
  144. fangStart:new Date().toISOString().slice(0, 10).replace(/-/g,'/'),//2023/08/24 当天
  145. fangEnd:new Date(new Date().setDate(new Date().getDate()+1)).toISOString().slice(0, 10).replace(/-/g,'/'),//后一天
  146. fangtype:1,//筛选条件1今日2本周3本月4本年
  147. // 订单量排行
  148. dingPai:[],
  149. dingtype:1,//筛选条件1今日2本月3本年
  150. // 销售额排行
  151. xiaoshou:[],
  152. xiaotype:1,
  153. }
  154. },
  155. onLoad() {
  156. this.getShuju()
  157. this.getFangwen()
  158. this.getZhuangtai()
  159. this.getMinsuliang()
  160. this.getFangQu()
  161. this.getDingPai()
  162. this.getXiaoshou()
  163. this.t1 = setInterval(function() {
  164. this.getShuju()
  165. this.getFangwen()
  166. this.getZhuangtai()
  167. this.getMinsuliang()
  168. this.getFangQu()
  169. this.getDingPai()
  170. this.getXiaoshou()
  171. }, 86400000);//一天刷新
  172. },
  173. beforeDestroy() {
  174. // 页面关闭清除定时器
  175. clearInterval(this.t1)
  176. },
  177. methods: {
  178. //中台数据
  179. getShuju(){
  180. this.minsu[0].num=0
  181. this.minsu[2].num=0
  182. this.minsu[3].num=0
  183. this.$axios.get("/hotelReservation/mhotel/idcgetSumData.action",
  184. {
  185. }).then(res => {
  186. if (res.data.code==200) {
  187. this.minsu[0].num=res.data.data.hotelSum
  188. this.minsu[2].num=res.data.data.salesAmountDay
  189. this.minsu[3].num=res.data.data.bookNumDay
  190. } else {
  191. console.log('获取中台数据失败')
  192. }
  193. });
  194. },
  195. //今日访问量
  196. getFangwen(){
  197. this.minsu[1].num=0
  198. this.$axios.get("/hotelReservation/mhotel/idcvisitsToday.action",
  199. {
  200. }).then(res => {
  201. if (res.data.code==200) {
  202. this.minsu[1].num=res.data.data.todayCount
  203. } else {
  204. console.log('获取今日访问量失败')
  205. }
  206. });
  207. },
  208. //订单状态占比
  209. getZhuangtai(){
  210. this.dingzhuang=[]
  211. this.dingnum=[]
  212. this.$axios.get("/hotelReservation/mhotel/idcgetBookStatusData.action",
  213. {
  214. }).then(res => {
  215. if (res.data.code==200) {
  216. this.dinglength=res.data.data.length
  217. res.data.data.forEach(data => {
  218. // 订单状态
  219. this.dingzhuang.push(data.orderStatusName)
  220. // 数量
  221. this.dingnum.push(data.statusNum)
  222. })
  223. } else {
  224. console.log('获取订单状态失败')
  225. }
  226. });
  227. },
  228. //各县民宿数量
  229. getMinsuliang(){
  230. this.xianmin=[]
  231. this.hotelnum=[]
  232. this.$axios.get("/hotelReservation/mhotel/idcgetHotelData.action",
  233. {
  234. }).then(res => {
  235. if (res.data.code==200) {
  236. res.data.data.forEach(data => {
  237. // 县名字
  238. this.xianmin.push(data.hposition.slice(-7))
  239. // 民宿数量
  240. this.hotelnum.push(data.hotelNum)
  241. })
  242. } else {
  243. console.log('获取民宿失败')
  244. }
  245. });
  246. },
  247. //获得本周的开始时间:
  248. getStartDayOfWeek(time) {
  249. let now = new Date(time); // 当前日期
  250. let nowDayOfWeek = now.getDay(); // 今天本周的第几天
  251. let day = nowDayOfWeek || 7;
  252. let nowDay = now.getDate(); // 当前日
  253. let nowMonth = now.getMonth(); // 当前月
  254. return this.formatDate(new Date(now.getFullYear(), nowMonth, nowDay + 1 - day));
  255. },
  256. // 日期格式化
  257. formatDate(date) {
  258. let myyear = date.getFullYear();
  259. let mymonth = date.getMonth() + 1;
  260. let myweekday = date.getDate();
  261. if (mymonth < 10) {
  262. mymonth = '0' + mymonth;
  263. }
  264. if (myweekday < 10) {
  265. myweekday = '0' + myweekday;
  266. }
  267. return (myyear + '/' + mymonth + '/' + myweekday);
  268. },
  269. //访问量切换条件
  270. fangwen(e){
  271. if(e==1){
  272. this.fangtype=1
  273. this.fangStart=new Date().toISOString().slice(0, 10).replace(/-/g,'/')
  274. this.fangEnd=new Date(new Date().setDate(new Date().getDate()+1)).toISOString().slice(0, 10).replace(/-/g,'/')
  275. }else if(e==2){
  276. this.fangtype=2
  277. this.fangStart=this.getStartDayOfWeek(new Date().toLocaleDateString())
  278. this.fangEnd=new Date(new Date().setDate(new Date().getDate()+1)).toISOString().slice(0, 10).replace(/-/g,'/')
  279. }else if(e==3){
  280. this.fangtype=3
  281. this.fangStart=new Date(new Date().getFullYear(), new Date().getMonth(),2).toISOString().slice(0, 10).replace(/-/g,'/')
  282. this.fangEnd=new Date(new Date().setDate(new Date().getDate()+1)).toISOString().slice(0, 10).replace(/-/g,'/')
  283. }else if(e==4){
  284. this.fangtype=4
  285. this.fangStart=new Date(new Date().getFullYear(), 0,2).toISOString().slice(0, 10).replace(/-/g,'/')
  286. this.fangEnd=new Date(new Date().setDate(new Date().getDate()+1)).toISOString().slice(0, 10).replace(/-/g,'/')
  287. }
  288. this.getFangQu()
  289. },
  290. //访问量趋势
  291. getFangQu(){
  292. this.fangQu=[]
  293. this.fangquTime=[]
  294. this.$axios.post("/hotelReservation/mhotel/idcvisitsDiyQuery.action?type=4&startTime="+this.fangStart+"&endTime="+this.fangEnd,
  295. {
  296. },).then(res => {
  297. if (res.data.code==200) {
  298. res.data.data.forEach(data => {
  299. // 访问量
  300. this.fangQu.push(data.visitNumber)
  301. // 访问量时间
  302. this.fangquTime.push(data.day)
  303. })
  304. } else {
  305. console.log('获取访问量失败')
  306. }
  307. });
  308. },
  309. //订单量切换条件
  310. dingqie(e){
  311. if(e==1){
  312. this.dingtype=1
  313. }else if(e==2){
  314. this.dingtype=2
  315. }else if(e==3){
  316. this.dingtype=3
  317. }
  318. this.getDingPai()
  319. },
  320. //订单量排行
  321. getDingPai(){
  322. this.dingPai=[]
  323. // type 1今日2本月3本年
  324. this.$axios.get("/hotelReservation/mhotel/idcgetRankBookNumData.action?type="+this.dingtype,
  325. {
  326. }).then(res => {
  327. if (res.data.code==200) {
  328. res.data.data.forEach(data => {
  329. this.dingPai.push(data)
  330. })
  331. } else {
  332. console.log('获取订单量排行数据失败')
  333. }
  334. });
  335. },
  336. //销售额切换条件
  337. xiaoqie(e){
  338. if(e==1){
  339. this.xiaotype=1
  340. }else if(e==2){
  341. this.xiaotype=2
  342. }else if(e==3){
  343. this.xiaotype=3
  344. }
  345. this.getXiaoshou()
  346. },
  347. //销售额排行
  348. getXiaoshou(){
  349. this.xiaoshou=[]
  350. // type 1今日2本月3本年
  351. this.$axios.get("/hotelReservation/mhotel/idcgetRankSalesAmountData.action?type="+this.xiaotype,
  352. {
  353. }).then(res => {
  354. if (res.data.code==200) {
  355. res.data.data.forEach(data => {
  356. this.xiaoshou.push(data)
  357. })
  358. } else {
  359. console.log('获取销售额排行数据失败')
  360. }
  361. });
  362. },
  363. }
  364. }
  365. </script>
  366. <style lang="scss" scoped>
  367. .container {
  368. width:100%;
  369. font-size: 14px;
  370. line-height: 24px;
  371. overflow-x:hidden;
  372. }
  373. /* 上层 */
  374. .top-bg{
  375. height:200px;
  376. width:100%;
  377. background-image: url('../../static/bg-top.png');
  378. background-size: 100%;
  379. // background:linear-gradient(-61.2185deg, rgb(75, 152, 237) 0%, rgb(72, 198, 239) 100%);;
  380. }
  381. .top-title{
  382. color:#FFFFFF;
  383. font-size:18px;
  384. padding-top:30px;
  385. text-align:center;
  386. }
  387. /* 具体数据 */
  388. .top-list-bg{
  389. width:90%;
  390. height:80px;
  391. background:#FFFFFF;
  392. margin:30px 0 0 20px;
  393. border-radius:5px;
  394. display:flex;
  395. }
  396. .minsuxinsi{
  397. position: relative;
  398. // margin-top: 328rpx;
  399. display: inline-block;
  400. width:25%;
  401. text-align: center;
  402. font-size:24rpx;
  403. }
  404. .list-num{
  405. // color:rgb(77, 139, 255);
  406. color:rgba(9, 101, 98, 1);
  407. margin-top: 10px;
  408. font-size: 18px;
  409. font-weight: 600;
  410. }
  411. .list-txt{
  412. margin-top: 5px;
  413. color:rgb(51, 51, 51);
  414. }
  415. // uni-section样式
  416. .uni-section[data-v-f7ca1098] {
  417. background-color: #fff;
  418. margin-top: 10px;
  419. height:280px;
  420. }
  421. .uni-section .uni-section-header__content[data-v-f7ca1098] {
  422. display: flex;
  423. flex-direction: column;
  424. flex: 1;
  425. color: #333;
  426. font-weight: 700;
  427. }
  428. .uni-section .uni-section-content[data-v-f7ca1098] {
  429. font-size: 14px;
  430. z-index: 1;
  431. position: absolute;
  432. }
  433. // 竖线颜色
  434. .decoration{
  435. width: 4px;
  436. height: 12px;
  437. border-radius: 10px;
  438. margin-right: 6px;
  439. background-color: rgba(9, 101, 98, 1);
  440. }
  441. // 订单状态图
  442. .echarts{
  443. width:100%;
  444. height:200px;
  445. }
  446. //民宿统计图
  447. .echarts2{
  448. width:100%;
  449. height:280px;
  450. }
  451. //访问量趋势图
  452. .qiehuankuang{
  453. width:225px;
  454. height:30px;
  455. margin:-30px 0 0 37%;
  456. line-height:30px;
  457. display: flex;
  458. font-size:28rpx;
  459. position: relative;
  460. z-index: 5;
  461. }
  462. .list{
  463. width:25%;
  464. height:100%;
  465. border:1px solid rgba(175, 175, 175, 0.7);
  466. text-align:center;
  467. color: rgb(119, 119, 119)
  468. }
  469. .xuanzhong{
  470. width:25%;
  471. height:100%;
  472. border:1px solid rgba(9, 101, 98, 1);
  473. text-align:center;
  474. background-color:rgba(9, 101, 98, 1);
  475. color:#FFFFFF;
  476. }
  477. // 三等份
  478. .list3{
  479. width:33%;
  480. height:100%;
  481. border:1px solid rgba(175, 175, 175, 0.7);
  482. text-align:center;
  483. color: rgb(119, 119, 119)
  484. }
  485. .xuanzhong3{
  486. width:33%;
  487. height:100%;
  488. border:1px solid rgba(9, 101, 98, 1);
  489. text-align:center;
  490. background-color:rgba(9, 101, 98, 1);
  491. color:#FFFFFF;
  492. }
  493. .echarts3{
  494. width:100%;
  495. height:230px;
  496. }
  497. //性别占比图
  498. .echarts4{
  499. width:100%;
  500. height:230px;
  501. }
  502. //年龄占比图
  503. .echarts5{
  504. width:100%;
  505. height:230px;
  506. }
  507. // 订单量排行
  508. .dingdan{
  509. background-color: #fff;
  510. margin-top: 20px;
  511. height:150%;
  512. }
  513. //订单量排行图
  514. .dingdanliang{
  515. width:100%;
  516. height: 260px;
  517. margin-top: 10px;
  518. overflow-y: auto;
  519. }
  520. // 销售额排行图
  521. .xiaoshoue{
  522. width:100%;
  523. height: 260px;
  524. margin-top: 10px;
  525. overflow-y: auto;
  526. }
  527. </style>