tj.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <template>
  2. <view class="page tt" :style="{'min-height':(h-th)+'px','padding-top':mt+'px'}">
  3. <c-nav-bar title="数据统计"></c-nav-bar>
  4. <view class="tabs">
  5. <text :class="type==1?'on':''" @click="type=1">月账单</text>
  6. <text :class="type==2?'on':''" @click="type=2">年账单</text>
  7. </view>
  8. <view class="content">
  9. <view class="time" @click="show=true">
  10. <u-icon name="calendar" :label="dateStr" labelPos="right" labelColor="#666" color="#666" space="7px"
  11. size="25px"></u-icon>
  12. <u-icon name="arrow-down" color="#999" size="20px" style="margin-left: 20rpx;"></u-icon>
  13. </view>
  14. <view class="money">
  15. <view>
  16. <text>收入金额</text>
  17. <text class="in">+{{info.allOrderAmount||0}}</text>
  18. <text>{{info.allOrders||0}}笔</text>
  19. </view>
  20. <view>
  21. <text>退款金额</text>
  22. <text>{{info.allRefundOrderAmount||0}}</text>
  23. <text>{{info.allRefundOrders||0}}笔</text>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="chart">
  28. <view class="tit">累计曲线图</view>
  29. <view class="total">
  30. <view class="t1">总收入<text>{{total}}</text></view>
  31. <view class="t2">总退款<text>{{total2}}</text></view>
  32. </view>
  33. <view class="line_charts_two">
  34. <qiun-data-charts type="line" canvas2d='true' style="z-index: 1;" :opts="gameOpts"
  35. :chartData="gameChartData" :ontouch="true" />
  36. </view>
  37. </view>
  38. <u-datetime-picker @confirm="confirmDate" @cancel="show=false" :show="show" v-model="value1"
  39. visibleItemCount="6" mode="year-month"></u-datetime-picker>
  40. </view>
  41. </template>
  42. <script>
  43. import {
  44. data
  45. } from '../../uni_modules/uview-ui/libs/mixin/mixin';
  46. export default {
  47. data() {
  48. return {
  49. merchantId: uni.getStorageSync('merchantId'),
  50. merchantType: uni.getStorageSync('merchantType'),
  51. total: '',
  52. total2: '',
  53. info: {
  54. allOrderAmount: 0,
  55. allOrders: 0,
  56. allRefundOrderAmount: 0,
  57. allRefundOrders: 0
  58. },
  59. show: false,
  60. value1: Number(new Date()),
  61. dateStr: new Date().Format('yyyy年-MM月'),
  62. date: new Date().Format('yyyy-MM'),
  63. dataList: [],
  64. type: 1,
  65. gameChartData: {},
  66. gameOpts: {
  67. color: ["#4B98FE", "#00D05E"],
  68. padding: [15, 15, 0, 15],
  69. enableScroll: true,
  70. legend: {
  71. show: false
  72. },
  73. xAxis: {
  74. disableGrid: true,
  75. gridType: "solid",
  76. itemCount: 6,
  77. scrollColor: "#f44",
  78. scrollShow: true,
  79. axisLineColor: "#EFEFEF",
  80. },
  81. yAxis: {
  82. gridType: "solid",
  83. gridColor: "#EFEFEF",
  84. dashLength: 2
  85. },
  86. extra: {
  87. line: {
  88. type: "curve",
  89. width: 2,
  90. activeType: "hollow"
  91. }
  92. }
  93. },
  94. }
  95. },
  96. watch: {
  97. type(newval, oldval) {
  98. if (newval == 1) {
  99. this.date = new Date().Format('yyyy-MM');
  100. this.dateStr = this.date.split('-')[0] + '年' + '-' + this.date.split('-')[1] + '月';
  101. } else {
  102. this.date = new Date().Format('yyyy');
  103. this.dateStr = this.date + '年';
  104. }
  105. },
  106. date(newval, oldval) {
  107. if (newval != oldval) {
  108. if (this.merchantType == 10) {
  109. this.getList()
  110. } else {
  111. this.gettopData();
  112. this.getBottomData();
  113. }
  114. }
  115. }
  116. },
  117. onLoad() {
  118. if (this.merchantType == 10) {
  119. this.getList()
  120. } else {
  121. this.gettopData();
  122. this.getBottomData();
  123. }
  124. //this.drawGameCharts(['1','2'], [11,2], [12.11]);
  125. },
  126. methods: {
  127. confirmDate(e) {
  128. // //调起时间弹出弹窗时候用
  129. // var pickerSlot = document.getElementsByClassName('picker-slot');
  130. // pickerSlot[1].style.display = 'none'
  131. // pickerSlot[2].style.display = 'none'
  132. // 创建一个Date对象并传入时间戳
  133. const date = new Date(e.value);
  134. // 使用Date对象的方法获取年、月、日、小时、分钟和秒
  135. const year = date.getFullYear();
  136. const month = ('0' + (date.getMonth() + 1)).slice(-2);
  137. const day = ('0' + date.getDate()).slice(-2);
  138. // 格式化时间
  139. let formattedTime = "";
  140. if (this.type == 1) {
  141. formattedTime = `${year}-${month}`;
  142. this.dateStr = `${year}年-${month}月`
  143. } else {
  144. formattedTime = `${year}`;
  145. this.dateStr = `${year}年`
  146. }
  147. this.date = formattedTime;
  148. this.show = false;
  149. },
  150. //渔家乐
  151. getList() {
  152. this.$api.post('/scenic/order/dataStatistics', {
  153. dateTime: this.date,
  154. dateType: this.type + '',
  155. merchantId: uni.getStorageSync('merchantId')
  156. }).then(res => {
  157. let x = [],
  158. y = [],
  159. z = [];
  160. this.total = 0;
  161. this.total2 = 0;
  162. if (res.data.code === 0) {
  163. this.info = res.data.data;
  164. this.info.allOrderAmount = res.data.data.statistics.allOrderAmount;
  165. this.info.allOrders = res.data.data.statistics.allOrders,
  166. this.info.allRefundOrderAmount = res.data.data.statistics.allRefundOrderAmount,
  167. this.info.allRefundOrders = res.data.data.statistics.allRefundOrders
  168. //折线图
  169. this.dataList = res.data.data.curve;
  170. for (let i = 0; i < res.data.data.curve.length; i++) {
  171. x.push(this.type == 1 ? res.data.data.curve[i].dateKey : (res.data.data.curve[i]
  172. .dateKey + '月'));
  173. y.push(res.data.data.curve[i].orderNums);
  174. z.push(res.data.data.curve[i].refundOrderNums);
  175. this.total += res.data.data.curve[i].orderNums;
  176. this.total2 += res.data.data.curve[i].refundOrderNums
  177. }
  178. } else {
  179. this.info = {
  180. paymentAmount: 0,
  181. paymentCount: 0,
  182. refundAmount: 0,
  183. refundCount: 0,
  184. }
  185. }
  186. setTimeout(() => {
  187. this.drawGameCharts(x, y, z);
  188. }, 500)
  189. })
  190. },
  191. gettopData() {
  192. this.$api.post('/api/merchant/food/getMerchantFoodBill', {
  193. dateTime: this.date,
  194. dateType: this.type + '',
  195. fishermanId: uni.getStorageSync('merchantId')
  196. }).then(res => {
  197. if (res.data.code === 0) {
  198. this.info = res.data.data;
  199. } else {
  200. this.info = {
  201. allOrderAmount: 0,
  202. allOrders: 0,
  203. allRefundOrderAmount: 0,
  204. allRefundOrders: 0
  205. }
  206. }
  207. })
  208. },
  209. getBottomData() {
  210. this.$api.post('/api/merchant/food/getMerchantFoodCurveAnalyse', {
  211. dateTime: this.date,
  212. dateType: this.type + '',
  213. merchantId: uni.getStorageSync('merchantId')
  214. }).then(res => {
  215. let x = [],
  216. y = [],
  217. z = [];
  218. this.total = 0;
  219. this.total2 = 0;
  220. if (res.data.code === 0) {
  221. this.dataList = res.data.data;
  222. for (let i = 0; i < res.data.data.length; i++) {
  223. x.push(this.type == 1 ? res.data.data[i].dateKey : (res.data.data[i].dateKey + '月'));
  224. y.push(res.data.data[i].orderNums);
  225. z.push(res.data.data[i].refundOrderNums);
  226. this.total += res.data.data[i].orderNums;
  227. this.total2 += res.data.data[i].refundOrderNums
  228. }
  229. } else {
  230. this.dataList = []
  231. }
  232. setTimeout(() => {
  233. this.drawGameCharts(x, y, z);
  234. }, 500)
  235. })
  236. },
  237. drawGameCharts(x, y, z) {
  238. let res = {
  239. categories: x,
  240. series: [{
  241. name: "总收入",
  242. data: y,
  243. color: "#367BFF",
  244. },
  245. {
  246. name: "总退款",
  247. data: z,
  248. color: "#77DFDD",
  249. },
  250. ],
  251. };
  252. this.gameChartData = JSON.parse(JSON.stringify(res));
  253. },
  254. }
  255. }
  256. </script>
  257. <style lang="scss">
  258. .u-popup__content {
  259. z-index: 99999999 !important;
  260. }
  261. .u-transition {
  262. z-index: 99999998 !important;
  263. }
  264. // .yearPicker {
  265. // .picker-items {
  266. // .picker-slot:nth-child(2),
  267. // .picker-slot:nth-child(3) {
  268. // display: none;
  269. // }
  270. // }
  271. // }
  272. </style>
  273. <style scoped lang="less">
  274. /deep/.visibleItemCount {
  275. z-index: 99999999999;
  276. }
  277. .tt {
  278. /deep/.u-picker__view__column {
  279. width: 100%;
  280. }
  281. }
  282. .line_charts_two {
  283. width: 100%;
  284. height: 500rpx;
  285. // background-color: aqua;
  286. }
  287. .page {
  288. background: #F5F8FA;
  289. box-sizing: border-box;
  290. width: 100%;
  291. overflow-x: hidden;
  292. .total {
  293. margin: 36rpx;
  294. display: flex;
  295. align-items: center;
  296. &>view {
  297. position: relative;
  298. color: #777;
  299. margin-right: 80rpx;
  300. font-size: 26rpx;
  301. padding-left: 30rpx;
  302. &.t1 {
  303. &::after {
  304. position: absolute;
  305. left: 0;
  306. top: 43%;
  307. z-index: 1;
  308. display: inline-block;
  309. content: "";
  310. width: 20rpx;
  311. height: 10rpx;
  312. border-radius: 10rpx;
  313. background-color: #367BFF;
  314. }
  315. }
  316. &.t2 {
  317. &::after {
  318. position: absolute;
  319. left: 0;
  320. top: 43%;
  321. z-index: 1;
  322. display: inline-block;
  323. content: "";
  324. width: 20rpx;
  325. height: 10rpx;
  326. border-radius: 10rpx;
  327. background-color: #77DFDD;
  328. }
  329. }
  330. text {
  331. color: #111;
  332. font-size: 28rpx;
  333. }
  334. }
  335. }
  336. }
  337. .chart {
  338. width: calc(100% - 40rpx);
  339. border-radius: 16rpx;
  340. padding: 36rpx 22rpx;
  341. background-color: #fff;
  342. margin: 20rpx auto 0;
  343. .tit {
  344. font-size: 28rpx;
  345. font-weight: bold;
  346. }
  347. }
  348. .tabs {
  349. text-align: center;
  350. border-bottom: 1rpx solid #EFEFEF;
  351. background-color: #fff;
  352. display: flex;
  353. text {
  354. display: inline-block;
  355. padding: 28rpx;
  356. width: 50%;
  357. position: relative;
  358. font-size: 32rpx;
  359. &.on::after {
  360. display: block;
  361. content: '';
  362. position: absolute;
  363. width: 64rpx;
  364. height: 6rpx;
  365. background-color: #007A69;
  366. bottom: 8rpx;
  367. z-index: 1;
  368. left: 50%;
  369. border-radius: 4rpx;
  370. transform: translate(-50%, 0);
  371. }
  372. }
  373. }
  374. .content {
  375. padding: 48rpx 30rpx 56rpx;
  376. background-color: #fff;
  377. .time {
  378. display: flex;
  379. align-items: center;
  380. margin-bottom: 42rpx;
  381. }
  382. .money {
  383. display: flex;
  384. align-items: center;
  385. padding: 0 10rpx;
  386. &>view {
  387. width: 50%;
  388. text {
  389. display: block;
  390. font-weight: bold;
  391. &:first-child {
  392. color: #111;
  393. font-size: 28rpx;
  394. font-weight: inherit;
  395. }
  396. &:nth-child(2) {
  397. font-size: 40rpx;
  398. margin: 14rpx 0 16rpx;
  399. color: #111;
  400. }
  401. &:last-child {
  402. color: #999;
  403. font-size: 26rpx;
  404. font-weight: inherit;
  405. }
  406. }
  407. .in {
  408. color: #FEA400;
  409. }
  410. }
  411. }
  412. }
  413. </style>