index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  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. },
  272. confirm(e) {
  273. this.showTime = false
  274. this.dateTime = e[0] + '~' + e[e.length - 1]
  275. this.fromData.dateDayStart = e[0]
  276. this.fromData.dateDayEnd = e[e.length - 1]
  277. this.getList()
  278. },
  279. closeDate() {
  280. this.showTime = false
  281. },
  282. DateTimes() {
  283. this.showTime = true
  284. },
  285. getDays(day) {
  286. var today = new Date();
  287. var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
  288. today.setTime(targetday_milliseconds); //注意,这行是关键代码
  289. var tYear = today.getFullYear();
  290. var tMonth = today.getMonth();
  291. var tDate = today.getDate();
  292. var week = today.getDay();
  293. tMonth = this.doHandleMonth(tMonth + 1);
  294. tDate = this.doHandleMonth(tDate);
  295. this.date = tYear + '年' + tMonth + '月'
  296. this.fromData.dateDay = tYear + '-' + tMonth
  297. return tYear + '-' + tMonth
  298. },
  299. doHandleMonth(month) {
  300. var m = month;
  301. if (month.toString().length == 1) {
  302. m = "0" + month;
  303. }
  304. return m;
  305. },
  306. // 时间
  307. startDate() {
  308. return this.getDate('start')
  309. },
  310. endDate() {
  311. return this.getDate('end')
  312. },
  313. getList() {
  314. this.$api.get('/merchant/hotel/mine/getHotelCountInfo', this.fromData).then(res => {
  315. this.list = res.data.data
  316. this.dataListOne = []
  317. this.dataListTwo = []
  318. // 营业概况
  319. this.getServerData();
  320. // 入住率
  321. let x = [],
  322. y = [],
  323. // 交易趋势
  324. x1 = [],
  325. y1 = [];
  326. if (res.data.code === 0) {
  327. this.list = res.data.data;
  328. for (let i = 0; i < res.data.data.checkedInChant.length; i++) {
  329. x.push(res.data.data.checkedInChant[i].dateDay);
  330. y.push(res.data.data.checkedInChant[i].checkedInRatio);
  331. }
  332. for (let i = 0; i < res.data.data.dealLineChant.length; i++) {
  333. x1.push(res.data.data.dealLineChant[i].dateDay);
  334. y1.push(res.data.data.dealLineChant[i].orderAmount);
  335. }
  336. } else {
  337. this.list = []
  338. }
  339. setTimeout(() => {
  340. this.drawRevenueChartstwo(x, y);
  341. this.drawRevenueChartsOne(x1, y1)
  342. }, 500)
  343. })
  344. },
  345. // 环图 营业概况
  346. getServerData() {
  347. this.PieChartsList = this.list
  348. this.PieChartsList = {
  349. series: [{
  350. data: [{
  351. "name": "房费",
  352. "value": this.PieChartsList.roomAmount == null ? '0' : this.PieChartsList
  353. .roomAmount,
  354. "labelText": "房费" + this.PieChartsList.roomRatio + '%'
  355. },
  356. {
  357. "name": "餐饮",
  358. "value": this.PieChartsList.repastAmount == null ? '0' : this.PieChartsList
  359. .repastAmount,
  360. "labelText": "餐饮" + this.PieChartsList.repastRatio + '%'
  361. },
  362. {
  363. "name": "其他",
  364. "value": this.PieChartsList.othersAmount == null ? '0' : this
  365. .PieChartsList.othersAmount,
  366. "labelText": "其他" + this.PieChartsList.othersRatio + '%',
  367. },
  368. ],
  369. }],
  370. }
  371. this.chartDataPied = JSON.parse(JSON.stringify(this.PieChartsList));
  372. },
  373. // 交易趋势
  374. drawRevenueChartsOne(x, y) {
  375. let list1 = {
  376. categories: x,
  377. series: [{
  378. name: "收入",
  379. data: y,
  380. legendShape: "circle",
  381. color: "#4088FE",
  382. pointShape: "none",
  383. }, ],
  384. }
  385. this.revenueChartDataOne = JSON.parse(JSON.stringify(list1));
  386. },
  387. // 入住率
  388. drawRevenueChartstwo(x, y) {
  389. let list2 = {
  390. categories: x,
  391. series: [{
  392. name: "入住率",
  393. data: y,
  394. legendShape: "circle",
  395. color: "#600EFF",
  396. pointShape: "none",
  397. }, ],
  398. }
  399. this.revenueChartDataTwo = JSON.parse(JSON.stringify(list2));
  400. },
  401. }
  402. }
  403. </script>
  404. <style lang="scss">
  405. .u-calendar scroll-view {
  406. height: 600rpx !important;
  407. }
  408. .uicon-close {
  409. font-size: 35rpx !important;
  410. z-index: 99999 !important;
  411. }
  412. .u-popup__content__close--top-right {
  413. width: 40rpx !important;
  414. height: 40rpx !important;
  415. z-index: 99999 !important;
  416. }
  417. .u-popup__content {
  418. z-index: 99999 !important;
  419. }
  420. .u-calendar-month__days__day {
  421. height: 100rpx !important;
  422. }
  423. .u-reset-button,
  424. .u-button--active {
  425. width: 100% !important;
  426. }
  427. .chartsview {
  428. z-index: 1 !important;
  429. }
  430. .u-calendar {
  431. z-index: 999 !important;
  432. }
  433. .u-time {
  434. height: 75vh !important;
  435. }
  436. </style>
  437. <style scoped lang="less">
  438. .charts-box {
  439. width: 100%;
  440. height: 630rpx;
  441. }
  442. .page {
  443. background: #F3F4F4;
  444. padding-bottom: 40rpx;
  445. box-sizing: border-box;
  446. // overflow-y: auto;
  447. padding: 20rpx 30rpx;
  448. // height: 100%;
  449. }
  450. .hander {
  451. height: 48rpx;
  452. width: 380rpx;
  453. border-radius: 8rpx;
  454. background-color: #fff;
  455. text-align: center;
  456. line-height: 48rpx;
  457. display: flex !important;
  458. justify-content: space-between !important;
  459. }
  460. .hander-price {
  461. margin-top: 20rpx;
  462. width: 100%;
  463. height: 192rpx;
  464. padding: 30rpx;
  465. box-sizing: border-box;
  466. border-radius: 10rpx;
  467. background-color: #fff;
  468. .one {
  469. display: flex;
  470. justify-content: space-between;
  471. .left {
  472. font-size: 32rpx;
  473. color: #333333;
  474. font-weight: Heavy;
  475. font-family: PingFang SC-Heavy;
  476. }
  477. .right {
  478. font-size: 24rpx;
  479. color: #333333;
  480. font-weight: Regular;
  481. font-family: PingFang SC-Regular;
  482. }
  483. }
  484. .two {
  485. margin-top: 20rpx;
  486. font-size: 48rpx;
  487. color: #1372FF;
  488. font-weight: Heavy;
  489. font-family: PingFang SC-Heavy;
  490. }
  491. }
  492. .echarts-one {
  493. box-sizing: border-box;
  494. width: 100%;
  495. height: 829rpx;
  496. background-color: #fff;
  497. margin: 20rpx 0;
  498. border-radius: 10rpx;
  499. padding: 30rpx;
  500. .title {
  501. font-size: 32rpx;
  502. color: #333333;
  503. font-weight: Heavy;
  504. font-family: PingFang SC-Heavy;
  505. }
  506. .hander-content {
  507. margin-top: 40rpx;
  508. display: flex;
  509. justify-content: space-between;
  510. height: 110rpx;
  511. .title {
  512. font-size: 28rpx;
  513. color: #777777;
  514. font-weight: Regular;
  515. font-family: PingFang SC-Regular;
  516. }
  517. .price {
  518. margin-top: 10rpx;
  519. font-size: 28rpx;
  520. color: #333;
  521. font-weight: Bold;
  522. font-family: PingFang SC-Bold;
  523. }
  524. }
  525. .Pie_charts {
  526. width: 600rpx !important;
  527. height: 560rpx !important;
  528. // background-color: aqua;
  529. }
  530. }
  531. .echarts-two {
  532. box-sizing: border-box;
  533. width: 100%;
  534. height: 543rpx;
  535. background-color: #fff;
  536. margin: 20rpx 0;
  537. border-radius: 10rpx;
  538. padding: 30rpx;
  539. .title {
  540. font-size: 32rpx;
  541. color: #333333;
  542. font-weight: Heavy;
  543. font-family: PingFang SC-Heavy;
  544. }
  545. .title1 {
  546. margin-left: 20rpx;
  547. margin-top: 20rpx;
  548. font-size: 20rpx;
  549. color: #333333;
  550. font-weight: Regular;
  551. font-family: PingFang SC-Regular;
  552. }
  553. .line_charts_one {
  554. width: 630rpx;
  555. height: 388rpx;
  556. // background-color: aqua;
  557. }
  558. }
  559. .echarts-three {
  560. box-sizing: border-box;
  561. width: 100%;
  562. height: 540rpx;
  563. background-color: #fff;
  564. margin: 20rpx 0;
  565. border-radius: 10rpx;
  566. padding: 30rpx;
  567. .title {
  568. font-size: 32rpx;
  569. color: #333333;
  570. font-weight: Heavy;
  571. font-family: PingFang SC-Heavy;
  572. }
  573. .title1 {
  574. margin-left: 20rpx;
  575. margin-top: 20rpx;
  576. font-size: 20rpx;
  577. color: #333333;
  578. font-weight: Regular;
  579. font-family: PingFang SC-Regular;
  580. }
  581. .line_charts_two {
  582. width: 630rpx;
  583. height: 388rpx;
  584. // background-color: aqua;
  585. }
  586. }
  587. </style>