index.vue 12 KB

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