index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. <template>
  2. <view class="page" :style="{'padding-top':mt+'px'}">
  3. <c-nav-bar title="统计" :showIcon="false"></c-nav-bar>
  4. <view class="hander" @click="DateTimes">
  5. <!-- 2024年1月 -->
  6. <view
  7. class="tn-flex tn-flex-col-center tn-margin-right tn-padding-xs tn-text-sm tn-bg-gray--light tn-radius tn-color-gray--dark"
  8. style="border-radius: 12rpx; width: 380rpx;">
  9. <!-- <picker @change="bindDateChange" mode="date" :value="date" :start="startDate" :end="endDate"
  10. fields="month">
  11. </picker> -->
  12. <text class="tn-padding-left-xs tn-padding-right-xs">{{dateTime}}
  13. </text>
  14. </view>
  15. <view style="width: 60rpx; line-height: 48rpx; height: 48rpx; margin: 15rpx 0 ; ">
  16. <u-icon name="arrow-down" color="#000000" size="20"></u-icon>
  17. </view>
  18. </view>
  19. <view class="hander-price">
  20. <view class="one">
  21. <view class="left">
  22. 总营业额
  23. </view>
  24. <view class="right">
  25. 共{{list.totalNums==null?'0':list.totalNums}}笔
  26. </view>
  27. </view>
  28. <view class="two">
  29. <text>¥</text>
  30. <text>{{list.totalAmount==null?'0':list.totalAmount}}</text>
  31. </view>
  32. </view>
  33. <view class="echarts-one">
  34. <view class="title">
  35. 营业概况
  36. </view>
  37. <view class="hander-content">
  38. <view class="list">
  39. <view class="title">
  40. 房费
  41. </view>
  42. <view class="price">
  43. {{list.roomAmount==null?'0':list.roomAmount}}
  44. </view>
  45. </view>
  46. <view class="list">
  47. <view class="title">
  48. 餐饮
  49. </view>
  50. <view class="price">
  51. {{list.repastAmount==null?'0':list.repastAmount}}
  52. </view>
  53. </view>
  54. <view class="list">
  55. <view class="title">
  56. 其他
  57. </view>
  58. <view class="price">
  59. {{list.othersAmount==null?'0':list.othersAmount}}
  60. </view>
  61. </view>
  62. </view>
  63. <view class="Pie_charts" style="min-height: 580rpx;">
  64. <!-- <PieCharts></PieCharts> -->
  65. <qiun-data-charts :canvas2d='true' type="ring" :opts="optsPied" :chartData="chartDataPied" />
  66. </view>
  67. </view>
  68. <view class="echarts-two">
  69. <view class="title">
  70. 交易趋势
  71. </view>
  72. <view class="title1">
  73. 单位:元
  74. </view>
  75. <view class="line_charts_one">
  76. <qiun-data-charts :ontouch="true" canvas2d='true' type="line" :opts="revenueOptsone"
  77. :chartData="revenueChartDataOne" />
  78. </view>
  79. </view>
  80. <view class="echarts-three">
  81. <view>
  82. <view class="title">
  83. 入住率
  84. </view>
  85. <view class="title1">
  86. 入住率(%)
  87. </view>
  88. </view>
  89. <view class="line_charts_two">
  90. <qiun-data-charts type="line" canvas2d='true' :ontouch="true" :opts="revenueOptstwo"
  91. :chartData="revenueChartDataTwo" />
  92. </view>
  93. </view>
  94. <Tabbar :tabbarIndex="2"></Tabbar>
  95. <u-calendar class="u-time" confirmDisabledText="确定" :show="showTime" mode="range" @confirm="confirm"
  96. @close="closeDate" :defaultDate="calendar.defaultDate" :maxDate="calendar.maxDate" :closeable="true"
  97. :minDate="calendar.minDate" :monthNum="calendar.monthNum" :closeOnClickOverlay="true"></u-calendar>
  98. </view>
  99. </template>
  100. <script>
  101. // import uCharts from '@/utils/u-charts.js';
  102. // import PieCharts from "@/components/Charts/PieCharts.vue"
  103. // import LineOne from "@/components/Charts/LineOne.vue"
  104. // import LineTwo from "@/components/Charts/LineTwo.vue"
  105. export default {
  106. components: {
  107. // PieCharts,
  108. // LineOne,
  109. // LineTwo
  110. },
  111. data() {
  112. return {
  113. h: uni.getSystemInfoSync().windowHeight,
  114. mt: uni.getSystemInfoSync().statusBarHeight + 54,
  115. date: '',
  116. fromData: {
  117. dateDayStart: '', //开始
  118. dateDayEnd: '', //结束
  119. homestayId: '',
  120. },
  121. // 营业概况
  122. chartDataPied: {},
  123. optsPied: {
  124. rotate: false,
  125. rotateLock: false,
  126. color: ['#1372FF', '#F89F2A', '#02C493'],
  127. padding: [30, 30, 30, 35],
  128. dataLabel: true,
  129. enableScroll: false,
  130. legend: {
  131. show: true,
  132. position: "bottom",
  133. lineHeight: 25
  134. },
  135. title: {
  136. name: "",
  137. fontSize: 15,
  138. color: "#666666"
  139. },
  140. subtitle: {
  141. name: "",
  142. fontSize: 25,
  143. color: "#7cb5ec"
  144. },
  145. extra: {
  146. ring: {
  147. ringWidth: 25,
  148. activeOpacity: 0.5,
  149. activeRadius: 10,
  150. offsetAngle: 0,
  151. labelWidth: 10,
  152. border: false,
  153. borderWidth: 3,
  154. borderColor: "#FFFFFF"
  155. }
  156. },
  157. },
  158. PieChartsList: {},
  159. // 交易趋势
  160. revenueChartDataOne: {},
  161. revenueOptsone: {
  162. color: ["#4B98FE"],
  163. padding: [15, 15],
  164. dataLabel: false,
  165. enableScroll: true,
  166. xAxis: {
  167. disableGrid: true,
  168. gridType: "solid",
  169. itemCount: 6,
  170. scrollShow: true,
  171. axisLineColor: "#EFEFEF",
  172. },
  173. legend: {
  174. show: false
  175. },
  176. yAxis: {
  177. gridType: "solid",
  178. gridColor: "#EFEFEF",
  179. dashLength: 2
  180. },
  181. extra: {
  182. line: {
  183. type: "curve",
  184. width: 2,
  185. activeType: "hollow"
  186. }
  187. }
  188. },
  189. dataListOne: [],
  190. // 入住率
  191. revenueChartDataTwo: {},
  192. revenueOptstwo: {
  193. color: ["#4B98FE"],
  194. padding: [15, 15],
  195. dataLabel: false,
  196. enableScroll: true,
  197. xAxis: {
  198. disableGrid: true,
  199. gridType: "solid",
  200. itemCount: 6,
  201. scrollShow: true,
  202. axisLineColor: "#EFEFEF",
  203. },
  204. legend: {
  205. show: false
  206. },
  207. yAxis: {
  208. gridType: "solid",
  209. gridColor: "#EFEFEF",
  210. dashLength: 2,
  211. data: [{
  212. axisLineColor: "#FFFFFF",
  213. min: 0,
  214. max: 1
  215. }],
  216. },
  217. extra: {
  218. line: {
  219. type: "curve",
  220. width: 2,
  221. activeType: "hollow"
  222. }
  223. }
  224. },
  225. dataListTwo: [],
  226. list: {},
  227. showTime: false,
  228. dateTime: '',
  229. calendar: {
  230. minDate: '',
  231. maxDate: '',
  232. defaultDate: '',
  233. monthNum: 13,
  234. },
  235. }
  236. },
  237. onReady() {
  238. // this.fromData.dateDay = e.detail.value
  239. this.fromData.homestayId = wx.getStorageSync('homestayId')
  240. if (this.fromData.homestayId !== '') {
  241. this.getList()
  242. }
  243. },
  244. onLoad() {
  245. // this.getDays(0)
  246. this.dateTime = new Date().Format('yyyy-MM-dd');
  247. this.fromData.dateDayStart = new Date().Format('yyyy-MM-dd');
  248. this.fromData.dateDayEnd = new Date().Format('yyyy-MM-dd');
  249. this.chooseTimed()
  250. },
  251. methods: {
  252. chooseTimed() {
  253. let date = new Date();
  254. let year = date.getFullYear();
  255. let month = String(date.getMonth() + 3);
  256. let day = String(date.getDate());
  257. month = month.padStart(2, '0');
  258. day = day.padStart(2, '0');
  259. this.calendar.maxDate = year + '-' + month + '-' + day;
  260. // this.calendar.defaultDate = year + '-' + month + '-' + day;
  261. this.calendar.defaultDate = new Date().Format('yyyy-MM-dd');
  262. let nowTime = date.getTime();
  263. let preTime = nowTime - 30 * 24 * 60 * 60 * 1000;
  264. let preDate = new Date(preTime);
  265. let preYear = preDate.getFullYear();
  266. let preMonth = String(preDate.getMonth());
  267. let preDay = String(preDate.getDate());
  268. preMonth = preMonth.padStart(2, '0');
  269. preDay = preDay.padStart(2, '0');
  270. this.calendar.minDate = preYear + '-' + preMonth + '-' + preDay;
  271. console.log(this.calendar);
  272. },
  273. confirm(e) {
  274. console.log(e);
  275. this.showTime = false
  276. this.dateTime = e[0] + '~' + e[e.length - 1]
  277. this.fromData.dateDayStart = e[0]
  278. this.fromData.dateDayEnd = e[e.length - 1]
  279. this.getList()
  280. },
  281. closeDate() {
  282. console.log('456789');
  283. this.showTime = false
  284. },
  285. DateTimes() {
  286. console.log('123456');
  287. this.showTime = true
  288. },
  289. getDays(day) {
  290. var today = new Date();
  291. var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
  292. today.setTime(targetday_milliseconds); //注意,这行是关键代码
  293. var tYear = today.getFullYear();
  294. var tMonth = today.getMonth();
  295. var tDate = today.getDate();
  296. var week = today.getDay();
  297. tMonth = this.doHandleMonth(tMonth + 1);
  298. tDate = this.doHandleMonth(tDate);
  299. console.log('------', tYear + '-' + tMonth);
  300. this.date = tYear + '年' + tMonth + '月'
  301. this.fromData.dateDay = tYear + '-' + tMonth
  302. return tYear + '-' + tMonth
  303. },
  304. doHandleMonth(month) {
  305. var m = month;
  306. if (month.toString().length == 1) {
  307. m = "0" + month;
  308. }
  309. return m;
  310. },
  311. // 时间
  312. startDate() {
  313. return this.getDate('start')
  314. },
  315. endDate() {
  316. return this.getDate('end')
  317. },
  318. getList() {
  319. this.$api.get('/merchant/hotel/mine/getHotelCountInfo', this.fromData).then(res => {
  320. this.list = res.data.data
  321. this.dataListOne = []
  322. this.dataListTwo = []
  323. // 营业概况
  324. this.getServerData();
  325. // 入住率
  326. let x = [],
  327. y = [],
  328. // 交易趋势
  329. x1 = [],
  330. y1 = [];
  331. console.log(res.data)
  332. if (res.data.code === 0) {
  333. this.list = res.data.data;
  334. for (let i = 0; i < res.data.data.checkedInChant.length; i++) {
  335. x.push(res.data.data.checkedInChant[i].dateDay);
  336. y.push(res.data.data.checkedInChant[i].checkedInRatio);
  337. }
  338. for (let i = 0; i < res.data.data.dealLineChant.length; i++) {
  339. x1.push(res.data.data.dealLineChant[i].dateDay);
  340. y1.push(res.data.data.dealLineChant[i].orderAmount);
  341. }
  342. } else {
  343. this.list = []
  344. }
  345. setTimeout(() => {
  346. this.drawRevenueChartstwo(x, y);
  347. this.drawRevenueChartsOne(x1, y1)
  348. }, 500)
  349. })
  350. },
  351. // 环图 营业概况
  352. getServerData() {
  353. this.PieChartsList = this.list
  354. this.PieChartsList = {
  355. series: [{
  356. data: [{
  357. "name": "房费",
  358. "value": this.PieChartsList.roomAmount == null ? '0' : this.PieChartsList
  359. .roomAmount,
  360. "labelText": "房费" + this.PieChartsList.roomRatio + '%'
  361. },
  362. {
  363. "name": "餐饮",
  364. "value": this.PieChartsList.repastAmount == null ? '0' : this.PieChartsList
  365. .repastAmount,
  366. "labelText": "餐饮" + this.PieChartsList.repastRatio + '%'
  367. },
  368. {
  369. "name": "其他",
  370. "value": this.PieChartsList.othersAmount == null ? '0' : this
  371. .PieChartsList.othersAmount,
  372. "labelText": "其他" + this.PieChartsList.othersRatio + '%',
  373. },
  374. ],
  375. }],
  376. }
  377. this.chartDataPied = JSON.parse(JSON.stringify(this.PieChartsList));
  378. },
  379. // 交易趋势
  380. drawRevenueChartsOne(x, y) {
  381. let list1 = {
  382. categories: x,
  383. series: [{
  384. name: "收入",
  385. data: y,
  386. legendShape: "circle",
  387. color: "#4088FE",
  388. pointShape: "none",
  389. }, ],
  390. }
  391. this.revenueChartDataOne = JSON.parse(JSON.stringify(list1));
  392. },
  393. // 入住率
  394. drawRevenueChartstwo(x, y) {
  395. console.log(x);
  396. console.log(y)
  397. let list2 = {
  398. categories: x,
  399. series: [{
  400. name: "入住率",
  401. data: y,
  402. legendShape: "circle",
  403. color: "#600EFF",
  404. pointShape: "none",
  405. }, ],
  406. }
  407. this.revenueChartDataTwo = JSON.parse(JSON.stringify(list2));
  408. },
  409. }
  410. }
  411. </script>
  412. <style lang="scss">
  413. .u-calendar scroll-view {
  414. height: 600rpx !important;
  415. }
  416. .uicon-close {
  417. font-size: 35rpx !important;
  418. z-index: 99999 !important;
  419. }
  420. .u-popup__content__close--top-right {
  421. width: 40rpx !important;
  422. height: 40rpx !important;
  423. z-index: 99999 !important;
  424. }
  425. // .data-v-b73440ae {
  426. // height: 400rpx !important;
  427. // }
  428. // .u-slide-up-enter-active {
  429. // height: 60vh !important;
  430. // }
  431. .u-popup__content {
  432. z-index: 99999 !important;
  433. }
  434. .u-calendar-month__days__day {
  435. height: 100rpx !important;
  436. }
  437. .u-reset-button,
  438. .u-button--active {
  439. width: 100% !important;
  440. }
  441. .chartsview {
  442. z-index: 1 !important;
  443. }
  444. .u-calendar {
  445. z-index: 999 !important;
  446. }
  447. .u-time {
  448. height: 75vh !important;
  449. }
  450. </style>
  451. <style scoped lang="less">
  452. .charts-box {
  453. width: 100%;
  454. height: 630rpx;
  455. }
  456. .page {
  457. background: #F3F4F4;
  458. padding-bottom: 40rpx;
  459. box-sizing: border-box;
  460. // overflow-y: auto;
  461. padding: 20rpx 30rpx;
  462. // height: 100%;
  463. }
  464. .hander {
  465. height: 48rpx;
  466. width: 380rpx;
  467. border-radius: 8rpx;
  468. background-color: #fff;
  469. text-align: center;
  470. line-height: 48rpx;
  471. display: flex !important;
  472. justify-content: space-between !important;
  473. }
  474. .hander-price {
  475. margin-top: 20rpx;
  476. width: 100%;
  477. height: 192rpx;
  478. padding: 30rpx;
  479. box-sizing: border-box;
  480. border-radius: 10rpx;
  481. background-color: #fff;
  482. .one {
  483. display: flex;
  484. justify-content: space-between;
  485. .left {
  486. font-size: 32rpx;
  487. color: #333333;
  488. font-weight: Heavy;
  489. font-family: PingFang SC-Heavy;
  490. }
  491. .right {
  492. font-size: 24rpx;
  493. color: #333333;
  494. font-weight: Regular;
  495. font-family: PingFang SC-Regular;
  496. }
  497. }
  498. .two {
  499. margin-top: 20rpx;
  500. font-size: 48rpx;
  501. color: #1372FF;
  502. font-weight: Heavy;
  503. font-family: PingFang SC-Heavy;
  504. }
  505. }
  506. .echarts-one {
  507. box-sizing: border-box;
  508. width: 100%;
  509. height: 829rpx;
  510. background-color: #fff;
  511. margin: 20rpx 0;
  512. border-radius: 10rpx;
  513. padding: 30rpx;
  514. .title {
  515. font-size: 32rpx;
  516. color: #333333;
  517. font-weight: Heavy;
  518. font-family: PingFang SC-Heavy;
  519. }
  520. .hander-content {
  521. margin-top: 40rpx;
  522. display: flex;
  523. justify-content: space-between;
  524. height: 110rpx;
  525. .title {
  526. font-size: 28rpx;
  527. color: #777777;
  528. font-weight: Regular;
  529. font-family: PingFang SC-Regular;
  530. }
  531. .price {
  532. margin-top: 10rpx;
  533. font-size: 28rpx;
  534. color: #333;
  535. font-weight: Bold;
  536. font-family: PingFang SC-Bold;
  537. }
  538. }
  539. .Pie_charts {
  540. width: 600rpx !important;
  541. height: 560rpx !important;
  542. // background-color: aqua;
  543. }
  544. }
  545. .echarts-two {
  546. box-sizing: border-box;
  547. width: 100%;
  548. height: 543rpx;
  549. background-color: #fff;
  550. margin: 20rpx 0;
  551. border-radius: 10rpx;
  552. padding: 30rpx;
  553. .title {
  554. font-size: 32rpx;
  555. color: #333333;
  556. font-weight: Heavy;
  557. font-family: PingFang SC-Heavy;
  558. }
  559. .title1 {
  560. margin-left: 20rpx;
  561. margin-top: 20rpx;
  562. font-size: 20rpx;
  563. color: #333333;
  564. font-weight: Regular;
  565. font-family: PingFang SC-Regular;
  566. }
  567. .line_charts_one {
  568. width: 630rpx;
  569. height: 388rpx;
  570. // background-color: aqua;
  571. }
  572. }
  573. .echarts-three {
  574. box-sizing: border-box;
  575. width: 100%;
  576. height: 540rpx;
  577. background-color: #fff;
  578. margin: 20rpx 0;
  579. border-radius: 10rpx;
  580. padding: 30rpx;
  581. .title {
  582. font-size: 32rpx;
  583. color: #333333;
  584. font-weight: Heavy;
  585. font-family: PingFang SC-Heavy;
  586. }
  587. .title1 {
  588. margin-left: 20rpx;
  589. margin-top: 20rpx;
  590. font-size: 20rpx;
  591. color: #333333;
  592. font-weight: Regular;
  593. font-family: PingFang SC-Regular;
  594. }
  595. .line_charts_two {
  596. width: 630rpx;
  597. height: 388rpx;
  598. // background-color: aqua;
  599. }
  600. }
  601. </style>