single_row.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <image v-if="props.url" @load="loaded" :style="'width:'+ headImg.w +'px;height:'+ headImg.h +'px'" :src="props.url"
  3. mode="scaleToFill"></image>
  4. <image class="col_img" :style=" item.style ? 'width:'+ item.style.w +'px;height:' + item.style.h + 'px' : ''"
  5. @load="v=>loadIndex(v,i, item.isRow)" :src="item.avatar" @click="()=>toPDF(i)" v-for="(item,i) in list"
  6. :key="i" mode="scaleToFill"></image>
  7. </template>
  8. <script setup>
  9. import {
  10. ref,
  11. defineProps
  12. } from "vue";
  13. import config from "../../config/index.js";
  14. import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
  15. onShareAppMessage(()=>{})
  16. onShareTimeline(()=>{})
  17. const info = uni.getSystemInfoSync();
  18. const props = defineProps({
  19. title: String,
  20. url: String,
  21. page: String
  22. })
  23. uni.setNavigationBarTitle({
  24. title: props.title
  25. })
  26. const list = ref([]);
  27. uni.request({
  28. url: config.base + props.page + ".json?" + Date.now(),
  29. success: res => {
  30. if (res.statusCode !== 200) return
  31. list.value = res.data || [];
  32. }
  33. })
  34. const headImg = ref({
  35. w: 0,
  36. h: 0
  37. })
  38. function loaded(v) {
  39. const w = info.windowWidth;
  40. const h = v.detail.height / v.detail.width * w;
  41. headImg.value = {
  42. w,
  43. h
  44. }
  45. }
  46. function loadIndex(v, i, isRow) {
  47. const oW = isRow ? info.windowWidth : info.windowWidth / 2;
  48. const w = oW - 8;
  49. const h = v.detail.height / v.detail.width * w;
  50. list.value[i].style = {
  51. w,
  52. h
  53. };
  54. }
  55. function toPDF(i) {
  56. uni.navigateTo({
  57. url: "/pages/detail/detail?index=" + i + "&page=" + props.page
  58. })
  59. }
  60. </script>
  61. <style lang="scss">
  62. .col_img {
  63. display: inline-block;
  64. margin: 4px 0 0 4px;
  65. border-radius: 7px;
  66. }
  67. </style>