tj.vue 7.8 KB

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