pic.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template name="pic">
  2. <view class="cover cover-height">
  3. <block v-if="item.text.length > 0">
  4. <image v-show="loaded" @click="Dever.viewPic([item.pic], item.pic)" :src="item.pic" mode="widthFix" :class="['default', 'slide-image', 'slide-image-'+item.type]" @error="onError" @load="onSuccess" style="height:auto"></image>
  5. <ourLoading v-show="!loaded" active text="加载中..." />
  6. <dever-position :item="item.text" :down="item.pic" :button="item.is_button"></dever-position>
  7. </block>
  8. <block v-if="item.text.length <= 0">
  9. <image v-show="loaded" @click="Dever.viewPic([item.pic], item.pic)" :src="item.pic" mode="widthFix" :class="['default', 'slide-image', 'slide-image-'+item.type]" @error="onError" @load="onSuccess" style="height:auto"></image>
  10. <ourLoading v-show="!loaded" active text="加载中..." />
  11. </block>
  12. </view>
  13. </template>
  14. <script>
  15. import deverPosition from "@/lib/dever/components/position.vue";
  16. export default {
  17. name: "pic",
  18. props: {
  19. control : {
  20. type : Object,
  21. value : null
  22. },
  23. item : {
  24. type : Object,
  25. value : null
  26. },
  27. index : 0,
  28. pic_index : 0,
  29. },
  30. data() {
  31. return {
  32. loaded : false
  33. };
  34. },
  35. methods:{
  36. onSuccess : function(e) {
  37. this.onImg(e);
  38. this.loaded = true;
  39. },
  40. onError : function(e) {
  41. this.loaded = false;
  42. },
  43. onImg : function(e) {
  44. var height = e.detail.height / (e.detail.width / this.Dever.config.system.windowWidth);
  45. this.$emit('setHeight', this.pic_index, height);
  46. }
  47. },
  48. components:{
  49. deverPosition
  50. }
  51. }
  52. </script>
  53. <style>
  54. .cover{
  55. position: relative;
  56. width: 100%;
  57. height: 100%;
  58. }
  59. .cover-height{
  60. overflow: auto;
  61. position: absolute;
  62. top:0;
  63. left:0;
  64. width:100%;
  65. height:100%;
  66. }
  67. .slide-image {
  68. }
  69. .slide-image-1 {
  70. width: 750rpx;
  71. height: 1386rpx;
  72. display: block;
  73. }
  74. .slide-image-2 {
  75. width: 2000rpx;
  76. height: 100%;
  77. display: block;
  78. }
  79. .long-wrapper {
  80. position: relative;
  81. }
  82. </style>