index.vue 13 KB

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