tj.vue 7.8 KB

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