index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. <template>
  2. <base-page>
  3. <view class="common-wrap">
  4. <view class="title">营业数据</view>
  5. <view class="choice-day">
  6. <view class="date-btn" :class="dateType == 'today' ? 'select' : ''" @click="switchDateType('today')" value="today">今日</view>
  7. <view class="date-btn" :class="dateType == 'yesterday' ? 'select' : ''" @click="switchDateType('yesterday')" value="yesterday">昨日</view>
  8. <view class="date-btn" :class="dateType == 'week' ? 'select' : ''" @click="switchDateType('week')" value="week">7日内</view>
  9. <view class="date-btn" :class="dateType == 'month' ? 'select' : ''" @click="switchDateType('month')" value="month">30日内</view>
  10. <view class="date-btn" :class="dateType == 'custom' ? 'select' : ''" @click="switchDateType('custom')" value="custom">自定义</view>
  11. <view class="report text-color">
  12. <text class="move iconfont iconicon-test"></text>
  13. <text></text>
  14. </view>
  15. </view>
  16. <view class="money" v-if="businessdata">
  17. <view class="estimate" :class="statType == 'expected_earnings_total_money' ? 'estimate-active' : ''">
  18. <view class="income">
  19. <text class="income-name">预计收入(元)</text>
  20. <!-- <uni-dropdown>
  21. <view class="action" slot="dropdown-link"><i class="iconfont iconbangzhu js-prompt-top"></i></view>
  22. <view slot="dropdown">
  23. <view class="dropdown-content-box">
  24. <view class="text">弹框展示内容</view>
  25. <view class="arrow"></view>
  26. </view>
  27. </view>
  28. </uni-dropdown> -->
  29. </view>
  30. <view class="num-money">
  31. <text class="last_income">{{ businessdata.expected_earnings_total_money || 0.0 }}</text>
  32. <text class="detail" @click="switchStatType('expected_earnings_total_money')">查看详情</text>
  33. </view>
  34. </view>
  35. <view class="estimate" :class="statType == 'billing_money' ? 'estimate-active' : ''">
  36. <view class="income">
  37. <text class="income-name">开单金额数(元)</text>
  38. <!-- <uni-dropdown>
  39. <view class="action" slot="dropdown-link"><i class="iconfont iconbangzhu js-prompt-top"></i></view>
  40. <view slot="dropdown">
  41. <view class="dropdown-content-box">
  42. <view class="text">弹框展示内容</view>
  43. <view class="arrow"></view>
  44. </view>
  45. </view>
  46. </uni-dropdown> -->
  47. </view>
  48. <view class="num-money">
  49. <text class="last_income">{{ businessdata.billing_money || 0.0 }}</text>
  50. <text class="detail" @click="switchStatType('billing_money')">查看详情</text>
  51. </view>
  52. </view>
  53. <view class="estimate" :class="statType == 'billing_count' ? 'estimate-active' : ''">
  54. <view class="income"><text class="income-name">开单数量</text></view>
  55. <view class="num-money">
  56. <text class="last_income">{{ businessdata.billing_count || 0 }}</text>
  57. <text class="detail" @click="switchStatType('billing_count')">查看详情</text>
  58. </view>
  59. </view>
  60. <view class="estimate" :class="statType == 'buycard_money' ? 'estimate-active' : ''">
  61. <view class="income"><text class="income-name">办卡金额数(元)</text></view>
  62. <view class="num-money">
  63. <text class="last_income">{{ businessdata.buycard_money || 0.0 }}</text>
  64. <text class="detail" @click="switchStatType('buycard_money')">查看详情</text>
  65. </view>
  66. </view>
  67. <view class="estimate" :class="statType == 'buycard_count' ? 'estimate-active' : ''">
  68. <view class="income"><text class="income-name">办卡数</text></view>
  69. <view class="num-money">
  70. <text class="last_income">{{ businessdata.buycard_count || 0 }}</text>
  71. <text class="detail" @click="switchStatType('buycard_count')">查看详情</text>
  72. </view>
  73. </view>
  74. <view class="estimate" :class="statType == 'recharge_money' ? 'estimate-active' : ''">
  75. <view class="income"><text class="income-name">会员充值金额(元)</text></view>
  76. <view class="num-money">
  77. <text class="last_income">{{ businessdata.recharge_money || 0.0 }}</text>
  78. <text class="detail" @click="switchStatType('recharge_money')">查看详情</text>
  79. </view>
  80. </view>
  81. <view class="estimate" :class="statType == 'recharge_count' ? 'estimate-active' : ''">
  82. <view class="income"><text class="income-name">会员充值数量</text></view>
  83. <view class="num-money">
  84. <text class="last_income">{{ businessdata.recharge_count || 0 }}</text>
  85. <text class="detail" @click="switchStatType('recharge_count')">查看详情</text>
  86. </view>
  87. </view>
  88. <view class="estimate" :class="statType == 'refund_money' ? 'estimate-active' : ''">
  89. <view class="income"><text class="income-name">会员退款金额(元)</text></view>
  90. <view class="num-money">
  91. <text class="last_income">{{ businessdata.refund_money || 0.0 }}</text>
  92. <text class="detail" @click="switchStatType('refund_money')">查看详情</text>
  93. </view>
  94. </view>
  95. <view class="estimate" :class="statType == 'refund_count' ? 'estimate-active' : ''">
  96. <view class="income"><text class="income-name">会员退款数量</text></view>
  97. <view class="num-money">
  98. <text class="last_income">{{ businessdata.refund_count || 0 }}</text>
  99. <text class="detail" @click="switchStatType('refund_count')">查看详情</text>
  100. </view>
  101. </view>
  102. <view class="estimate" :class="statType == 'order_member_count' ? 'estimate-active' : ''">
  103. <view class="income"><text class="income-name">门店下单会员数</text></view>
  104. <view class="num-money">
  105. <text class="last_income">{{ businessdata.order_member_count || 0 }}</text>
  106. <text class="detail" @click="switchStatType('order_member_count')">查看详情</text>
  107. </view>
  108. </view>
  109. <view class="estimate" :class="statType == 'balance_money' ? 'estimate-active' : ''">
  110. <view class="income"><text class="income-name">会员余额消费金额</text></view>
  111. <view class="num-money">
  112. <text class="last_income">{{ businessdata.balance_money || 0.0 }}</text>
  113. <text class="detail" @click="switchStatType('balance_money')">查看详情</text>
  114. </view>
  115. </view>
  116. </view>
  117. </view>
  118. <uni-popup ref="customTime">
  119. <view class="pop-box">
  120. <view class="pop-header">
  121. <view class="pop-header-text">自定义时间选择</view>
  122. <view class="pop-header-close" @click="$refs.customTime.close()"><i class="iconguanbi1 iconfont"></i></view>
  123. </view>
  124. <view class="pop-content ">
  125. <uni-datetime-picker v-model="timeObj.custom" @change="changeTime" :end="endDate" :clearIcon="false" type="datetimerange" rangeSeparator="至" />
  126. </view>
  127. <view class="pop-bottom"><button class="primary-btn" @click="getStatData()">确定</button></view>
  128. </view>
  129. </uni-popup>
  130. <uni-popup ref="chartsPop">
  131. <view class="pop-box charts-pop">
  132. <view class="pop-header">
  133. <view class="pop-header-text">运营数据图表展示</view>
  134. <view class="pop-header-close" @click="$refs.chartsPop.close()"><i class="iconguanbi1 iconfont"></i></view>
  135. </view>
  136. <view class="pop-content">
  137. <qiun-data-charts type="line" :chartData="chartData" :eopts="{ seriesTemplate: { smooth: true } }" :ontouch="true" :opts="chartsOpts" />
  138. </view>
  139. <!-- <view class="pop-bottom"><button class="primary-btn" @click="getStatData()">确定</button></view> -->
  140. </view>
  141. </uni-popup>
  142. </base-page>
  143. </template>
  144. <script>
  145. export default {
  146. data() {
  147. return {
  148. statType: 'expected_earnings_total_money',
  149. statTypeArr: {
  150. expected_earnings_total_money: '预计收入',
  151. billing_money: '开单金额数',
  152. billing_count: '开单数量',
  153. buycard_money: '办卡金额数',
  154. buycard_count: '办卡数',
  155. recharge_money: '会员充值金额',
  156. recharge_count: '会员充值数量',
  157. refund_money: '会员退款金额',
  158. refund_count: '会员退款数量',
  159. order_member_count: '门店下单会员数',
  160. balance_money: '会员余额消费金额'
  161. },
  162. dateType: 'today',
  163. timeObj: {
  164. today: [],
  165. yesterday: [],
  166. week: [],
  167. month: [],
  168. custom: []
  169. },
  170. chartData: {
  171. categories: [],
  172. series: []
  173. },
  174. businessdata: null,
  175. chartsOpts: { enableScroll: true, xAxis: { scrollShow: true, itemCount: 24, disableGrid: true } }
  176. };
  177. },
  178. onLoad() {
  179. this.setDate();
  180. this.getStatData();
  181. },
  182. onShow() {
  183. let date = new Date();
  184. var y = date.getFullYear();
  185. var m = date.getMonth() + 1;
  186. var d = date.getDate();
  187. this.endDate = y + '-' + m + '-' + d + ' 23:59:59';
  188. },
  189. methods: {
  190. // 重置图表数据
  191. resetChartData() {
  192. this.chartData.categories = [];
  193. this.chartData.series = [];
  194. },
  195. setDate() {
  196. let time = this.$util.timeTurnTimeStamp(this.$util.timeFormat(Date.now() / 1000, 'y-m-d'));
  197. this.timeObj.today = [time, time + 86399];
  198. this.timeObj.yesterday = [time - 86400, time - 1];
  199. this.timeObj.week = [time - 604800, time];
  200. this.timeObj.month = [time - 2592000, time];
  201. },
  202. switchDateType(type) {
  203. this.dateType = type;
  204. if (type == 'custom') {
  205. this.$refs.customTime.open();
  206. return false;
  207. }
  208. if (type == 'month') this.chartsOpts.xAxis.itemCount = 10;
  209. else this.chartsOpts.xAxis.itemCount = 24;
  210. this.getStatData();
  211. },
  212. switchStatType(type) {
  213. this.statType = type;
  214. this.$refs.chartsPop.open();
  215. this.resetChartData();
  216. this.getStatData();
  217. setTimeout(() => {
  218. this.getChartData();
  219. }, 500);
  220. },
  221. changeTime(e) {
  222. this.timeObj.custom = e;
  223. this.chartsOpts.xAxis.itemCount = 10;
  224. },
  225. getStatData() {
  226. if (this.dateType == 'custom') {
  227. this.$refs.customTime.close();
  228. this.timeObj.custom[0] = this.$util.timeTurnTimeStamp(this.timeObj.custom[0]) * 1000; // 解决自定义数据保存之后再次点击出现的数据错乱
  229. this.timeObj.custom[1] = this.$util.timeTurnTimeStamp(this.timeObj.custom[1]) * 1000; // 解决自定义数据保存之后再次点击出现的数据错乱
  230. }
  231. this.getBusinessData();
  232. },
  233. getChartData() {
  234. let url = '/cashier/storeapi/stat/dayStatData';
  235. let data = {};
  236. data.start_time = this.timeObj[this.dateType][0];
  237. if (this.dateType == 'today' || this.dateType == 'yesterday') url = '/cashier/storeapi/stat/hourStatData';
  238. else data.end_time = this.timeObj[this.dateType][1];
  239. this.$api.sendRequest({
  240. url: url,
  241. data: data,
  242. success: res => {
  243. if (res.code >= 0) {
  244. this.chartData.series = [];
  245. this.chartData.series.push({
  246. data: res.data[this.statType],
  247. name: this.statTypeArr[this.statType]
  248. });
  249. this.chartData.categories = res.data.time;
  250. }
  251. }
  252. });
  253. },
  254. getBusinessData() {
  255. let data = {};
  256. data.start_time = this.dateType == 'custom' ? parseInt(this.timeObj[this.dateType][0] / 1000) : parseInt(this.timeObj[this.dateType][0]);
  257. data.end_time = this.dateType == 'custom' ? parseInt(this.timeObj[this.dateType][1] / 1000) : parseInt(this.timeObj[this.dateType][1]);
  258. this.$api.sendRequest({
  259. url: '/cashier/storeapi/stat/statTotal',
  260. data: data,
  261. success: res => {
  262. if (res.code >= 0) {
  263. this.businessdata = res.data;
  264. }
  265. }
  266. });
  267. }
  268. }
  269. };
  270. </script>
  271. <style>
  272. .stat-input-inline .uni-date {
  273. }
  274. .pop-content >>> .uni-icons {
  275. line-height: 0.32rem;
  276. }
  277. </style>
  278. <style lang="scss" scoped>
  279. .common-wrap {
  280. padding: 0.2rem;
  281. height: 100vh;
  282. box-sizing: border-box;
  283. }
  284. .title {
  285. display: flex;
  286. margin-bottom: 0.21rem;
  287. font-size: 0.16rem;
  288. font-family: Source Han Sans CN;
  289. font-weight: bold;
  290. line-height: 0.2rem;
  291. }
  292. .choice-day {
  293. display: flex;
  294. }
  295. .choice-time {
  296. margin-top: 0.09rem;
  297. font-size: 0.12rem;
  298. font-family: Source Han Sans CN;
  299. font-weight: 400;
  300. line-height: 0.36rem;
  301. }
  302. .report {
  303. display: flex;
  304. justify-content: flex-end;
  305. margin-right: 0.2rem;
  306. font-size: 0.14rem;
  307. font-family: Source Han Sans CN;
  308. font-weight: 400;
  309. line-height: 0.36rem;
  310. cursor: pointer;
  311. }
  312. .move {
  313. margin-right: 0.06rem;
  314. }
  315. .money {
  316. display: flex;
  317. flex-wrap: wrap;
  318. margin-top: 0.35rem;
  319. .estimate {
  320. width: calc((100% - 0.85rem) / 5);
  321. margin: 0 0.08rem 0.2rem;
  322. padding: 0.2rem;
  323. background: #fff;
  324. border: 0.01rem solid #eee;
  325. border-radius: 0.02rem;
  326. cursor: pointer;
  327. position: relative;
  328. box-sizing: border-box;
  329. .income {
  330. display: flex;
  331. flex-direction: row;
  332. box-sizing: border-box;
  333. line-height: 0.2rem;
  334. .income-name {
  335. font-size: 0.16rem;
  336. }
  337. }
  338. .num-money {
  339. .last_income {
  340. display: block;
  341. margin: 0.15rem 0;
  342. font-size: 0.24rem;
  343. font-weight: 500;
  344. line-height: 0.2rem;
  345. }
  346. .detail {
  347. display: block;
  348. text-align: right;
  349. color: $primary-color;
  350. font-size: $uni-font-size-sm;
  351. position: relative;
  352. bottom: -0.05rem;
  353. }
  354. }
  355. }
  356. .estimate:last-child {
  357. margin-right: 0;
  358. }
  359. }
  360. .jantou {
  361. margin-top: 0.05rem;
  362. padding-left: 0.1rem;
  363. height: 0.11rem;
  364. }
  365. .yesterday {
  366. display: flex;
  367. flex-wrap: wrap;
  368. font-size: 0.12rem;
  369. }
  370. .top-num {
  371. display: flex;
  372. margin-left: 0.05rem;
  373. font-size: 0.12rem;
  374. font-weight: 400;
  375. }
  376. .date-btn {
  377. height: 0.42rem;
  378. line-height: 0.42rem;
  379. font-size: 0.14rem;
  380. padding: 0 0.3rem;
  381. box-sizing: border-box;
  382. border: 0.01rem solid #d2d2d2;
  383. cursor: pointer;
  384. border-right: none;
  385. border-left: none;
  386. position: relative;
  387. }
  388. .date-btn:nth-child(6)::after {
  389. border-radius: 0 0.02rem 0.02rem 0;
  390. }
  391. .date-btn:first-child::after {
  392. border-radius: 0.02rem 0 0 0.02rem;
  393. }
  394. .date-btn:first-child {
  395. border-radius: 0.02rem 0 0 0.02rem;
  396. }
  397. .date-btn::after {
  398. content: '';
  399. position: absolute;
  400. top: -0.01rem;
  401. left: 0;
  402. bottom: -0.01rem;
  403. right: -0.01rem;
  404. border-right: 0.01rem solid #d2d2d2;
  405. border-left: 0.01rem solid #d2d2d2;
  406. }
  407. .select {
  408. color: #fff;
  409. background-color: $primary-color;
  410. border-color: $primary-color;
  411. }
  412. .select::after {
  413. z-index: 2;
  414. border-color: $primary-color;
  415. }
  416. .select:first-child {
  417. border-radius: 0.02rem 0 0 0.02rem;
  418. }
  419. .seleced:nth-child(6) {
  420. border-radius: 0 0.02rem 0.02rem 0;
  421. }
  422. .c-datepicker-picker {
  423. z-index: 99999999 !important;
  424. }
  425. .yesterday {
  426. display: none;
  427. }
  428. .dropdown-content-box {
  429. padding: 0.05rem 0;
  430. margin-top: 0.05rem;
  431. background-color: #fff;
  432. border: 0.01rem solid #ebeef5;
  433. border-radius: 0.04rem;
  434. box-shadow: 0 0.01rem 0.12rem 0 rgba(0, 0, 0, 0.1);
  435. position: relative;
  436. .arrow {
  437. position: absolute;
  438. top: -0.06rem;
  439. right: 0.06rem;
  440. width: 0;
  441. height: 0;
  442. border-left: 0.06rem solid transparent;
  443. border-right: 0.06rem solid transparent;
  444. border-bottom: 0.06rem solid #fff;
  445. }
  446. .text {
  447. display: flex;
  448. align-items: center;
  449. justify-content: center;
  450. margin: 0;
  451. padding: 0 0.1rem;
  452. transition: all 0.3s;
  453. font-size: 0.12rem;
  454. width: 1.5rem;
  455. box-sizing: border-box;
  456. text-align: left;
  457. line-height: 1.5;
  458. }
  459. }
  460. .js-prompt-top {
  461. color: #c8c9cc;
  462. font-size: 0.14rem;
  463. z-index: 999;
  464. margin-left: 0.05rem;
  465. cursor: pointer;
  466. }
  467. // pop弹框
  468. .pop-box {
  469. background: #ffffff;
  470. width: 6rem;
  471. height: 3.38rem;
  472. .pop-header {
  473. padding: 0 0.15rem 0 0.2rem;
  474. height: 0.5rem;
  475. line-height: 0.5rem;
  476. border-bottom: 0.01rem solid #f0f0f0;
  477. font-size: 0.14rem;
  478. color: #333;
  479. overflow: hidden;
  480. border-radius: 0.02rem 0.2rem 0 0;
  481. box-sizing: border-box;
  482. display: flex;
  483. justify-content: space-between;
  484. .pop-header-text {
  485. }
  486. .pop-header-close {
  487. cursor: pointer;
  488. i {
  489. font-size: 0.18rem;
  490. }
  491. }
  492. }
  493. .pop-content {
  494. height: calc(100% - 1.05rem);
  495. // overflow-y: scroll;
  496. padding: 0.2rem;
  497. box-sizing: border-box;
  498. }
  499. .pop-bottom {
  500. padding: 0.1rem;
  501. height: 0.65rem;
  502. border-top: 0.01rem solid #eee;
  503. button {
  504. width: 95%;
  505. }
  506. }
  507. }
  508. .charts-pop {
  509. width: 9.5rem;
  510. height: 5.4rem;
  511. background-color: #fff;
  512. .pop-content {
  513. width: 100%;
  514. height: calc(100% - 1rem);
  515. }
  516. }
  517. </style>