tj.vue 9.4 KB

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