photo_classify.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view class="photoClassify">
  3. <view
  4. v-for="item in classifyList"
  5. :key="item.id"
  6. class="classifyItem"
  7. @click="toClassifyImgs(item)"
  8. >
  9. <image :src="item.cover.thumbnail" class="classifyItem-img" mode="widthFix"></image>
  10. <view>{{ item.image_name }}</view>
  11. <view>{{ item.total || 0 }}张</view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. import { getPhotoClassify } from "../../api/album.js"
  17. export default {
  18. data() {
  19. return {
  20. classifyList: []
  21. }
  22. },
  23. onLoad(e) {
  24. getPhotoClassify({ id: e.id }).then(res => {
  25. if(res.code === 200) {
  26. this.classifyList = res.data.list
  27. } else {
  28. uni.showModal({
  29. content: res.message || '获取相册分类失败',
  30. showCancel: false
  31. })
  32. }
  33. }).catch(() => {
  34. uni.showModal({
  35. content: '获取相册分类失败',
  36. showCancel: false
  37. })
  38. })
  39. },
  40. methods: {
  41. toClassifyImgs(item) {
  42. if(!item.total || item.total === 0) {
  43. uni.showModal({
  44. content: '暂无图片',
  45. showCancel: false
  46. })
  47. return false
  48. }
  49. uni.navigateTo({
  50. url: '../photos/photos?title=' + item.image_name + '&activity_id=' + item.activity_id + '&id=' + item.id + '&type=1'
  51. });
  52. }
  53. }
  54. }
  55. </script>
  56. <style lang="scss" scoped>
  57. .photoClassify {
  58. width: 100%;
  59. padding: 40rpx 30rpx;
  60. display: flex;
  61. align-items: center;
  62. flex-wrap: wrap;
  63. justify-content: flex-start;
  64. .classifyItem {
  65. width: calc((100% - 30rpx) / 2);
  66. margin-bottom: 30rpx;
  67. &:nth-of-type(2n) {
  68. margin-left: 30rpx;
  69. }
  70. &-img {
  71. display: block;
  72. width: 100%;
  73. height: 268rpx;
  74. margin-bottom: 20rpx;
  75. border-radius: 16rpx;
  76. }
  77. &-title {
  78. color: #333333;
  79. font-size: 32rpx;
  80. line-height: 44rpx;
  81. margin-bottom: 12rpx;
  82. }
  83. }
  84. }
  85. </style>