act_album.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view class="container">
  3. <!-- 图片列表区域 -->
  4. <view class="list">
  5. <image v-for="(item, index) in imgList" :key="index" class="img" mode="aspectFill" :src="item" @click="cilckImg(index, imgList)" />
  6. </view>
  7. <!-- 没有数据时展示的页面 -->
  8. <noData v-if="!imgList.length"></noData>
  9. <!-- 上传照片按钮区域 -->
  10. <view class="btn" @click="clickUpload">
  11. <uni-icons type="upload" size="22" color="#fff"></uni-icons>
  12. &nbsp;&nbsp;上传照片
  13. </view>
  14. </view>
  15. </template>
  16. <script setup>
  17. import { onLoad } from '@dcloudio/uni-app'
  18. import { ref } from 'vue'
  19. // 图片数组
  20. const imgList = ref([])
  21. // 活动ID
  22. const currentId = ref()
  23. onLoad((options) => {
  24. if (options.imgList) {
  25. imgList.value = JSON.parse(decodeURIComponent(options.imgList))
  26. }
  27. if (options.currentId) {
  28. currentId.value = options.currentId
  29. }
  30. })
  31. // 点击上传照片的回调
  32. const clickUpload = () => {
  33. uni.navigateTo({
  34. url: `/pages/school_photo_upload/school_photo_upload?type=1&currentId=${currentId.value}`
  35. })
  36. }
  37. // 点击图片回调
  38. const cilckImg = (current, urls) => {
  39. uni.previewImage({
  40. urls,
  41. current
  42. })
  43. }
  44. </script>
  45. <style lang="scss" scoped>
  46. .container {
  47. padding: 20rpx 18rpx;
  48. min-height: 100vh;
  49. .list {
  50. display: grid;
  51. grid-template-columns: repeat(3, 1fr);
  52. gap: 20rpx;
  53. .img {
  54. width: 220rpx;
  55. height: 220rpx;
  56. border-radius: 10rpx;
  57. }
  58. }
  59. .btn {
  60. position: fixed;
  61. left: 50%;
  62. bottom: 30rpx;
  63. transform: translateX(-50%);
  64. display: flex;
  65. align-items: center;
  66. justify-content: center;
  67. width: 243rpx;
  68. height: 100rpx;
  69. color: #fff;
  70. font-size: 28rpx;
  71. border-radius: 8rpx;
  72. background-color: #007aff;
  73. }
  74. }
  75. </style>