index.vue 13 KB

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