xiuli.gao 1 rok temu
rodzic
commit
b6657e49d0

+ 10 - 3
project/src/components/assembly/editCon.vue

@@ -197,7 +197,7 @@
197 197
           <el-upload class="avatar-uploader" :action="URL.BASEURL + URL.material_upload" name="material_file"
198 198
             :show-file-list="false" :data="fileData2" :on-success="uploadSuccess" :on-progress='beforeUploadUpload'
199 199
             :on-error='uploadFail' accept=".jpg,.jpeg,.png">
200
-            <img v-if="miniprogram.pic_url" :src="miniprogram.pic_url" class="fm_img">
200
+            <img v-if="miniprogram.pic_url" :src="miniprogram.pic_url" class="fm_img" style="height:80px;">
201 201
             <i v-else class="el-icon-plus avatar-uploader-icon"></i>
202 202
           </el-upload>
203 203
           <div style="margin-left:40px;">
@@ -282,7 +282,7 @@
282 282
     />
283 283
     <!-- 图片裁剪弹框 -->
284 284
     <el-dialog width="840px" title="图片裁剪" :visible.sync="imgCutterVisible" append-to-body>
285
-      <imgCutter v-if="imgCutterVisible" :target="oss_url"></imgCutter>
285
+      <imgCutter v-if="imgCutterVisible" :target="oss_url" @imgCutterCallback="imgCutterCallback"></imgCutter>
286 286
     </el-dialog>
287 287
   </div>
288 288
 </template>
@@ -394,6 +394,14 @@ export default {
394 394
     }
395 395
   },
396 396
   methods: {
397
+    // 图片裁剪回调
398
+    imgCutterCallback(obj){
399
+      this.imgCutterVisible = false;
400
+      if ( obj.flag ){
401
+        this.miniprogram.pic_url = obj.data.url
402
+        this.miniprogram.pic_media_id = obj.data.material_id;
403
+      }
404
+    },
397 405
     openImgCutter(){ // 打开图片裁剪
398 406
       if ( this.miniprogram.pic_url ) {
399 407
         this.$loading(this.$loadingConfig)
@@ -773,7 +781,6 @@ export default {
773 781
     },
774 782
     // 批量导入链接 - 确定
775 783
     onConfirmMultipleLink(res) {
776
-      console.log('onConfirmMultipleLink => ', res)
777 784
       this.multipleLinkVisible = false
778 785
       if (Array.isArray(res) && res.length) {
779 786
         res.forEach(item => {

+ 14 - 7
project/src/components/assembly/imgCutter.vue

@@ -1,7 +1,16 @@
1 1
 <template>
2 2
 <div>
3
-  <ImgCutter ref="imgCutterModal" v-loading="loadCut" :isModal="false" :sizeChange="true" :scaleAble="false" :originalGraph="true" rate="65:52" @cutDown="cutDown" @onClearAll="onClearAll">
3
+  <ImgCutter ref="imgCutterModal" v-loading="loadCut" :isModal="false" :sizeChange="true" :scaleAble="false" :originalGraph="true" rate="65:52" @cutDown="cutDown">
4 4
     <template slot="open"><slot></slot></template>
5
+    <template slot="choose">
6
+      <el-button type="primary" plain size="mini">选择图片</el-button>
7
+    </template>
8
+    <template slot="cancel">
9
+      <el-button type="primary" plain size="mini" style="display:none">取消</el-button>
10
+    </template>
11
+    <template slot="confirm">
12
+      <el-button type="primary" size="mini">确定</el-button>
13
+    </template>
5 14
   </ImgCutter>
6 15
 </div>
7 16
 </template>
@@ -71,8 +80,8 @@ export default {
71 80
       },
72 81
        //通过cutDown事件接收选择的图片信息
73 82
        cutDown(event) {
74
-           console.log(event)
75 83
           if (!event.file) {
84
+            this.$emit('imgCutterCallback',{flag:false})
76 85
             this.$message({ message: '图片剪裁失败!', type: "error" })
77 86
             return
78 87
           };
@@ -94,19 +103,17 @@ export default {
94 103
           instance.post(this.URL.BASEURL + this.URL.material_upload,formData).then((res) => {
95 104
             var res = res.data
96 105
             if (res && res.errno == 0) {
97
-
106
+              this.$emit('imgCutterCallback',{flag:true,data:res.rst})
98 107
             } else if (res.errno != 4002) {
108
+              this.$emit('imgCutterCallback',{flag:false})
99 109
               this.$message({ message: res.err, type: "error" })
100 110
             }
101 111
           }).catch((err) => {
112
+            this.$emit('imgCutterCallback',{flag:false})
102 113
             this.$message({ message: '服务器错误,获取裁剪图片失败', type: "error" })
103 114
           });
104 115
 
105 116
        },
106
-      // 清空画布
107
-      onClearAll(){
108
-        console.log('点击了取消')
109
-      },
110 117
     }
111 118
 
112 119
 }