detail.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="detail_body" v-if="item.avatar">
  3. <image v-if="item.avatar" @load="loaded" :style="'width:'+ headImg.w +'px;height:'+ headImg.h +'px'"
  4. :src="item.avatar" mode="scaleToFill"></image>
  5. <view class="dl" v-if="typeof item.introduction === 'string'" v-text="item.introduction"></view>
  6. <view class="dl" v-else v-for="(v, i) in item.introduction" v-text="v" :key="i"></view>
  7. <view class="btn" @click="()=>showPDF(item.pdfUrl)">
  8. 详情
  9. </view>
  10. <view style="display: flex;margin-top: 5em;" v-if="item.pdfUrl_z && item.pdfUrl_z.length">
  11. <local-select @open="()=>open(i)" @change="url=>change(i, url)" v-for="(v,i) in item.pdfUrl_z" :key="i"
  12. style="flex: 1;" :url="v.url" :fOpen="v.fOpen" :btnText="v.text" :list="v.child"></local-select>
  13. </view>
  14. </view>
  15. </template>
  16. <script setup>
  17. import {
  18. ref
  19. } from "vue";
  20. import {
  21. showPDF
  22. } from "../../unit/index.js";
  23. import config from "../../config/index.js";
  24. import localSelect from "./select.vue"
  25. import {
  26. onShareAppMessage,
  27. onShareTimeline,
  28. onLoad
  29. } from '@dcloudio/uni-app'
  30. const App = getApp();
  31. const info = uni.getSystemInfoSync();
  32. const item = ref({});
  33. onShareAppMessage(() => {})
  34. onShareTimeline(() => {})
  35. onLoad(option => {
  36. console.log(option) // 所属数列
  37. uni.request({
  38. url: config.base + option.page + ".json?" + Date.now(),
  39. success: res => {
  40. if (res.statusCode !== 200) return
  41. item.value = res.data[option.index];
  42. }
  43. })
  44. })
  45. const headImg = ref({
  46. w: 0,
  47. h: 0
  48. })
  49. function loaded(v) {
  50. const w = info.windowWidth;
  51. const h = v.detail.height / v.detail.width * w;
  52. headImg.value = {
  53. w,
  54. h
  55. }
  56. }
  57. function change(i, url) {
  58. const pdfURl = url ? url : item.value.pdfUrl_z[i].pdfurl;
  59. showPDF(pdfURl);
  60. }
  61. function open(i) {
  62. item.value.pdfUrl_z[i].fOpen = !item.value.pdfUrl_z[i].fOpen
  63. }
  64. </script>
  65. <style lang="scss">
  66. .detail_body {
  67. background-color: #fff;
  68. height: 100vh;
  69. padding-bottom: 1.5em;
  70. overflow-y: auto;
  71. .dl {
  72. padding: .2em .5em;
  73. text-indent: 2em;
  74. }
  75. .btn {
  76. width: 50%;
  77. margin: 2.5em auto;
  78. text-align: center;
  79. border-radius: 5px;
  80. background-color: #b5bdc3;
  81. line-height: 2.5em;
  82. color: #fff;
  83. }
  84. }
  85. </style>