tj.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <template>
  2. <view :style="{'min-height':(h-th)+'px','padding-top':mt+'px'}" :class="type==2?'year page tt':'page tt'">
  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/api/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. merchantId: 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. .year .u-picker__view__column:last-child {
  265. display:none;
  266. }
  267. </style>
  268. <style scoped lang="less">
  269. /deep/.visibleItemCount {
  270. z-index: 99999999999;
  271. }
  272. .tt {
  273. /deep/.u-picker__view__column {
  274. width: 100%;
  275. }
  276. }
  277. .line_charts_two {
  278. width: 100%;
  279. height: 500rpx;
  280. // background-color: aqua;
  281. }
  282. .page {
  283. background: #F5F8FA;
  284. box-sizing: border-box;
  285. width: 100%;
  286. overflow-x: hidden;
  287. .total {
  288. margin: 36rpx;
  289. display: flex;
  290. align-items: center;
  291. &>view {
  292. position: relative;
  293. color: #777;
  294. margin-right: 80rpx;
  295. font-size: 26rpx;
  296. padding-left: 30rpx;
  297. &.t1 {
  298. &::after {
  299. position: absolute;
  300. left: 0;
  301. top: 43%;
  302. z-index: 1;
  303. display: inline-block;
  304. content: "";
  305. width: 20rpx;
  306. height: 10rpx;
  307. border-radius: 10rpx;
  308. background-color: #367BFF;
  309. }
  310. }
  311. &.t2 {
  312. &::after {
  313. position: absolute;
  314. left: 0;
  315. top: 43%;
  316. z-index: 1;
  317. display: inline-block;
  318. content: "";
  319. width: 20rpx;
  320. height: 10rpx;
  321. border-radius: 10rpx;
  322. background-color: #77DFDD;
  323. }
  324. }
  325. text {
  326. color: #111;
  327. font-size: 28rpx;
  328. }
  329. }
  330. }
  331. }
  332. .chart {
  333. width: calc(100% - 40rpx);
  334. border-radius: 16rpx;
  335. padding: 36rpx 22rpx;
  336. background-color: #fff;
  337. margin: 20rpx auto 0;
  338. .tit {
  339. font-size: 28rpx;
  340. font-weight: bold;
  341. }
  342. }
  343. .tabs {
  344. text-align: center;
  345. border-bottom: 1rpx solid #EFEFEF;
  346. background-color: #fff;
  347. display: flex;
  348. text {
  349. display: inline-block;
  350. padding: 28rpx;
  351. width: 50%;
  352. position: relative;
  353. font-size: 32rpx;
  354. &.on::after {
  355. display: block;
  356. content: '';
  357. position: absolute;
  358. width: 64rpx;
  359. height: 6rpx;
  360. background-color: #007A69;
  361. bottom: 8rpx;
  362. z-index: 1;
  363. left: 50%;
  364. border-radius: 4rpx;
  365. transform: translate(-50%, 0);
  366. }
  367. }
  368. }
  369. .content {
  370. padding: 48rpx 30rpx 56rpx;
  371. background-color: #fff;
  372. .time {
  373. display: flex;
  374. align-items: center;
  375. margin-bottom: 42rpx;
  376. }
  377. .money {
  378. display: flex;
  379. align-items: center;
  380. padding: 0 10rpx;
  381. &>view {
  382. width: 50%;
  383. text {
  384. display: block;
  385. font-weight: bold;
  386. &:first-child {
  387. color: #111;
  388. font-size: 28rpx;
  389. font-weight: inherit;
  390. }
  391. &:nth-child(2) {
  392. font-size: 40rpx;
  393. margin: 14rpx 0 16rpx;
  394. color: #111;
  395. }
  396. &:last-child {
  397. color: #999;
  398. font-size: 26rpx;
  399. font-weight: inherit;
  400. }
  401. }
  402. }
  403. }
  404. .in {
  405. color: #FEA400!important;
  406. }
  407. }
  408. </style>