index.vue 12 KB

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