school_photo_upload.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <view class="container">
  3. <!-- 分段器区域 -->
  4. <common-controlTag :tagList="tagList" :currentIndex="currentIndex" @change="handleChange"></common-controlTag>
  5. <view v-if="currentIndex == 0">
  6. <school-photo-upload-box :type="type" :currentId="currentId" @change="changeIndex"></school-photo-upload-box>
  7. </view>
  8. <view v-if="currentIndex == 1">
  9. <school-photo-upload-my :type="type"></school-photo-upload-my>
  10. </view>
  11. </view>
  12. </template>
  13. <script setup>
  14. import { onLoad } from '@dcloudio/uni-app'
  15. import { ref } from 'vue'
  16. // 1为活动相册 2为校友相册
  17. const type = ref()
  18. // 分段器数组
  19. const tagList = ['上传照片', '我上传的']
  20. // 分段器当前索引
  21. const currentIndex = ref(0)
  22. // 活动ID
  23. const currentId = ref()
  24. onLoad((options) => {
  25. if (options.type) {
  26. type.value = options.type
  27. }
  28. if (options.currentId) {
  29. currentId.value = options.currentId
  30. }
  31. if (options.type == 1) {
  32. uni.setNavigationBarTitle({
  33. title: '上传照片'
  34. })
  35. }
  36. if (options.type == 2) {
  37. uni.setNavigationBarTitle({
  38. title: '校友相册'
  39. })
  40. }
  41. })
  42. // 分段器切换回调
  43. const handleChange = (e) => {
  44. if (currentIndex.value != e) {
  45. currentIndex.value = e
  46. // console.log(e)
  47. }
  48. }
  49. // 自定义事件
  50. const changeIndex = (e) => {
  51. // console.log(e);
  52. currentIndex.value = e
  53. }
  54. </script>
  55. <style lang="scss" scoped>
  56. .container {
  57. padding: 20rpx 18rpx;
  58. min-height: 100vh;
  59. }
  60. </style>