小程序白屏问题
发布于 4 年前 作者 xiulanmeng 6020 次浏览 来自 问答

在选择完图片后用七牛的图片上传接口保存图片,返回后会出现白屏情况,但是注释七牛的代码后则不会出现此类情况

chooseImageTap: function (e) {

var _this = this;

var index = e.currentTarget.dataset.index;

wx.showActionSheet({

itemList: [‘从相册中选择’, ‘拍照’],

itemColor: “#e61128”,

success: function (res) {

if (!res.cancel) {

if (res.tapIndex == 0) {

_this.chooseWxImage(‘album’, index)

} else if (res.tapIndex == 1) {

_this.chooseWxImage(‘camera’, index)

}

}

}

})

},

chooseWxImage: function (type, index) {

let _this = this;

wx.chooseImage({

sizeType: [‘original’, ‘compressed’],

sourceType: [type],

success: function (res) {

var filePath = res.tempFilePaths[0];

console.log(‘选择完成图片’)

// 交给七牛上传

//注释以下代码则不会出现白屏问题

qiniuUploader.upload(filePath, (res) => {

var imageURL = res.imageURL;

console.log(‘七牛上传完成图片’)

if(index==1){

_this.setData({ idCartFront: imageURL});

}else{

_this.setData({ idCartBack: imageURL });

}

}, (error) => {

}, {

region: ‘ECN’, // 华东区

uptoken: _this.data.uptoken,

domain: http://img1.zhefengle.com,

shouldUseQiniuFileName: false

}

);

//注释以上代码则不会出现白屏问题

}

})

回到顶部