From aa3a4d8e28689d33aeb6c2dddb271328f43df1b0 Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Fri, 26 Mar 2021 15:14:55 +0800 Subject: [PATCH] 修复图片选择器小程序中的兼容问题 --- forms/imagePicker/cImagePicker.scss | 7 +++---- forms/textarea/CTextArea.vue | 1 - forms/textarea/cTextArea.scss | 2 +- forms/imagePicker/CImagePicker.vue | 34 +++++++++++++++++++++++++--------- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/forms/imagePicker/CImagePicker.vue b/forms/imagePicker/CImagePicker.vue index fe3507e..c3f7ff5 100644 --- a/forms/imagePicker/CImagePicker.vue +++ b/forms/imagePicker/CImagePicker.vue @@ -66,9 +66,9 @@ const value = this.itemRes.formData[this.itemRes.name]; let files = []; if (Object.prototype.toString.call(value) === '[object String]') { - files = value.split(',').map((url) => ({ url })); + files = value.split(',').map(url => ({ url })); } else if (Object.prototype.toString.call(value) === '[object Array]') { - files = value.map((url) => ({ url })); + files = value.map(url => ({ url })); } files.push({ type: 'btn' }); return files; @@ -77,7 +77,7 @@ methods: { handleChange(files, operationType, index) { const value = []; - files.forEach((file) => { + files.forEach(file => { if (file.type === 'btn') { return; } @@ -104,7 +104,7 @@ const url = $fetcherCommon.getUploadImgURL(); const uploadTeam = []; const imgs = []; - this.files.forEach((file) => { + this.files.forEach(file => { if (file.type === 'btn') { return; } @@ -119,9 +119,16 @@ formData: {}, success(res) { const res2 = - typeof res.data === 'string' ? JSON.parse(res.data) : res.data; + typeof res.data === 'string' + ? JSON.parse(res.data) + : res.data; if (res2.state.code === 2000) { - resolve($fetcherCommon.transImgPath('fix', res2.data.src)); + resolve( + $fetcherCommon.transImgPath( + 'fix', + res2.data.src + ) + ); } else { reject({ message: 'res2.state.msg' }); } @@ -142,19 +149,28 @@ } }); Promise.all(uploadTeam) - .then((res) => { + .then(res => { this.itemRes.onChange(res); setTimeout(() => { callback('success'); }, 0); }) - .catch((err) => { + .catch(err => { callback('error', err); }); }, }, mounted() { - $(this.$refs.input.$el).find('.at-input__input').prepend(this.$refs.picker.$el); + if (process.env.TARO_ENV === 'h5') { + $(this.$refs.input.$el) + .find('.at-input__input') + .prepend(this.$refs.picker.$el); + } else if (process.env.TARO_ENV === 'weapp') { + console.log(this.$refs); + $(this.$refs.input.$el) + .find('.at-input__container') + .append(this.$refs.picker.$el); + } }, }; </script> \ No newline at end of file diff --git a/forms/imagePicker/cImagePicker.scss b/forms/imagePicker/cImagePicker.scss index 2327519..026257a 100644 --- a/forms/imagePicker/cImagePicker.scss +++ b/forms/imagePicker/cImagePicker.scss @@ -9,16 +9,15 @@ .at-input { padding: 0; } - .at-input__input { + .at-input__container { .weui-input { display: none; } .at-image-picker { - padding-bottom: 12px; + padding-bottom: 18px; } .at-image-picker__flex-box { - padding: 10px 0 0; - margin-left: -10px; + padding: 18px 18px 0 0; } .at-image-picker__preview-img { text-align: center; diff --git a/forms/textarea/CTextArea.vue b/forms/textarea/CTextArea.vue index ef4d128..29c897a 100644 --- a/forms/textarea/CTextArea.vue +++ b/forms/textarea/CTextArea.vue @@ -58,7 +58,6 @@ .find('.at-input__input') .prepend(this.$refs.textarea.$el); } else if (process.env.TARO_ENV === 'weapp') { - console.log(this.$refs); $(this.$refs.input.$el) .find('.at-input__container') .append(this.$refs.textarea); diff --git a/forms/textarea/cTextArea.scss b/forms/textarea/cTextArea.scss index f3ab430..253d39a 100644 --- a/forms/textarea/cTextArea.scss +++ b/forms/textarea/cTextArea.scss @@ -15,7 +15,7 @@ flex: 1; width: 100%; height: 94px; - padding-right: 18rpx; + padding-right: 18px; font-size: 32px; textarea { resize: none; -- Gitblit v1.9.1