index.vue 12 KB

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