Parcourir la source

fix:以图识图 样式优化

zhangxin il y a 1 semaine
Parent
commit
3ee9e0a11b

+ 55 - 9
components/remote-search-select/index.scss

@@ -83,16 +83,62 @@
83 83
       color: #909399;
84 84
     }
85 85
   }
86
-}
87
-.img-preview-container{
88
-  margin:70rpx 40rpx;
89
-  .img-result-list {
90
-    max-height: 1200rpx;
91
-    ::v-deep .uni-scroll-view-content{
92
-      display: grid;
93
-      grid-template-columns: 1fr 1fr;
94
-      gap: 20rpx;
86
+  .img-preview-container {
87
+    margin: 70rpx 40rpx;
88
+    
89
+    .image-section {
90
+      transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
91
+      
92
+      .image-container {
93
+        display: flex;
94
+        justify-content: center;
95
+        align-items: center;
96
+        background-color: #f0f0f0;
97
+        border-radius: 8rpx;
98
+        
99
+        .preview-image {
100
+          width: 100%;
101
+          height: 100%;
102
+          object-fit: contain;
103
+        }
104
+      }
95 105
       
106
+      .confirm-crop-btn-container {
107
+        max-height: 0;
108
+        opacity: 0;
109
+        overflow: hidden;
110
+        display: flex;
111
+        justify-content: flex-end;
112
+        width: 100%;
113
+        transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
114
+        
115
+        &.show {
116
+          max-height: 100rpx;
117
+          opacity: 1;
118
+          margin-top: 20rpx;
119
+          margin-bottom: 10rpx;
120
+        }
121
+        
122
+        .confirm-crop-btn {
123
+          margin: 0;
124
+          width: fit-content;
125
+        }
126
+      }
127
+    }
128
+    
129
+    .img-result-list {
130
+      transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
131
+      max-height: 1200rpx;
132
+      
133
+      &.compressed {
134
+        max-height: 600rpx;
135
+      }
136
+      
137
+      ::v-deep .uni-scroll-view-content {
138
+        display: grid;
139
+        grid-template-columns: 1fr 1fr;
140
+        gap: 20rpx;
141
+      }
96 142
     }
97 143
   }
98 144
   

+ 13 - 5
components/remote-search-select/index.vue

@@ -26,12 +26,12 @@
26 26
         <u-popup title="图片识别结果" :show="show" @open="openImgPopup" mode="bottom" :round="10" :closeOnClickOverlay="false">
27 27
             <view class="img-preview-container" @touchstart="handleTouchStart" @touchmove="handleTouchMove" @touchend="handleTouchEnd">
28 28
                 <view class="image-section" :class="{ 'expanded': isImageExpanded }">
29
-                    <view class="image-container" v-if="currentImg" :style="isImageExpanded ? 'height: 500rpx; width: 670rpx;' : ''">
30
-                        <image v-show="!isImageExpanded" :src="currentImg" class="preview-image" :class="{ 'zoomed': isImageExpanded }" @load="handleImageLoad" id="previewImage"></image>
29
+                    <view class="image-container" v-if="currentImg" :style="imageContainerStyle">
30
+                        <image v-show="!isImageExpanded" :src="currentImg" class="preview-image" @load="handleImageLoad" id="previewImage"></image>
31 31
                         <bt-cropper v-if="isImageExpanded" ref="cropper" :imageSrc="currentImg" :ratio="0" :fileType="fileType" :key="currentImg" :containerSize="{width: 670, height: 500}" @loadFail="handleCropLoadFail"></bt-cropper>
32
-                        <view v-if="isImageExpanded" class="confirm-crop-btn">
33
-                            <u-button type="primary" size="mini" @click="confirmCrop">确认裁剪</u-button>
34
-                        </view>
32
+                    </view>
33
+                    <view class="confirm-crop-btn-container" :class="{ 'show': isImageExpanded }">
34
+                        <u-button class="confirm-crop-btn" type="primary" size="mini" @click="confirmCrop">确认裁剪</u-button>
35 35
                     </view>
36 36
 
37 37
                     <view class="img-result-container">
@@ -173,6 +173,14 @@ export default {
173 173
         }
174 174
     },
175 175
     computed: {
176
+        imageContainerStyle() {
177
+            return {
178
+                height: this.isImageExpanded ? '500rpx' : '300rpx', // 给一个基础高度以使过渡平滑
179
+                width: '670rpx',
180
+                transition: 'all 0.4s cubic-bezier(0.25, 1, 0.5, 1)',
181
+                overflow: 'hidden'
182
+            };
183
+        },
176 184
         currentImg:{
177 185
             get(){
178 186
                 return this.localCurrentImg || ''