useDetail.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view class="container">
  3. <image class="banner" src="@/static/images/mine/back.png" mode="aspectFill" />
  4. <view class="title" :style="{ top: `${paddingTop * 2}rpx` }">
  5. <view class="title_back" @click="handleBack">
  6. <wd-icon name="thin-arrow-left" color="#001713" size="18"></wd-icon>
  7. </view>
  8. 使用明细
  9. </view>
  10. <!-- 选择时间区域 -->
  11. <view class="time">
  12. <wd-datetime-picker type="year-month" v-model="timeValue1" format="yyyy-MM" @confirm="handleConfirm" />
  13. </view>
  14. <!-- 内容区域 -->
  15. <scroll-view scroll-y class="body" @scrolltolower="scrolltolower">
  16. <!-- 每一个明细区域 -->
  17. <view class="body_item" v-for="(item,index) in listData" :key="index">
  18. <view v-if="item.vertifyState==1">
  19. <view class="item_msg">
  20. <view class="">订单号:{{item.orderNum}}</view>
  21. <view class="msg_detail">充值+{{item.account4}}</view>
  22. </view>
  23. <view class="">描述:支付{{item.account4}}
  24. <!-- ,赠送补贴包{{item.account2}} -->
  25. </view>
  26. <view class="item_text">主余额:{{item.account1}}
  27. <!-- 补贴余额:{{item.account2}} 余额:{{item.account5}} -->
  28. </view>
  29. <view class="item_text">{{item.createTime}}</view>
  30. </view>
  31. <view v-if="item.vertifyState==0">
  32. <view class="item_msg">
  33. <view class="">订单号:{{item.orderNum}}</view>
  34. <view class="msg_detail">提现-{{item.account4}}</view>
  35. </view>
  36. <!-- <view class="">描述:支付{{item.account4}},赠送补贴包{{item.account2}}</view> -->
  37. <view class="item_text">主余额:{{item.account1}}
  38. <!-- 补贴余额:{{item.account2}} 余额:{{item.account5}} -->
  39. </view>
  40. <view class="item_text">{{item.createTime}}</view>
  41. </view>
  42. </view>
  43. </scroll-view>
  44. </view>
  45. </template>
  46. <script setup>
  47. import { onMounted, ref ,computed} from 'vue'
  48. import { onLoad, onReachBottom } from '@dcloudio/uni-app'
  49. import { myRequest } from '@/utils/api.ts'
  50. const userInfo = uni.getStorageSync('carUserInfo')
  51. // 胶囊按钮距离页面顶部的距离
  52. const paddingTop = ref(0)
  53. // 当前选择的时间
  54. const timeValue1 = ref(new Date())
  55. const timeValue = ref(new Date())
  56. // 当前选择的时间转换成2025-10格式
  57. const timeTime = ref('')
  58. // 每页多少条数据
  59. const pageSize = ref(6)
  60. // 当前是第几页
  61. const currentPage = ref(1)
  62. // 总共多少条数据
  63. const total = ref(0)
  64. // 预约记录数据
  65. const listData = ref([])
  66. onMounted(() => {
  67. paddingTop.value = uni.getMenuButtonBoundingClientRect().top
  68. })
  69. // 计算属性:将时间戳转换为 Sat Feb 01 2025 08:00:00 GMT+0800 (中国标准时间) 格式
  70. function formattedDate(value){
  71. const date = new Date(value);
  72. return date.toString();
  73. }
  74. // 转换为 "yyyy-MM" 格式
  75. function formattedDate2(value){
  76. // 1. 将字符串转换为 Date 对象
  77. const date = new Date(value);
  78. // 2. 提取年和月(月份需 +1,且补0至2位)
  79. const year = date.getFullYear();
  80. const month = String(date.getMonth() + 1).padStart(2, '0');
  81. // 3. 拼接为 "yyyy-MM" 格式
  82. return `${year}-${month}`;
  83. }
  84. // 计算下一个月
  85. function nextMonth(value1){
  86. // 1. 拆分年和月
  87. const [year, month] = value1.value.split('-').map(Number);
  88. // 2. 月份 +1,若超过12则年份 +1,月份重置为1
  89. let newYear = year;
  90. let newMonth = month + 1;
  91. if (newMonth > 12) {
  92. newYear += 1;
  93. newMonth = 1;
  94. }
  95. // 3. 格式化为 "yyyy-MM"
  96. return `${newYear}-${String(newMonth).padStart(2, '0')}`;
  97. }
  98. // 确认选择时的回调(此时 value 已为 "yyyy-MM" 格式)
  99. const handleConfirm = (value) => {
  100. timeValue.value = formattedDate(value.value)//value; // 直接赋值,保持格式一致
  101. // console.log(11133,timeValue.value,formattedDate(value.value),formattedDate2(timeValue.value))
  102. getMyData()
  103. };
  104. // 获取充值明细数据
  105. async function getMyData() {
  106. const start=formattedDate2(timeValue.value)
  107. timeTime.value=formattedDate2(timeValue.value)
  108. const end=nextMonth(timeTime)
  109. const res = await myRequest({
  110. url: '/cardlist.action',
  111. data: {
  112. mobile: userInfo.mobile,
  113. createStart: start,
  114. createEnd: end,
  115. rows: pageSize.value,
  116. page: currentPage.value
  117. }
  118. })
  119. console.log(res)
  120. listData.value = [...listData.value, ...res.rows]
  121. total.value = res.total
  122. }
  123. onLoad(() => {
  124. getMyData()
  125. console.log(111,timeValue.value)
  126. })
  127. // 页面滚动到底部触发的回调
  128. const scrolltolower = () => {
  129. if (listData.value.length < total.value) {
  130. currentPage.value++
  131. getMyData()
  132. } else {
  133. uni.showToast({
  134. title: '没有更多数据了',
  135. icon: 'none'
  136. })
  137. }
  138. }
  139. // 顶部返回图标回调
  140. const handleBack = () => {
  141. uni.navigateBack()
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .container {
  146. position: relative;
  147. height: 100vh;
  148. color: #001713;
  149. background-color: #fff;
  150. overflow: hidden;
  151. .banner {
  152. width: 100%;
  153. height: 482rpx;
  154. }
  155. .title {
  156. position: absolute;
  157. display: flex;
  158. align-items: center;
  159. width: 100vh;
  160. font-size: 40rpx;
  161. .title_back {
  162. margin-left: 26rpx;
  163. margin-right: 252rpx;
  164. }
  165. }
  166. .time {
  167. position: absolute;
  168. top: 130rpx;
  169. left: 32rpx;
  170. width: 250rpx;
  171. :deep(.wd-cell) {
  172. background-color: transparent;
  173. }
  174. }
  175. .body {
  176. position: absolute;
  177. top: 230rpx;
  178. box-sizing: border-box;
  179. padding: 10rpx 30rpx;
  180. height: calc(100vh - 230rpx);
  181. color: #001713;
  182. font-size: 28rpx;
  183. background-color: #fff;
  184. .body_item {
  185. padding: 20rpx 0;
  186. margin-bottom: 10rpx;
  187. border-bottom: 2rpx solid #d5d5d5;
  188. .item_msg {
  189. display: flex;
  190. align-items: center;
  191. justify-content: space-between;
  192. margin-bottom: 8rpx;
  193. .msg_detail {
  194. font-size: 36rpx;
  195. font-weight: bold;
  196. }
  197. }
  198. .item_text {
  199. margin-top: 12rpx;
  200. color: #aba6a6;
  201. font-size: 24rpx;
  202. }
  203. }
  204. }
  205. }
  206. </style>