index.vue 12 KB

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