index.vue 14 KB

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