income.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <script lang="ts" setup>
  2. import type { AccountDetailItem } from '@/api/income'
  3. import { useRequest } from 'alova/client'
  4. import { storeToRefs } from 'pinia'
  5. import { ref } from 'vue'
  6. import { getAccountCount } from '@/api/home'
  7. import { getCouponIssuerAccountByPageMap, PageMapResponse } from '@/api/income'
  8. import { LOGIN_PAGE } from '@/router/config'
  9. import { useUserStore } from '@/store'
  10. import { useTokenStore } from '@/store/token'
  11. import { changtime, menuButtonInfo, safeAreaInsets, systemInfo } from '@/utils'
  12. definePage({
  13. style: {
  14. navigationBarTitleText: '收益',
  15. navigationStyle: 'custom',
  16. },
  17. })
  18. const userStore = useUserStore()
  19. const tokenStore = useTokenStore()
  20. // 使用storeToRefs解构userInfo
  21. const { userInfo } = storeToRefs(userStore)
  22. const { hasLogin } = storeToRefs(tokenStore)
  23. const show = ref(false)
  24. const filterValue = ref(Number(new Date()))
  25. function confirm() {
  26. // 函数实现
  27. show.value = false
  28. }
  29. function cancel() {
  30. show.value = false
  31. }
  32. function close() {
  33. show.value = false
  34. }
  35. // 发券人账户表-通过userId查询账户信息
  36. const { send: getAccountCountRequest, data: accountCountData } = useRequest(getAccountCount, {
  37. immediate: false,
  38. })
  39. const queryForm = ref({
  40. pageNo: 1,
  41. pageSize: 10,
  42. startTime: '',
  43. endTime: '',
  44. status: 0, // 0-待结算, 1-已结算/成功
  45. type: 1, // 明细类型: 1-佣金收入, 2-提现支出, 3-退款扣减, 4-系统调整
  46. })
  47. // 获取账户明细分页数据(Map格式)
  48. const { send: getCouponIssuerAccountByPageMapRequest, data: couponIssuerAccountByPageMapData } = useRequest(
  49. getCouponIssuerAccountByPageMap,
  50. { immediate: false },
  51. )
  52. const list = ref<AccountDetailItem[]>([])
  53. onShow(async () => {
  54. // 登录后查询收益数据
  55. if (hasLogin) {
  56. try {
  57. await getAccountCountRequest()
  58. await getCouponIssuerAccountByPageMapRequest(queryForm.value)
  59. // 使用可选链和空值合并运算符避免undefined错误,直接赋值而非展开运算符
  60. list.value = couponIssuerAccountByPageMapData.value?.detailList || []
  61. }
  62. catch (error) {
  63. console.error('获取收益数据失败:', error)
  64. uni.showToast({ title: '获取数据失败', icon: 'error' })
  65. list.value = []
  66. }
  67. }
  68. })
  69. function showTimeFilter() {
  70. show.value = true
  71. }
  72. const wjsList = ref<AccountDetailItem[]>([])
  73. const yjsList = ref<AccountDetailItem[]>([])
  74. onLoad(() => {
  75. list.value = wjsList.value
  76. })
  77. const activeTab = ref('pending')
  78. async function changeTab(tab: string) {
  79. console.log(999, activeTab.value, tab)
  80. if (activeTab.value === tab)
  81. return
  82. activeTab.value = tab
  83. queryForm.value.status = tab === 'pending' ? 0 : 1
  84. try {
  85. await getCouponIssuerAccountByPageMapRequest(queryForm.value)
  86. // 使用可选链和空值合并运算符避免undefined错误,直接赋值而非展开运算符
  87. list.value = couponIssuerAccountByPageMapData.value?.detailList || []
  88. }
  89. catch (error) {
  90. console.error('切换标签页失败:', error)
  91. uni.showToast({ title: '获取数据失败', icon: 'error' })
  92. list.value = []
  93. }
  94. }
  95. function goPage(page: string) {
  96. uni.navigateTo({
  97. url: `/pages-A/${page}/index`,
  98. })
  99. }
  100. </script>
  101. <template>
  102. <view class="profile-container">
  103. <!-- 顶部区域 -->
  104. <view class="income-header"
  105. style="background: url('../../static/images/income/income-bg.png') no-repeat center center; background-size: cover;">
  106. <view class="income-header-avatar-info"
  107. :style="{ paddingTop: `${safeAreaInsets.top + menuButtonInfo.height + 12}px` }">
  108. <view class="income-header-balance">
  109. 当前账户余额(元)
  110. </view>
  111. <view class="income-header-balance-num">
  112. <view class="income-header-balance-num-amount">
  113. {{ accountCountData?.balance }}
  114. </view>
  115. <view class="income-header-balance-num-btns">
  116. <view class="income-header-balance-num-btn js" @click="goPage('unlockRewards')">
  117. 解锁
  118. </view>
  119. <view class="income-header-balance-num-btn tx" @click="goPage('withdraw')">
  120. 提现
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. <view class="income-header-tips">
  126. <view class="income-header-tips-item">
  127. <view class="income-header-tips-item-num">
  128. {{ accountCountData?.withdrawableAmount }}
  129. </view>
  130. <view class="income-header-tips-item-des">
  131. 可提现金额
  132. </view>
  133. </view>
  134. <view class="income-header-tips-item">
  135. <view class="income-header-tips-item-num">
  136. {{ accountCountData?.unsettledAmount }}
  137. </view>
  138. <view class="income-header-tips-item-des">
  139. 未结算金额
  140. </view>
  141. </view>
  142. </view>
  143. </view>
  144. <!-- 公告 -->
  145. <view class="income-header-notice">
  146. <view class="income-header-notice-icon">
  147. <image src="@/static/images/income/notice.png" mode="aspectFit" />
  148. </view>
  149. <view class="income-header-notice-content">
  150. 在考核周期内未达标已锁定收益,<text>前往查看~</text>
  151. </view>
  152. </view>
  153. <!-- 菜单 -->
  154. <view class="income-header-menu">
  155. <!-- 结算筛选 -->
  156. <view class="income-header-menu-filter">
  157. <view class="income-header-menu-filter-item" :class="[activeTab === 'pending' ? 'active' : '']"
  158. @click="changeTab('pending')">
  159. 待结算
  160. </view>
  161. <view class="income-header-menu-filter-item" :class="[activeTab === 'settled' ? 'active' : '']"
  162. @click="changeTab('settled')">
  163. 已结算
  164. </view>
  165. </view>
  166. <!-- 时间筛选 -->
  167. <view class="income-menu-time-filter">
  168. <view class="income-menu-time-filter-text" @click="showTimeFilter">
  169. <text>{{ changtime(filterValue) }}</text>
  170. <up-icon name="arrow-down" color="#666666" size="14" />
  171. </view>
  172. <view>合计:¥{{ couponIssuerAccountByPageMapData?.totalAmount || 0 }}</view>
  173. </view>
  174. <!-- 优惠券列表 -->
  175. <view class="income-header-menu-list">
  176. <view v-for="item in list" :key="item.id" class="income-header-menu-item">
  177. <view class="income-header-menu-icon">
  178. <image v-if="activeTab === 'settled'" src="@/static/images/income/hb.png" mode="aspectFit" />
  179. <image v-else src="@/static/images/income/djs.png" mode="aspectFit" />
  180. <view class="income-header-menu-text">
  181. <view class="income-header-menu-text-nickname">
  182. {{ item.receiveUserName }}
  183. </view>
  184. <view>{{ item.couponName }}</view>
  185. </view>
  186. </view>
  187. <view class="income-header-menu-left">
  188. <view class="income-header-menu-left-amount">
  189. ¥{{ item.changeAmount }}
  190. </view>
  191. <view class="income-header-menu-left-time">
  192. {{ item.settleTime }}
  193. </view>
  194. </view>
  195. </view>
  196. </view>
  197. </view>
  198. <up-datetime-picker v-model="filterValue" :show="show" mode="year-month" close-on-click-overlay
  199. @confirm="confirm" @cancel="cancel" />
  200. </view>
  201. </template>
  202. <style lang="scss" scoped>
  203. .profile-container {
  204. font-family: Alibaba PuHuiTi;
  205. min-height: 100vh;
  206. background-color: #f5f5f5;
  207. line-height: 1;
  208. .income-header {
  209. height: 525rpx;
  210. .income-header-avatar-info {
  211. display: flex;
  212. flex-direction: column;
  213. gap: 30rpx;
  214. padding: 0 24rpx;
  215. .income-header-balance {
  216. font-weight: 400;
  217. font-size: 26rpx;
  218. color: #ffffff;
  219. }
  220. .income-header-balance-num {
  221. display: flex;
  222. justify-content: space-between;
  223. align-items: center;
  224. .income-header-balance-num-amount {
  225. font-weight: 500;
  226. font-size: 65rpx;
  227. color: #ffffff;
  228. }
  229. .income-header-balance-num-btns {
  230. display: flex;
  231. gap: 15rpx;
  232. .income-header-balance-num-btn {
  233. padding: 20rpx 40rpx;
  234. border-radius: 33rpx;
  235. font-weight: 400;
  236. font-size: 26rpx;
  237. &.js {
  238. background: #da4c47;
  239. color: #ffffff;
  240. }
  241. &.tx {
  242. background: #bfbfbf;
  243. color: #747474;
  244. }
  245. }
  246. }
  247. }
  248. }
  249. .income-header-tips {
  250. height: 124rpx;
  251. display: flex;
  252. background: linear-gradient(114deg, #f67873, #fb847f, #f67873);
  253. border-radius: 10rpx;
  254. margin: 47rpx 24rpx 0 24rpx;
  255. .income-header-tips-item {
  256. flex: 1;
  257. display: flex;
  258. flex-direction: column;
  259. justify-content: center;
  260. align-items: center;
  261. gap: 15rpx;
  262. font-weight: 500;
  263. font-size: 34rpx;
  264. color: #ffffff;
  265. line-height: 1;
  266. position: relative;
  267. &:first-child:after {
  268. content: '';
  269. position: absolute;
  270. top: 50%;
  271. right: 0;
  272. transform: translateY(-50%);
  273. width: 2px;
  274. height: 40rpx;
  275. background: #ffffff;
  276. }
  277. .income-header-tips-item-num {
  278. font-weight: bold;
  279. }
  280. .income-header-tips-item-des {
  281. font-weight: 400;
  282. font-size: 24rpx;
  283. color: #ffffff;
  284. }
  285. }
  286. }
  287. }
  288. .income-header-notice {
  289. margin: -50rpx 24rpx 24rpx 24rpx;
  290. background: #ffffff;
  291. border-radius: 10rpx;
  292. display: flex;
  293. align-items: center;
  294. gap: 20rpx;
  295. padding: 28rpx 20rpx;
  296. .income-header-notice-icon {
  297. width: 52rpx;
  298. height: 35rpx;
  299. image {
  300. width: 100%;
  301. height: 100%;
  302. }
  303. }
  304. .income-header-notice-content {
  305. font-weight: 400;
  306. font-size: 24rpx;
  307. color: #333333;
  308. text {
  309. color: #c52d27;
  310. }
  311. }
  312. }
  313. .income-header-menu {
  314. // background: #ffffff;
  315. border-radius: 10rpx 10rpx 0rpx 0rpx;
  316. margin: 24rpx 24rpx 0;
  317. .income-header-menu-filter {
  318. display: flex;
  319. justify-content: space-between;
  320. align-items: center;
  321. font-weight: 500;
  322. font-size: 32rpx;
  323. color: #333333;
  324. height: 90rpx;
  325. background: #ffffff;
  326. box-shadow: 0rpx 3rpx 7rpx 0rpx rgba(213, 213, 213, 0.29);
  327. border-radius: 10rpx 10rpx 0rpx 0rpx;
  328. .income-header-menu-filter-item {
  329. flex: 1;
  330. display: flex;
  331. justify-content: center;
  332. align-items: center;
  333. position: relative;
  334. height: 100%;
  335. &.active {
  336. color: #ed6b66;
  337. &:after {
  338. content: '';
  339. position: absolute;
  340. bottom: 0;
  341. left: 50%;
  342. transform: translateX(-50%);
  343. width: 67rpx;
  344. height: 6rpx;
  345. background: #ed6b66;
  346. border-radius: 3rpx;
  347. }
  348. }
  349. }
  350. }
  351. .income-menu-time-filter {
  352. display: flex;
  353. justify-content: space-between;
  354. align-items: center;
  355. font-weight: 400;
  356. font-size: 24rpx;
  357. color: #333333;
  358. padding: 50rpx 20rpx 14rpx;
  359. background: #ffffff;
  360. margin-top: 4rpx;
  361. .income-menu-time-filter-text {
  362. font-weight: 400;
  363. font-size: 26rpx;
  364. color: #000000;
  365. display: flex;
  366. align-items: center;
  367. gap: 12rpx;
  368. }
  369. }
  370. .income-header-menu-list {
  371. background: #ffffff;
  372. .income-header-menu-item {
  373. height: 88rpx;
  374. display: flex;
  375. justify-content: space-between;
  376. align-items: center;
  377. border-bottom: 1px solid #eeeeee;
  378. padding: 32rpx 0 29rpx;
  379. margin: 0 20rpx;
  380. &:last-child {
  381. border-bottom: none;
  382. }
  383. .income-header-menu-icon {
  384. display: flex;
  385. justify-content: center;
  386. align-items: center;
  387. gap: 19rpx;
  388. image {
  389. width: 60rpx;
  390. height: 60rpx;
  391. }
  392. .income-header-menu-text {
  393. font-weight: 400;
  394. font-size: 24rpx;
  395. color: #888888;
  396. .income-header-menu-text-nickname {
  397. font-size: 28rpx;
  398. color: #222222;
  399. margin-bottom: 18rpx;
  400. }
  401. }
  402. }
  403. .income-header-menu-left {
  404. font-weight: 400;
  405. font-size: 24rpx;
  406. color: #888888;
  407. .income-header-menu-left-amount {
  408. font-size: 28rpx;
  409. color: #222222;
  410. margin-bottom: 18rpx;
  411. text-align: right;
  412. }
  413. }
  414. }
  415. }
  416. }
  417. }
  418. </style>