index.vue 12 KB

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