6***@qq.com
6***@qq.com
  • 发布:2022-07-21 18:17
  • 更新:2024-07-07 17:31
  • 阅读:436

【报Bug】求助,uni-file-picker组件在微信小程序开发版和体验版都可以正常上传并预览,但是正式发布后就会出现上传图片失败的情况,

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Windows 10 专业工作站版 21H2

HBuilderX类型: 正式

HBuilderX版本号: 3.4.18

第三方开发者工具版本号: 1.06.22

基础库版本号: 2.24.3

项目创建方式: HBuilderX

示例代码:
    <view class="page-content" style="background: #fff;">  
        <view class="addBox">  
            <view class="starItem">  
                <view class="addTitle">服务满意度:</view>  
                <view class="starIconBox">  
                    <view  
                        class="iconfont icon-xingxingman setIcon"  
                        v-for="(item, index) in starNum"  
                        :key="index"  
                        :class="index < selectStar ? 'starColor' : ''"  
                        @tap="setSelectStarNum(index)"  
                    ></view>  
                </view>  
            </view>  
            <view class="textareaItem" style="border: none;">  
                <view class="starItem" style="border: none;">  
                    <view class="addTitle" style="width: auto;">  
                        <text>选择图片:</text>  
                        <text style="font-size: 25rpx;">(最多选择9张图片)</text>  
                    </view>  
                </view>  
                <uni-file-picker limit="9" :auto-upload="true" file-mediatype="image" mode="grid" @select="select" @progress="progress" @success="success" @fail="fail"/>  
            </view>  
            <view class="textareaItem">  
                <view class="starItem" style="border-top: 1rpx #009C87 solid;border-bottom: none"><view class="addTitle">评价内容:</view></view>  
                <view class="uni-textarea setTextarea"><textarea @blur="bindTextAreaBlur" show-confirm-bar placeholder="请输入300字以内的评论内容" maxlength="300" /></view>  
            </view>  
            <view class="bottomBtn" @tap="releaseEvaluation()">发表评价</view>  
        </view>  
    </view>  
</template>  

<script>  
export default {  
    data() {  
        return {  
            starNum: 5,  
            selectStar: 5,  
            customerEvaluationInfo: null,  
            evaluationImgs: [],  
            goods_id:null,  
            outTradeNo:null  
        };  
    },  
    onLoad(option) {  
        //option为object类型,会序列化上个页面传递的参数  
        this.goods_id = option.goodsID  
        this.outTradeNo = option.outTradeNo  
    },  
    methods: {  
        setSelectStarNum(index) {  
            this.selectStar = index + 1;  
        },  
        bindTextAreaBlur(e) {  
            this.customerEvaluationInfo = e.detail.value;  
            console.log(this.customerEvaluationInfo);  
        },  
        // 获取上传状态  
        select(e) {  
            console.log('选择文件:', e);  
        },  
        // 获取上传进度  
        progress(e) {  
            console.log('上传进度:', e);  
            if(e.tempFile.url){  
                let imgItem = e.tempFile;  
                this.evaluationImgs.push(imgItem);  
            }  
        },  
        // 上传成功  
        success(e) {  
            console.log('上传成功');  
        },        
        // 上传失败  
        fail(e) {  
            console.log('上传失败:', e);  
        },  
        // 发表评价  
        releaseEvaluation() {  
            let evaluationInfo;  
            if (this.customerEvaluationInfo !== null && this.evaluationImgs.length > 0) {  
                evaluationInfo = {  
                    starNum: this.selectStar,  
                    customerEvaluationImgs: this.evaluationImgs,  
                    comment_content: this.customerEvaluationInfo,  
                    goods_id: this.goods_id,  
                    outTradeNo:this.outTradeNo  
                };  
                this.$func.LoveStorage.call('evaluation/createEvaluation', evaluationInfo).then(res => {  
                    console.log('createEvaluation', res.datas);  
                    if(res.datas.code === 0&&res.code===200){  
                        uni.showModal({  
                            showCancel:false,  
                            title: '提示',  
                            content: '评论发布成功!',  
                            success: function (res) {  
                                if (res.confirm) {  
                                    console.log('用户点击确定');  
                                    uni.navigateBack({  
                                        delta: 1  
                                    })  
                                }   
                            }  
                        });  

                    }else{  
                        uni.showToast({  
                            icon:"fail",  
                            title: '身份验证已过期,请重新登录!',  
                            duration: 2000  
                        });  
                        // #ifdef MP-WEIXIN  
                        this.$wx.checkToken()  
                        // #endif  
                    }  
                });  
            }  

        }  
    }  
};  
</script>  

<style scoped>  
@import './customerEvaluation.css';  
</style>

操作步骤:

点击上传图片后无法预览,并且获取不到地址

预期结果:

上传图片并预览

实际结果:

点击上传图片后无法预览,并且获取不到地址

bug描述:

求助,uni-file-picker组件在微信小程序开发版和体验版都可以正常上传并预览,但是正式发布后就会出现上传图片失败的情况,莫名奇妙的找不到原因,找了多个手机测试也是一样,请问有什么好的解决方案么?

2022-07-21 18:17 负责人:无 分享
已邀请:
c***@qq.com

c***@qq.com - hello uniapp

有解决吗?我也遇到了类似的问题,还没解决

要回复问题请先登录注册