tj.vue 7.5 KB

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