HetongList.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <view class="phone-list-page ht-list-page">
  3. <!-- 导航区域 -->
  4. <customNavbarVue title="我的合同" :show-back-btn="true" @back="goUpPage"></customNavbarVue>
  5. <!-- 课程列表 -->
  6. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  7. :refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh" @scrolltolower="onScrolltolower"
  8. :style="{ height: `calc(100vh - ${statusBarHeight}px - 212rpx);`}" class="admin-phone-tabbar-view">
  9. <uni-list class="admin-list-box ht-list-box">
  10. <uni-list-item v-for="item in data.list" class="ht-list-item-box">
  11. <template v-slot:body>
  12. <view class="ht-card-row">
  13. <view class="ht-status-btn-row">
  14. <view class="ht-status">合同状态:<view :class="'status-' + item.status">{{formatStatus(item.status)}}</view></view>
  15. <view class="ht-biew-btn" @click="checkKecheng(item)">查看
  16. <icon class="ht-jt" :style="{ backgroundImage: 'url(' + data.imgsArr.htjtIcon + ')' }"></icon>
  17. </view>
  18. </view>
  19. <view class="ht-time">
  20. <icon class="phone-time-icon" :style="{ backgroundImage: 'url(' + data.imgsArr.timeIcon + ')' }"/>合同开始时间:{{formatTime(item.startDate)}} </view>
  21. <view class="ht-time">
  22. <icon class="phone-time-icon" :style="{ backgroundImage: 'url(' + data.imgsArr.timeIcon + ')' }"/>合同结束时间:{{formatTime(item.endDate)}} </view>
  23. </view>
  24. </template>
  25. </uni-list-item>
  26. <uni-load-more :status="data.state" @click="getMore(0)" :contentText="data.contentText"></uni-load-more>
  27. </uni-list>
  28. </scroll-view>
  29. <!-- 底部区域 -->
  30. <customTabbarClient :currentTab="0"></customTabbarClient>
  31. </view>
  32. </template>
  33. <script setup>
  34. import {ref,reactive,onMounted} from "vue";
  35. import {onLoad,onShow} from "@dcloudio/uni-app";
  36. import {getHetongList} from '@/api/jzHetong.js'
  37. import customTabbarClient from "@/components/custom-tabbar/custom-tabbar-client.vue"
  38. import customNavbarVue from "@/components/custom-navbar/custom-navbar.vue";
  39. import cacheManager from '@/utils/cacheManager.js'
  40. const statusBarHeight = ref(0);
  41. const data = reactive({
  42. list: [], // 考试列表
  43. loading: false,
  44. page: 0,
  45. size: 10,
  46. state: 'more',
  47. contentText: {
  48. contentdown: '查看更多',
  49. contentrefresh: '加载中',
  50. contentnomore: '没有更多'
  51. },
  52. imgsArr: {
  53. htjtIcon: '',
  54. timeIcon: '',
  55. },
  56. })
  57. onLoad((options) => {
  58. data.from = options.from;
  59. data.imgsArr.htjtIcon = cacheManager.get('projectImg').nav_bar_jt_bottom;
  60. data.imgsArr.timeIcon = cacheManager.get('projectImg').date_icon;
  61. })
  62. onShow(() => {
  63. refreshData()
  64. })
  65. onMounted(() => {
  66. uni.getSystemInfo({
  67. success: (res) => {
  68. statusBarHeight.value = res.statusBarHeight;
  69. }
  70. });
  71. });
  72. function onRefresh() {
  73. data.page = 0;
  74. data.list = [];
  75. data.loading = true;
  76. refreshData();
  77. }
  78. function refreshData() {
  79. const opt = {
  80. page: 1,
  81. size: 10, // 固定查询10条
  82. }
  83. data.list = [];
  84. // 数学
  85. data.state = 'loading';
  86. data.page++;
  87. opt.page = data.page;
  88. console.log('列表',opt)
  89. getHetongList(opt).then(res => {
  90. data.list = data.list.concat(res.data.data);
  91. data.loading = false;
  92. if (res.data.total > data.list.length) {
  93. data.state = 'more';
  94. data.loading = false;
  95. } else {
  96. data.state = 'no-more';
  97. data.loading = false;
  98. }
  99. }).catch(err => {
  100. data.state = 'more';
  101. data.loading = false;
  102. })
  103. }
  104. function getMore() {
  105. const opt = {
  106. page: 1,
  107. size: 10, // 固定查询10条
  108. }
  109. if (data.state == 'no-more') return;
  110. data.state = 'loading';
  111. data.page++;
  112. opt.page = data.page;
  113. getHetongList(opt).then(res => {
  114. console.log('列表2',res.data)
  115. data.list = data.list.concat(res.data.data);
  116. data.loading = false;
  117. if (res.data.total > data.list.length) {
  118. data.state = 'more';
  119. data.loading = false;
  120. } else {
  121. data.state = 'no-more';
  122. data.loading = false;
  123. }
  124. }).catch(err => {
  125. data.state = 'more';
  126. data.loading = false;
  127. })
  128. }
  129. function onScrolltolower() {
  130. getMore()
  131. }
  132. function handleSearch() {
  133. data.page = 0;
  134. refreshData();
  135. }
  136. // 在现有代码底部添加此方法
  137. function formatStatus(status) {
  138. const statusMap = {
  139. 0: '待签字',
  140. 1: '待审核',
  141. 2: '生效',
  142. 3: '失效',
  143. };
  144. return statusMap[status] || '未知状态'; // 处理未知状态
  145. }
  146. function formatTime(data){
  147. return data.split(' ')[0];
  148. }
  149. function checkKecheng(item) {
  150. uni.navigateTo({
  151. url: `/pages/client/hetong/hetongInfo?id=${item.id}`
  152. })
  153. }
  154. function goUpPage() {
  155. uni.navigateBack()
  156. }
  157. </script>
  158. <style>
  159. </style>