index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <template>
  2. <view class="container">
  3. <view class="top"></view>
  4. <view class="title">财务数据</view>
  5. <view class="balance-card">
  6. <!-- 账户余额 -->
  7. <view class="balance-info">
  8. <view @click="goPage">
  9. <view class="flex">
  10. <text class="balance-label">账户余额</text>
  11. <u-icon name="arrow-right" class="ml-1" color="#fff" size="24"></u-icon>
  12. </view>
  13. <text class="balance-amount">{{ formatAmount(financeData.availableAmount) }}</text>
  14. </view>
  15. <view>
  16. <button class="withdraw-btn" @click="goWithdrawal">提现</button>
  17. </view>
  18. </view>
  19. <!-- 金额统计 -->
  20. <view class="stats-row u-m-b-20">
  21. <view class="stat-item">
  22. <text class="stat-label">已结算金额 (元)</text>
  23. <text class="stat-value">{{ formatAmount(financeData.totalSettledAmount) }}</text>
  24. </view>
  25. <view class="stat-item">
  26. <text class="stat-label">待结算金额 (元)</text>
  27. <text class="stat-value">{{ formatAmount(financeData.pendingSettledAmount) }}</text>
  28. </view>
  29. </view>
  30. <view class="stats-row">
  31. <view class="stat-item">
  32. <text class="stat-label">已提现金额 (元)</text>
  33. <text class="stat-value">{{ formatAmount(financeData.totalWithdrawnAmount) }}</text>
  34. </view>
  35. <view class="stat-item">
  36. <text class="stat-label">提现中金额 (元)</text>
  37. <text class="stat-value">{{ formatAmount(financeData.frozenAmount) }}</text>
  38. </view>
  39. </view>
  40. </view>
  41. <!-- 业务类型 -->
  42. <view class="business-tabs">
  43. <view
  44. v-for="(tab, index) in businessTabs"
  45. :key="tab.name"
  46. :class="index == currentTab ? 'tab-item active' : 'tab-item'"
  47. @click="onTabChange(index)"
  48. >{{ tab.name }}</view
  49. >
  50. </view>
  51. <!-- 订单统计 -->
  52. <view class="amount-card">
  53. <!-- 日期选择 -->
  54. <view class="date-picker">
  55. <view @click="selectDate">
  56. <text>{{ startDate ? startDate : '开始时间' }}</text>
  57. <text class="date-separator">至</text>
  58. <text>{{ endDate ? endDate : '结束时间' }}</text>
  59. <u-icon v-if="!startDate || !endDate" class="ml-1" name="arrow-down-fill" size="18" color="#666666"></u-icon>
  60. </view>
  61. <uni-icons
  62. v-if="startDate"
  63. class="ml-1"
  64. type="clear"
  65. size="18"
  66. color="#909399"
  67. @click="resetDateRange"
  68. ></uni-icons>
  69. </view>
  70. <!-- 普通/团餐 -->
  71. <view v-if="currentTab == 0 || currentTab == 2">
  72. <view class="row u-m-b-12">
  73. <view class="item">
  74. <text class="label">{{ currentTab == 0 ? '订单金额 (元)' : '团餐订单金额 (元)' }}</text>
  75. <text class="value">{{ formatAmount(orderData.orderAmount) || '0.00' }}</text>
  76. </view>
  77. <view class="item">
  78. <text class="label">{{ currentTab == 0 ? '退款金额 (元)' : '团餐退款金额 (元)' }}</text>
  79. <text class="value">{{ formatAmount(orderData.refundAmount) || '0.00' }}</text>
  80. </view>
  81. </view>
  82. <view class="row u-m-b-12">
  83. <view class="item">
  84. <text class="label">{{ currentTab == 0 ? '支付订单量' : '团餐订单量' }}</text>
  85. <text class="value">{{ formatAmount(orderData.orderCount, 'quantity') || '0' }}</text>
  86. </view>
  87. <view class="item">
  88. <text class="label">退款订单量</text>
  89. <text class="value">{{ formatAmount(orderData.refundCount, 'quantity') || '0' }}</text>
  90. </view>
  91. </view>
  92. <view class="row" v-if="currentTab == 2">
  93. <view class="item">
  94. <text class="label">普通订单金额 (元)</text>
  95. <text class="value">{{ formatAmount(orderData.normalOrderAmount) || '0.00' }}</text>
  96. </view>
  97. <view class="item">
  98. <text class="label">企业订单金额 (元)</text>
  99. <text class="value">{{ formatAmount(orderData.enterpriseOrderAmount) || '0.00' }}</text>
  100. </view>
  101. </view>
  102. </view>
  103. <!-- 渠道订单 -->
  104. <view v-if="currentTab == 1">
  105. <view class="row u-m-b-12">
  106. <view class="item">
  107. <text class="label">权益券金额 (元)</text>
  108. <text class="value">{{ formatAmount(orderData.couponAmount) || '0.00' }}</text>
  109. </view>
  110. <view class="item">
  111. <text class="label">实付金额 (元)</text>
  112. <text class="value">{{ formatAmount(orderData.actualPayAmount) || '0.00' }}</text>
  113. </view>
  114. </view>
  115. <view class="row">
  116. <view class="item">
  117. <text class="label">应收金额 (元)</text>
  118. <text class="value">{{ formatAmount(orderData.receivableAmount) || '0.00' }}</text>
  119. </view>
  120. <view class="item">
  121. <text class="label">订单量</text>
  122. <text class="value">{{ formatAmount(orderData.orderCount, 'quantity') || '0' }}</text>
  123. </view>
  124. </view>
  125. </view>
  126. </view>
  127. <rangTime ref="rangTime" :mode="1" title="选择日期" @onSubmit="onEndTimeChange" />
  128. </view>
  129. </template>
  130. <script>
  131. import api from '@/api/account.js';
  132. import { formatAmount } from '@/common/util/util';
  133. import rangTime from '@/components/dengrq-datetime-picker/dateSelector/index.vue';
  134. export default {
  135. components: {
  136. rangTime,
  137. },
  138. data() {
  139. return {
  140. formatAmount,
  141. currentTab: 0,
  142. financeData: {},
  143. orderData: {},
  144. startDate: '',
  145. endDate: '',
  146. businessTabs: [
  147. { name: '普通业务', type: 'NORMAL' },
  148. { name: '渠道业务', type: 'CHANNEL' },
  149. { name: '团餐业务', type: 'GROUP_MEAL' },
  150. ],
  151. };
  152. },
  153. onShow() {
  154. this.getData();
  155. this.getFinanceInfo();
  156. },
  157. methods: {
  158. getData() {
  159. api.getAccountInfo().then((res) => {
  160. if (res.data.code === 200 && res.data.result) {
  161. this.financeData = res.data.result;
  162. }
  163. });
  164. },
  165. getFinanceInfo() {
  166. const params = {
  167. bizType: this.businessTabs[this.currentTab].type,
  168. };
  169. if (this.startDate) {
  170. params.startDate = this.startDate;
  171. params.endDate = this.endDate;
  172. }
  173. api.getFinanceStats(params).then((res) => {
  174. if (res.data.code === 200 && res.data.result) {
  175. this.orderData = res.data.result;
  176. this.startDate = res.data.result.startDate;
  177. this.endDate = res.data.result.endDate;
  178. this.$refs.rangTime.startDate = this.startDate;
  179. this.$refs.rangTime.endDate = this.endDate;
  180. }
  181. });
  182. },
  183. onTabChange(e) {
  184. this.currentTab = e;
  185. this.resetDateRange();
  186. },
  187. // 选择日期
  188. selectDate() {
  189. this.$refs.rangTime.open();
  190. },
  191. onEndTimeChange(val) {
  192. this.startDate = val.startDate;
  193. this.endDate = val.endDate;
  194. console.log(this.startDate, this.endDate);
  195. this.$forceUpdate();
  196. this.getFinanceInfo();
  197. },
  198. resetDateRange() {
  199. this.startDate = '';
  200. this.endDate = '';
  201. this.$refs.rangTime.startDate = '';
  202. this.$refs.rangTime.endDate = '';
  203. this.getFinanceInfo();
  204. },
  205. // 跳转账号余额
  206. goPage() {
  207. uni.navigateTo({
  208. url: `/pages/finance/balance?balance=${this.financeData.availableAmount}`,
  209. });
  210. },
  211. // 跳转提现
  212. goWithdrawal() {
  213. uni.navigateTo({
  214. url: `/pages/finance/withdrawal?balance=${this.financeData.availableAmount}`,
  215. });
  216. },
  217. },
  218. };
  219. </script>
  220. <style lang="scss" scoped>
  221. .container {
  222. width: 100%;
  223. background: #ffffff;
  224. font-family: Source Han Sans CN;
  225. .top {
  226. width: 100%;
  227. height: var(--status-bar-height);
  228. background:
  229. linear-gradient(90deg, #e3f4f8 0%, #ebf7f7 47.5%, #d6eff7 100%),
  230. linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0) 100%);
  231. }
  232. .title {
  233. height: 117rpx;
  234. font-family: Source Han Sans SC;
  235. display: flex;
  236. align-items: center;
  237. justify-content: center;
  238. font-size: 38rpx;
  239. color: #333333;
  240. font-weight: 500;
  241. border-bottom: 1rpx solid #eeeeee;
  242. background:
  243. linear-gradient(90deg, #e3f4f8 0%, #ebf7f7 47.5%, #d6eff7 100%),
  244. linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0) 100%);
  245. }
  246. .balance-card {
  247. margin: 21rpx 25rpx 10rpx;
  248. padding: 21rpx 31rpx 31rpx;
  249. background: linear-gradient(286deg, #34bbff 0%, #4496fb 100%);
  250. box-shadow: 0rpx 4rpx 10rpx 0rpx #dae3f4;
  251. border-radius: 21rpx 21rpx 21rpx 21rpx;
  252. border: 1rpx solid rgba(255, 255, 255, 0.6);
  253. .balance-info {
  254. flex: 1;
  255. display: flex;
  256. justify-content: space-between;
  257. align-items: center;
  258. border-bottom: 1rpx solid rgba(255, 255, 255, 0.2);
  259. margin-bottom: 21rpx;
  260. .balance-label {
  261. display: block;
  262. font-weight: 400;
  263. font-size: 25rpx;
  264. color: #ffffff;
  265. }
  266. .balance-amount {
  267. font-family:
  268. DIN Alternate,
  269. DIN Alternate;
  270. font-weight: bold;
  271. font-size: 63rpx;
  272. color: #ffffff;
  273. }
  274. .withdraw-btn {
  275. width: 129rpx;
  276. height: 63rpx;
  277. background: #ffffff;
  278. border-radius: 8rpx 8rpx 8rpx 8rpx;
  279. font-family: Source Han Sans SC;
  280. font-weight: 500;
  281. font-size: 29rpx;
  282. color: #38b2fe;
  283. display: flex;
  284. align-items: center;
  285. justify-content: center;
  286. }
  287. }
  288. }
  289. .stats-row {
  290. display: flex;
  291. text-align: left;
  292. :last-child {
  293. margin-bottom: 0;
  294. }
  295. .stat-item {
  296. flex: 1;
  297. text-align: center;
  298. .stat-label {
  299. display: block;
  300. font-weight: 400;
  301. font-size: 21rpx;
  302. color: #ffffff;
  303. }
  304. .stat-value {
  305. font-family: DIN Alternate;
  306. font-weight: bold;
  307. font-size: 38rpx;
  308. color: #ffffff;
  309. }
  310. }
  311. }
  312. .amount-card {
  313. margin: 21rpx 25rpx 0;
  314. padding: 17rpx 0 21rpx;
  315. background: #f7f8fc;
  316. border-radius: 21rpx 21rpx 21rpx 21rpx;
  317. .row {
  318. display: flex;
  319. text-align: left;
  320. :last-child {
  321. margin-bottom: 0;
  322. }
  323. .item {
  324. flex: 1;
  325. text-align: center;
  326. .label {
  327. display: block;
  328. font-weight: 400;
  329. font-size: 21rpx;
  330. color: #666666;
  331. }
  332. .value {
  333. font-family: Source Han Sans SC;
  334. font-weight: 500;
  335. font-size: 33rpx;
  336. color: #333333;
  337. }
  338. }
  339. }
  340. }
  341. .business-tabs {
  342. display: flex;
  343. justify-content: space-around;
  344. .tab-item {
  345. // flex: 1;
  346. position: relative;
  347. padding: 18rpx 0;
  348. cursor: pointer;
  349. font-family: Source Han Sans SC;
  350. color: #333333;
  351. font-weight: 400;
  352. font-size: 29rpx;
  353. }
  354. .active {
  355. font-weight: 500;
  356. color: #449aff;
  357. }
  358. .tab-item.active::after {
  359. content: '';
  360. position: absolute;
  361. bottom: -28px;
  362. left: 35%;
  363. width: 38rpx;
  364. height: 100%;
  365. background: url('@/static/product/tab-act.png') no-repeat;
  366. background-size: contain;
  367. }
  368. }
  369. .date-picker {
  370. display: flex;
  371. justify-content: center;
  372. border-radius: 12rpx;
  373. margin: 0 28rpx 17rpx;
  374. display: flex;
  375. align-items: center;
  376. justify-content: center;
  377. cursor: pointer;
  378. font-weight: 400;
  379. font-size: 27rpx;
  380. color: #666666;
  381. .date-separator {
  382. margin: 0 5px;
  383. }
  384. }
  385. }
  386. </style>