WebApp【公共组件库】@前端(For Git Submodule)
Tevin
2021-03-26 aa3a4d8e28689d33aeb6c2dddb271328f43df1b0
修复图片选择器小程序中的兼容问题
4 files modified
44 ■■■■■ changed files
forms/imagePicker/CImagePicker.vue 34 ●●●● patch | view | raw | blame | history
forms/imagePicker/cImagePicker.scss 7 ●●●●● patch | view | raw | blame | history
forms/textarea/CTextArea.vue 1 ●●●● patch | view | raw | blame | history
forms/textarea/cTextArea.scss 2 ●●● patch | view | raw | blame | history
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>
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;
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);
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;