ImagePopup.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <view class="popup-mask" v-if="visible" @click="handleClose">
  3. <view class="popup-content" @click.stop>
  4. <view class="close-btn" @click="handleClose">×</view>
  5. <image class="popup-image" :src="imageUrl" mode="widthFix"></image>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. name: 'ImagePopup',
  12. props: {
  13. imageUrl: {
  14. type: String,
  15. default: '',
  16. },
  17. storageKey: {
  18. type: String,
  19. default: 'version_shown',
  20. },
  21. },
  22. data() {
  23. return {
  24. visible: false,
  25. };
  26. },
  27. mounted() {
  28. // this.checkAndShowPopup();
  29. },
  30. methods: {
  31. checkAndShowPopup() {
  32. const hasShown = uni.getStorageSync(this.storageKey);
  33. if (!hasShown) {
  34. this.visible = true;
  35. }
  36. },
  37. handleClose() {
  38. this.visible = false;
  39. uni.setStorage({
  40. key: this.storageKey,
  41. data: true,
  42. });
  43. this.$emit('close');
  44. },
  45. },
  46. };
  47. </script>
  48. <style lang="less" scoped>
  49. .popup-mask {
  50. position: fixed;
  51. top: 0;
  52. left: 0;
  53. width: 100%;
  54. height: 100%;
  55. background-color: rgba(0, 0, 0, 0.7);
  56. z-index: 9999;
  57. display: flex;
  58. justify-content: center;
  59. align-items: center;
  60. .popup-content {
  61. position: relative;
  62. width: 85%;
  63. max-width: 600rpx;
  64. background-color: transparent;
  65. border-radius: 16rpx;
  66. box-sizing: border-box;
  67. .close-btn {
  68. position: absolute;
  69. bottom: -60rpx;
  70. left: 50%;
  71. transform: translateX(-50%);
  72. width: 56rpx;
  73. height: 56rpx;
  74. line-height: 48rpx;
  75. text-align: center;
  76. font-size: 40rpx;
  77. color: #999;
  78. background-color: rgba(255, 255, 255, 0.9);
  79. border-radius: 50%;
  80. border: 2rpx solid #ddd;
  81. z-index: 10;
  82. cursor: pointer;
  83. &:active {
  84. background-color: #f5f5f5;
  85. }
  86. }
  87. .popup-image {
  88. width: 100%;
  89. border-radius: 8rpx;
  90. }
  91. }
  92. }
  93. </style>