index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. <template>
  2. <div class="statistical-page" ref="container">
  3. <div class="navs">
  4. <div class="list">
  5. <div class="item" :class="time == 'today' ? 'on' : ''" @click="setTime('today')">今天</div>
  6. <div class="item" :class="time == 'yesterday' ? 'on' : ''" @click="setTime('yesterday')">昨天</div>
  7. <div class="item" :class="time == 'seven' ? 'on' : ''" @click="setTime('seven')">最近7天</div>
  8. <div class="item" :class="time == 'month' ? 'on' : ''" @click="setTime('month')">本月</div>
  9. <div class="item" :class="time == 'date' ? 'on' : ''" @click="dateTitle">自定义</div>
  10. </div>
  11. </div>
  12. <div class="wrapper" v-if="datalist">
  13. <div class="title">
  14. <span v-if="type == 1">{{ time == 'date'?'':title }}配送订单(元)</span>
  15. <span v-if="type == 2">{{ time == 'date'?'':title }}配送订单(单)</span>
  16. <span v-if="type == 3">{{ time == 'date'?'':title }}退款订单(元)</span>
  17. <span v-if="type == 4">{{ time == 'date'?'':title }}收银订单(元)</span>
  18. <span v-if="type == 5">{{ time == 'date'?'':title }}核销订单(元)</span>
  19. <span v-if="type == 6">{{ time == 'date'?'':title }}付费会员(元)</span>
  20. <span v-if="type == 7">{{ time == 'date'?'':title }}充值订单(元)</span>
  21. <span v-if="type == 8">{{ time == 'date'?'':title }}推广用户量(人)</span>
  22. <span v-if="type == 9">{{ time == 'date'?'':title }}激活会员卡(张)</span>
  23. <!-- {{ time == 'date'?'':title }}{{ this.where.type == 1 ? "营业额(元)" : "订单量(份)" }} -->
  24. </div>
  25. <div class="money">{{cardData.data.now}}</div>
  26. <div class="increase acea-row row-between-wrapper">
  27. <div>
  28. {{ time == 'date'?'':title }}增长率:<span :class="cardData.data.increase_time_status === 1 ? 'red' : 'green'">{{ cardData.data.growth }}%
  29. <span class="iconfont" :class="
  30. cardData.data.increase_time_status === 1
  31. ? 'icon-xiangshang1'
  32. : 'icon-xiangxia2'
  33. "></span></span>
  34. </div>
  35. <div>
  36. {{ time == 'date'?'':title }}增长:<span :class="cardData.data.increase_time_status === 1 ? 'red' : 'green'">{{ cardData.data.differ }}
  37. <span class="iconfont" :class="
  38. cardData.data.increase_time_status === 1
  39. ? 'icon-xiangshang1'
  40. : 'icon-xiangxia2'
  41. "></span></span>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="public-wrapper">
  46. <div class="conter">
  47. <div class="item" v-for="(item, index) in cardData.list" :key="index">
  48. <div v-if="type == 8">
  49. <div class="datas">
  50. <div class="number_leftbox">
  51. <image :src="item.avatar" mode=""></image>
  52. <div class="number_font">
  53. <div >{{ item.nickname }}</div>
  54. <div class="times">加入时间:{{ item.spread_time }}</div>
  55. </div>
  56. </div>
  57. <div class="number_rightbox">
  58. <div>{{ item.order_count }} 单</div>
  59. <div>{{ item.order_price }} 元</div>
  60. </div>
  61. </div>
  62. </div>
  63. <div v-else-if="type == 9">
  64. <div class="data">
  65. <div class="leftbox">
  66. <image :src="item.avatar" mode=""></image>
  67. <span>{{ item.nickname }}</span>
  68. </div>
  69. <div >微信会员卡</div>
  70. </div>
  71. <div class="times">激活时间:{{ item.add_time }}</div>
  72. </div>
  73. <div v-else>
  74. <div class="data">
  75. <div class="leftbox">
  76. <image :src="item.uid?item.avatar:'../../static/yonghu.png'" mode=""></image>
  77. <span>{{ item.uid?item.nickname:'游客' }}</span>
  78. </div>
  79. <div v-if="type == 7">{{ item.price }} 元</div>
  80. <div v-else>{{ item.pay_price }} 元</div>
  81. </div>
  82. <div class="times">订单编号66:{{ item.order_id }}</div>
  83. <div class="times">下单时间:{{ item.add_time }}</div>
  84. </div>
  85. <!-- <div v-else-if="where.type == 6"> -->
  86. </div>
  87. </div>
  88. </div>
  89. <!-- #ifdef H5 || APP-PLUS -->
  90. <uni-calendar ref="calendar" :date="info.date" :insert="info.insert" :lunar="info.lunar" :startDate="info.startDate" :endDate="info.endDate" :range="info.range" @confirm="confirm" :showMonth="info.showMonth" />
  91. <div class="mask" @touchmove.prevent v-show="current === true" @click="close"></div>
  92. <!-- #endif -->
  93. <Loading :loaded="loaded" :loading="loading"></Loading>
  94. </div>
  95. </template>
  96. <script>
  97. import Loading from '@/components/Loading/index.vue'
  98. import uniCalendar from '@/components/uni-calendar/uni-calendar.vue'
  99. var canvaLineA = null;
  100. import {
  101. getStatisticsListApi
  102. } from "@/api/admin";
  103. const year = new Date().getFullYear();
  104. const month = new Date().getMonth() + 1;
  105. const day = new Date().getDate();
  106. export default {
  107. name: "Statistics",
  108. components: {
  109. uniCalendar,
  110. Loading
  111. },
  112. props: {},
  113. data: function() {
  114. return {
  115. cardData: {
  116. data:[],
  117. list:[]
  118. },
  119. datalist: false,
  120. tip: 1,
  121. value: [
  122. [year, month, day - 1],
  123. [year, month, day]
  124. ],
  125. isrange: true,
  126. weekSwitch: false,
  127. ismulti: false,
  128. monFirst: true,
  129. clean: false, //简洁模式
  130. lunar: false, //显示农历
  131. renderValues: [],
  132. monthRange: [],
  133. current: false,
  134. where: {
  135. start: "",
  136. stop: "",
  137. is_manager: "",
  138. page: 1,
  139. limit: 15,
  140. },
  141. types: "", //类型|order=订单数|price=营业额
  142. time: "today", //时间|today=今天|yesterday=昨天|month=本月
  143. title: "", //时间|today=今天|yesterday=昨天|month=本月
  144. loaded: false,
  145. loading: false,
  146. list: [],
  147. // charts
  148. cWidth: '',
  149. cHeight: '',
  150. "LineA": {
  151. "categories": ["2012", "2013", "2014", "2015", "2016", "2017"],
  152. "series": [{
  153. "data": [35, 8, 25, 37, 4, 20]
  154. }]
  155. },
  156. info: {
  157. startDate: '',
  158. endDate: '',
  159. lunar: false,
  160. range: true,
  161. insert: false,
  162. selected: [],
  163. showMonth:false
  164. },
  165. type: '',
  166. before: '',
  167. after: ''
  168. };
  169. },
  170. // watch: {
  171. // "$route.params": function(newVal) {
  172. // var that = this;
  173. // if (newVal != undefined) {
  174. // that.setType(newVal.type);
  175. // }
  176. // }
  177. // },
  178. onLoad: function(options) {
  179. this.type = options.type;
  180. if (options.before) {
  181. this.before = options.before;
  182. }
  183. if (options.after) {
  184. this.after = options.after;
  185. }
  186. if(options.manager){
  187. this.where.is_manager = options.manager
  188. }
  189. this.cWidth = uni.upx2px(690);
  190. this.cHeight = uni.upx2px(500);
  191. this.setTime(options.time);
  192. },
  193. methods: {
  194. getList(){
  195. this.loading = true;
  196. getStatisticsListApi(this.type,this.where).then(res=>{
  197. this.cardData.data = res.data.data
  198. this.datalist = true
  199. this.where.page += 1;
  200. this.loading = false;
  201. this.cardData.list = this.cardData.list.concat(res.data.list);
  202. if(res.data.list.length < this.where.limit){
  203. this.tip = 2
  204. }
  205. })
  206. },
  207. setTime: function(time) {
  208. let self = this
  209. this.time = time;
  210. var year = new Date().getFullYear(),
  211. month = new Date().getMonth() + 1,
  212. day = new Date().getDate();
  213. this.list = [];
  214. this.tip = 1,
  215. this.cardData = {
  216. data:[],
  217. list:[]
  218. }
  219. this.where.page = 1;
  220. this.loaded = false;
  221. this.loading = false;
  222. switch (time) {
  223. case "today":
  224. this.where.start =
  225. new Date(Date.parse(year + "/" + month + "/" + day)).getTime() /
  226. 1000;
  227. this.where.stop =
  228. new Date(Date.parse(year + "/" + month + "/" + day)).getTime() /
  229. 1000 +
  230. 24 * 60 * 60 -
  231. 1;
  232. this.title = "今日";
  233. this.getList()
  234. break;
  235. case "yesterday":
  236. this.where.start =
  237. new Date(Date.parse(year + "/" + month + "/" + day)).getTime() /
  238. 1000 -
  239. 24 * 60 * 60;
  240. this.where.stop =
  241. new Date(Date.parse(year + "/" + month + "/" + day)).getTime() /
  242. 1000 -
  243. 1;
  244. this.title = "昨日";
  245. this.getList()
  246. break;
  247. case "month":
  248. this.where.start =
  249. new Date(year, new Date().getMonth(), 1).getTime() / 1000;
  250. this.where.stop = new Date(year, month, 1).getTime() / 1000 - 1;
  251. this.title = "本月";
  252. this.getList()
  253. break;
  254. case "seven":
  255. this.where.start =
  256. new Date(Date.parse(year + "/" + month + "/" + day)).getTime() /
  257. 1000 +
  258. 24 * 60 * 60 -
  259. 7 * 3600 * 24;
  260. this.where.stop =
  261. new Date(Date.parse(year + "/" + month + "/" + day)).getTime() /
  262. 1000 +
  263. 24 * 60 * 60 -
  264. 1;
  265. this.title = "七日";
  266. this.getList()
  267. break;
  268. // #ifdef MP
  269. case "date":
  270. let star = new Date(self.before).getTime()/1000
  271. let stop = new Date(self.after).getTime()/1000
  272. self.where.start = star
  273. self.where.stop = stop
  274. Promise.all([self.getList()]);
  275. break;
  276. // #endif
  277. }
  278. },
  279. dateTitle: function() {
  280. // #ifdef H5 || APP-PLUS
  281. this.$refs.calendar.open()
  282. this.time = 'date'
  283. // #endif
  284. // #ifdef MP
  285. uni.navigateTo({
  286. url: '/pages/admin/store/custom_date/index?type=' + this.type
  287. });
  288. // #endif
  289. // this.current = true;
  290. },
  291. close: function() {
  292. this.current = false;
  293. },
  294. // 日历确定
  295. confirm(e) {
  296. let self = this
  297. let star,stop;
  298. if(e.range.after && e.range.before){
  299. if(e.range.before>e.range.after){
  300. star = new Date(e.range.after+' 00:00:00').getTime()/1000
  301. stop = new Date(e.range.before+' 23:59:59').getTime()/1000
  302. }else{
  303. star = new Date(e.range.before+' 00:00:00').getTime()/1000
  304. stop = new Date(e.range.after+' 23:59:59').getTime()/1000
  305. }
  306. self.where.start = star
  307. self.where.stop = stop
  308. self.list = [];
  309. self.cardData.list = [];
  310. // self.tip =1
  311. self.where.page = 1;
  312. self.loaded = false;
  313. self.loading = false;
  314. Promise.all([self.getList()]);
  315. }
  316. },
  317. },
  318. onReachBottom() {
  319. if(this.tip == 1){
  320. this.getList()
  321. }
  322. }
  323. };
  324. </script>
  325. <style lang="scss" scoped>
  326. /*交易额统计*/
  327. .statistical-page .navs {
  328. width: 100%;
  329. height: 96upx;
  330. background-color: #fff;
  331. overflow: hidden;
  332. line-height: 96upx;
  333. position: fixed;
  334. top: 0;
  335. left: 0;
  336. z-index: 9;
  337. }
  338. .statistical-page .navs .list {
  339. overflow-y: hidden;
  340. overflow-x: auto;
  341. white-space: nowrap;
  342. -webkit-overflow-scrolling: touch;
  343. width: 100%;
  344. }
  345. .statistical-page .navs .item {
  346. font-size: 32upx;
  347. color: #282828;
  348. margin-left: 60upx;
  349. display: inline-block;
  350. }
  351. .statistical-page .navs .item.on {
  352. color: #2291f8;
  353. }
  354. .statistical-page .navs .item .iconfont {
  355. font-size: 25upx;
  356. margin-left: 13upx;
  357. }
  358. .statistical-page .wrapper {
  359. // width: 740upx;
  360. background-color: #fff;
  361. border-radius: 10upx;
  362. margin: 119upx 30upx 0 30upx;
  363. padding: 50upx 30upx;
  364. }
  365. .statistical-page .wrapper .title {
  366. font-size: 30upx;
  367. color: #999;
  368. text-align: center;
  369. }
  370. .statistical-page .wrapper .money {
  371. font-size: 72upx;
  372. color: #1890FF;
  373. text-align: center;
  374. margin-top: 10upx;
  375. }
  376. .statistical-page .wrapper .increase {
  377. font-size: 28upx;
  378. color: #999;
  379. margin-top: 20upx;
  380. }
  381. .statistical-page .wrapper .increase .red {
  382. color: #ff6969;
  383. }
  384. .statistical-page .wrapper .increase .green {
  385. color: #1abb1d;
  386. }
  387. .statistical-page .wrapper .increase .iconfont {
  388. font-size: 23upx;
  389. margin-left: 15upx;
  390. }
  391. .statistical-page .chart {
  392. width: 690upx;
  393. background-color: #fff;
  394. border-radius: 10upx;
  395. margin: 23upx auto 0 auto;
  396. /* padding: 25upx 22upx 0 22upx; */
  397. }
  398. .statistical-page .chart .chart-title{
  399. padding:20upx 20upx 10upx;
  400. font-size: 26upx;
  401. color: #999;
  402. }
  403. .statistical-page .chart canvas {
  404. width: 100%;
  405. height: 530rpx;
  406. }
  407. .statistical-page .chart .company {
  408. font-size: 26upx;
  409. color: #999;
  410. }
  411. .yd-confirm {
  412. background-color: #fff;
  413. font-size: unset;
  414. width: 540upx;
  415. height: 250upx;
  416. border-radius: 40upx;
  417. }
  418. .yd-confirm-hd {
  419. text-align: center;
  420. }
  421. .yd-confirm-title {
  422. color: #030303;
  423. font-weight: bold;
  424. font-size: 36upx;
  425. }
  426. .yd-confirm-bd {
  427. text-align: center;
  428. font-size: 28upx;
  429. color: #333333;
  430. }
  431. .yd-confirm-ft {
  432. line-height: 90upx;
  433. margin-top: 14px;
  434. border-top: 1upx solid #eee;
  435. }
  436. .yd-confirm-ft>a {
  437. color: #e93323;
  438. }
  439. .yd-confirm-ft>a.primary {
  440. border-left: 1upx solid #eee;
  441. color: #e93323;
  442. }
  443. .calendar-wrapper {
  444. position: fixed;
  445. bottom: 0;
  446. left: 0;
  447. width: 100%;
  448. z-index: 777;
  449. transform: translate3d(0, 100%, 0);
  450. transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  451. }
  452. .calendar-wrapper.on {
  453. transform: translate3d(0, 0, 0);
  454. }
  455. .statistical-page .wrapper .increase {
  456. font-size: 24upx;
  457. }
  458. .statistical-page .wrapper .increase .iconfont {
  459. margin-left: 0;
  460. }
  461. .public-wrapper .title {
  462. font-size: 30upx;
  463. color: #282828;
  464. padding: 0 30upx;
  465. margin-bottom: 20upx;
  466. }
  467. .public-wrapper .title .iconfont {
  468. color: #2291f8;
  469. font-size: 40upx;
  470. margin-right: 13upx;
  471. vertical-align: middle;
  472. }
  473. .public-wrapper {
  474. margin: 18upx auto 0 auto;
  475. width: 690upx;
  476. background-color: #fff;
  477. border-radius: 10upx;
  478. // padding-top: 25upx;
  479. }
  480. .public-wrapper .conter {
  481. padding: 0 30upx;
  482. }
  483. .public-wrapper .conter .item {
  484. border-bottom: 2upx solid #f7f7f7;
  485. // height: 194upx;
  486. font-size: 24upx;
  487. display: flex;
  488. flex-direction: column;
  489. padding: 30upx 0upx;
  490. .times{
  491. color: #999999;
  492. margin-bottom: 8upx;
  493. }
  494. .data{
  495. display: flex;
  496. justify-content: space-between;
  497. align-items: center;
  498. margin-bottom: 18upx;
  499. .leftbox{
  500. display: flex;
  501. align-items: center;
  502. font-weight: 400;
  503. color: #000000;
  504. image{
  505. width: 46upx;
  506. height: 46upx;
  507. border-radius: 50%;
  508. margin-right: 20upx;
  509. }
  510. }
  511. }
  512. .datas{
  513. display: flex;
  514. justify-content: space-between;
  515. align-items: center;
  516. .number_leftbox{
  517. display: flex;
  518. justify-content: start;
  519. image{
  520. width: 96upx;
  521. height: 96upx;
  522. border-radius: 50%;
  523. margin-right: 20upx;
  524. }
  525. .number_font{
  526. display: flex;
  527. flex-direction: column;
  528. font-size: 30upx;
  529. padding-top: 6upx;
  530. .times{
  531. color: #999999;
  532. font-size: 24upx;
  533. margin-top: 10upx;
  534. }
  535. }
  536. }
  537. .number_rightbox{
  538. text-align: right;
  539. line-height: 46upx;
  540. }
  541. }
  542. }
  543. </style>