school-photo-upload-my.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <view class="content">
  3. <!-- 选择时间区域 -->
  4. <view class="time">
  5. <view class="time_box" :class="{ active: currentIndex == index }" v-for="(item, index) in timeList" :key="index" @click="changeTimeIndex(index)">
  6. {{ item }}
  7. </view>
  8. </view>
  9. <!-- 列表区域 -->
  10. <view class="list">
  11. <view class="list_box" v-for="item in dataList" :key="item.id">
  12. <image class="img" mode="aspectFill" :src="item.images[0]" @click="clickImg(item.images)"></image>
  13. <view v-if="item.isPass == 1" class="status ing">审核中...</view>
  14. <view v-if="item.isPass == 2" class="status pass">审批通过</view>
  15. <view v-if="item.isPass == 3" class="status nopass">驳回</view>
  16. <view v-if="item.isPass == 3" class="msg">照片违规,请重新提交</view>
  17. </view>
  18. <noData v-if="!dataList.length"></noData>
  19. </view>
  20. </view>
  21. </template>
  22. <script setup>
  23. import { onReachBottom } from '@dcloudio/uni-app'
  24. import { ref, onMounted } from 'vue'
  25. import { getMyImagePage, getMyUploadPage } from '@/api/index.js'
  26. const $props = defineProps(['type'])
  27. // 页面类型 1为活动相册 2为校友相册
  28. const type = ref()
  29. // 分段器数组
  30. const timeList = ['全部', '审核中', '审核通过', '驳回']
  31. // 分段器当前索引
  32. const currentIndex = ref(0)
  33. // 当前页
  34. const currentPage = ref(1)
  35. // 每页多少条
  36. const pageCount = ref(6)
  37. // 总条数
  38. const total = ref(0)
  39. // 列表数据
  40. const dataList = ref([])
  41. onMounted(() => {
  42. type.value = $props.type
  43. if ($props.type == 1) {
  44. // 活动相册
  45. getData_act()
  46. }
  47. if ($props.type == 2) {
  48. // 校友相册
  49. getData()
  50. }
  51. })
  52. // 页面触底触发的回调
  53. onReachBottom(() => {
  54. if (total.value > dataList.value.length) {
  55. currentPage.value++
  56. if (type.value == 1) {
  57. getData_act()
  58. } else {
  59. getData()
  60. }
  61. } else {
  62. uni.showToast({
  63. title: '没有更多数据了~~',
  64. icon: 'none'
  65. })
  66. }
  67. })
  68. // 获取我上传的活动图片分页数据
  69. const getData_act = async () => {
  70. let data = {
  71. currentPage: currentPage.value,
  72. pageCount: pageCount.value,
  73. isPass: currentIndex.value
  74. }
  75. const res = await getMyUploadPage(data)
  76. // console.log(res);
  77. dataList.value = [...dataList.value, ...res.data.list]
  78. total.value = res.data.totalCount
  79. }
  80. // 获取我上传的校友相册分页数据
  81. const getData = async () => {
  82. let data = {
  83. currentPage: currentPage.value,
  84. pageCount: pageCount.value,
  85. isPass: currentIndex.value
  86. }
  87. const res = await getMyImagePage(data)
  88. // console.log(res)
  89. dataList.value = [...dataList.value, ...res.data.list]
  90. total.value = res.data.totalCount
  91. }
  92. // 分段器切换回调
  93. const changeTimeIndex = (e) => {
  94. if (e != currentIndex.value) {
  95. currentIndex.value = e
  96. currentPage.value = 1
  97. dataList.value = []
  98. if (type.value == 1) {
  99. getData_act()
  100. } else {
  101. getData()
  102. }
  103. }
  104. }
  105. // 点击图片回调
  106. const clickImg = (urls) => {
  107. uni.previewImage({
  108. urls
  109. })
  110. }
  111. </script>
  112. <style lang="scss" scoped>
  113. .content {
  114. .time {
  115. display: flex;
  116. align-items: center;
  117. justify-content: space-around;
  118. margin-top: 20rpx;
  119. width: 712rpx;
  120. height: 90rpx;
  121. font-size: 28rpx;
  122. border-radius: 8rpx;
  123. background-color: #f2f7ff;
  124. .time_box {
  125. display: flex;
  126. align-items: center;
  127. justify-content: center;
  128. width: 211rpx;
  129. height: 71rpx;
  130. border-radius: 8rpx;
  131. }
  132. .active {
  133. font-size: 30rpx;
  134. color: #0061ff;
  135. border: 2rpx solid #0061ff;
  136. background-color: rgba(0, 97, 255, 0.1);
  137. }
  138. }
  139. .list {
  140. margin-top: 40rpx;
  141. .list_box {
  142. position: relative;
  143. display: flex;
  144. justify-content: space-between;
  145. align-items: center;
  146. height: 200rpx;
  147. border-bottom: 2rpx solid #e5e5e5;
  148. .img {
  149. width: 140rpx;
  150. height: 140rpx;
  151. border-radius: 8rpx;
  152. }
  153. .status {
  154. display: flex;
  155. justify-content: center;
  156. align-items: center;
  157. width: 157rpx;
  158. height: 55rpx;
  159. color: #fff;
  160. font-size: 28rpx;
  161. border-radius: 70rpx 40rpx 0 70rpx;
  162. }
  163. .pass {
  164. background: linear-gradient(90deg, #366fff 0%, #5da0fc 100%);
  165. }
  166. .ing {
  167. background: linear-gradient(90deg, #ff7045 0%, #f7a172 100%);
  168. }
  169. .nopass {
  170. background: linear-gradient(90deg, #d43030 0%, #f56c6c 100%);
  171. }
  172. .msg {
  173. position: absolute;
  174. top: 36rpx;
  175. left: 157rpx;
  176. width: 360rpx;
  177. font-size: 24rpx;
  178. color: #d43030;
  179. }
  180. }
  181. }
  182. }
  183. </style>