PreviewPicture.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <!-- PreviewPicture.vue -->
  2. <template>
  3. <view class="div" v-if="detailInfo">
  4. <uni-popup background-color="#fff" ref="isshow" type="right" >
  5. <view :style="'width:'+screenWidth+'px'" class="common-popup-wrapper">
  6. <view class="div preview-picture">
  7. <title-header />
  8. <view
  9. class="div picture-header"
  10. v-on:click="closePopup()"
  11. >
  12. <text class="span">关闭</text
  13. ><text class="span">商品详情</text
  14. >
  15. </view>
  16. <view class="div picture-body">
  17. <image mode="aspectFit" class="img" v-if="detailInfo.pgoods_image" v-bind:src="detailInfo.pgoods_image" @click="setPopHeader()" />
  18. </view>
  19. </view>
  20. </view>
  21. </uni-popup>
  22. </view>
  23. </template>
  24. <script>
  25. import TitleHeader from '../../../TitleHeader'
  26. import { mapState, mapMutations } from 'vuex'
  27. export default {
  28. data(){
  29. return {
  30. screenWidth:0,
  31. isshowPopHeader: false
  32. }
  33. },
  34. props: {
  35. },
  36. components:{
  37. TitleHeader
  38. },
  39. computed: {
  40. ...mapState({
  41. isPreviewPicture: state => state.goodsdetail.isPreviewPicture,
  42. detailInfo: state => state.pointsgoods.detailInfo
  43. })
  44. },
  45. mounted(){
  46. this.screenWidth=uni.getSystemInfoSync().screenWidth
  47. },
  48. watch: {
  49. isPreviewPicture: function (value) {
  50. if(value){
  51. this.showPopup('isshow')
  52. }else{
  53. this.hidePopup('isshow')
  54. }
  55. },
  56. },
  57. methods:{
  58. showPopup(id){
  59. this.$refs[id].open()
  60. },
  61. hidePopup(id){
  62. this.$refs[id].close()
  63. },
  64. ...mapMutations({
  65. setisPreviewPicture: 'setisPreviewPicture'
  66. }),
  67. /*
  68. * closePopup: 关闭图片预览
  69. */
  70. closePopup () {
  71. this.setisPreviewPicture(false)
  72. uni.$emit('hide-priview-picture', false)
  73. },
  74. /*
  75. * setPopHeader: 预览大图点击图片切换header
  76. */
  77. setPopHeader (ev) {
  78. this.isshowPopHeader = !this.isshowPopHeader
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .preview-picture {
  85. width: 100%;
  86. height: 100%;
  87. position: fixed;
  88. z-index: 10;
  89. top: 0;
  90. bottom: 0;
  91. left: 0;
  92. right: 0;
  93. background-color: #000;
  94. display: flex;
  95. flex-direction: column;
  96. .picture-header {
  97. color: #000;
  98. background-color: #fff;
  99. display: flex;
  100. justify-content: center;
  101. align-content: center;
  102. align-items: center;
  103. width: 100%;
  104. top: 0;
  105. padding-top:var(--status-bar-height);
  106. .span {
  107. font-size:$subFontSize;
  108. font-weight: normal;
  109. height:2.2rem;
  110. line-height:2.2rem;
  111. &:first-child {
  112. position: absolute;
  113. cursor: pointer;
  114. left:0.75rem;
  115. background-size:1.2rem;
  116. display: inline-block;
  117. height:2.2rem;
  118. line-height:2.2rem;
  119. }
  120. }
  121. }
  122. .picture-body {
  123. flex:1;
  124. display: flex;
  125. justify-content: center;
  126. align-content: center;
  127. align-items: center;
  128. .img{width:100%}
  129. }
  130. }
  131. </style>