index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <script lang="ts" setup>
  2. import { storeToRefs } from 'pinia'
  3. import { ref } from 'vue'
  4. import FilterTime from '@/components/FilterTime.vue'
  5. import { LOGIN_PAGE } from '@/router/config'
  6. import { useUserStore } from '@/store'
  7. import { useTokenStore } from '@/store/token'
  8. import { changtime, menuButtonInfo, safeAreaInsets, systemInfo } from '@/utils'
  9. definePage({
  10. style: {
  11. navigationBarTitleText: '提现明细',
  12. },
  13. })
  14. const userStore = useUserStore()
  15. const tokenStore = useTokenStore()
  16. // 使用storeToRefs解构userInfo
  17. const { userInfo } = storeToRefs(userStore)
  18. function menuClick(page: string) {
  19. uni.navigateTo({
  20. url: `/pages-A/${page}/index`,
  21. })
  22. }
  23. const show = ref(false)
  24. // up-datetime-picker 返回字符串格式,FilterTime 返回数组格式
  25. const filterValue = ref<string[] | string>([])
  26. function confirm(value) {
  27. // up-datetime-picker 组件确认时保持字符串格式 YYYY-MM
  28. console.log(111, value)
  29. filterValue.value = changtime(value.value, 'YYYY年MM月')
  30. show.value = false
  31. }
  32. function cancel() {
  33. show.value = false
  34. }
  35. function close() {
  36. show.value = false
  37. }
  38. function showTimeFilter() {
  39. show.value = true
  40. }
  41. // 处理时间选择变化
  42. function handleTimeChange(value: string | string[]) {
  43. console.log('时间选择变化', value)
  44. filterValue.value = value
  45. }
  46. // 格式化时间显示
  47. function formatTimeDisplay() {
  48. console.log('formatTimeDisplay1111', filterValue.value)
  49. // 处理 filterValue 是字符串的情况(单个月份)
  50. if (typeof filterValue.value === 'string') {
  51. return filterValue.value
  52. }
  53. // 处理 filterValue 是数组的情况(时间范围)
  54. if (!filterValue.value || !filterValue.value[0] || !filterValue.value[1]) {
  55. // 当天的YYYY年MM月
  56. return changtime(new Date(), 'YYYY年MM月')
  57. }
  58. return `${filterValue.value[0]} 至 ${filterValue.value[1]}`
  59. }
  60. const wjsList = ref([
  61. {
  62. id: 1,
  63. nickName: '昵称1',
  64. name: '优惠券1',
  65. price: 1000,
  66. date: '2023-08-01 10:00:00',
  67. },
  68. {
  69. id: 2,
  70. nickName: '昵称2',
  71. name: '优惠券2',
  72. price: 1300,
  73. date: '2023-10-01 10:00:00',
  74. },
  75. ])
  76. const yjsList = ref([
  77. {
  78. id: 1,
  79. nickName: '昵称3',
  80. name: '优惠券3',
  81. price: 2300,
  82. date: '2023-10-01 10:00:00',
  83. },
  84. {
  85. id: 2,
  86. nickName: '昵称4',
  87. name: '优惠券4',
  88. price: 300,
  89. date: '2023-10-01 10:00:00',
  90. },
  91. ])
  92. const list = ref([])
  93. onLoad(() => {
  94. list.value = [...wjsList.value]
  95. })
  96. function goPage(page: string) {
  97. uni.navigateTo({
  98. url: `/pages-A/${page}/index`,
  99. })
  100. }
  101. const filterTimeRef = ref()
  102. function openDatePicker() {
  103. // 调用子组件的方法
  104. filterTimeRef.value.openPopup()
  105. }
  106. </script>
  107. <template>
  108. <view class="profile-container">
  109. <!-- 时间筛选 -->
  110. <view class="income-menu-time-filter">
  111. <view class="income-menu-time-filter-left">
  112. <view class="income-menu-time-filter-text" @click="showTimeFilter">
  113. <text>{{ formatTimeDisplay() }}</text>
  114. <up-icon name="arrow-down" color="#666666" size="14" />
  115. </view>
  116. <view>合计:¥4396.00</view>
  117. </view>
  118. <view class="income-menu-time-filter-right" @click="openDatePicker">
  119. 日期筛选
  120. </view>
  121. </view>
  122. <view class="income-header-menu">
  123. <!-- 优惠券列表 -->
  124. <view class="income-header-menu-list">
  125. <view v-for="item in list" :key="item.id" class="income-header-menu-item">
  126. <view class="income-header-menu-icon">
  127. <image src="@/static/images/income/tx-icon.png" mode="aspectFit" />
  128. <view class="income-header-menu-text">
  129. <view class="income-header-menu-text-nickname">
  130. 提现金额
  131. </view>
  132. <view>2025/10/29 12:44:26</view>
  133. </view>
  134. </view>
  135. <view class="income-header-menu-left">
  136. <view class="income-header-menu-left-amount">
  137. ¥{{ item.price }}
  138. </view>
  139. </view>
  140. </view>
  141. </view>
  142. </view>
  143. <up-datetime-picker
  144. :value="Array.isArray(filterValue) ? filterValue[0] : filterValue"
  145. mode="year-month"
  146. :show="show"
  147. close-on-click-overlay
  148. @confirm="(value) => {
  149. // filterValue.value = value;
  150. confirm(value);
  151. }"
  152. @cancel="cancel"
  153. />
  154. <FilterTime ref="filterTimeRef" v-model="filterValue" @update:value="handleTimeChange" />
  155. </view>
  156. </template>
  157. <style lang="scss" scoped>
  158. .profile-container {
  159. font-family: Alibaba PuHuiTi;
  160. min-height: 100vh;
  161. background-color: #f5f5f5;
  162. line-height: 1;
  163. padding: 20rpx;
  164. .income-menu-time-filter {
  165. height: 83rpx;
  166. display: flex;
  167. justify-content: space-between;
  168. align-items: center;
  169. font-weight: 400;
  170. font-size: 24rpx;
  171. color: #333333;
  172. .income-menu-time-filter-left {
  173. display: flex;
  174. align-items: center;
  175. gap: 39rpx;
  176. .income-menu-time-filter-text {
  177. font-weight: 400;
  178. font-size: 26rpx;
  179. color: #000000;
  180. display: flex;
  181. align-items: center;
  182. gap: 12rpx;
  183. }
  184. }
  185. .income-menu-time-filter-right {
  186. font-weight: 400;
  187. font-size: 26rpx;
  188. color: #1777ff;
  189. display: flex;
  190. align-items: center;
  191. }
  192. }
  193. .income-header-menu {
  194. .income-header-menu-list {
  195. background: #ffffff;
  196. border-radius: 10rpx;
  197. .income-header-menu-item {
  198. height: 88rpx;
  199. display: flex;
  200. justify-content: space-between;
  201. align-items: center;
  202. border-bottom: 1px solid #eeeeee;
  203. padding: 32rpx 0 29rpx;
  204. margin: 0 26rpx;
  205. &:last-child {
  206. border-bottom: none;
  207. }
  208. .income-header-menu-icon {
  209. display: flex;
  210. justify-content: center;
  211. align-items: center;
  212. gap: 19rpx;
  213. image {
  214. width: 60rpx;
  215. height: 60rpx;
  216. }
  217. .income-header-menu-text {
  218. font-weight: 400;
  219. font-size: 24rpx;
  220. color: #888888;
  221. .income-header-menu-text-nickname {
  222. font-size: 28rpx;
  223. color: #222222;
  224. margin-bottom: 18rpx;
  225. }
  226. }
  227. }
  228. .income-header-menu-left {
  229. height: 100%;
  230. line-height: 100%;
  231. font-weight: 500;
  232. font-size: 24rpx;
  233. color: #888888;
  234. display: flex;
  235. align-items: center;
  236. .income-header-menu-left-amount {
  237. font-size: 30rpx;
  238. color: #222222;
  239. margin-bottom: 18rpx;
  240. }
  241. }
  242. }
  243. }
  244. }
  245. }
  246. </style>