微信小程序授权头像模糊解决方案

751 阅读1分钟

最近写了小程序。但是发现一个问题就是微信授权后得到的图片非常的不清晰; 原图是这样:

原图
授权后得到的图片:
模糊的图

下面就是解决办法----具体为啥 我不知道 但是解决了~ 希望帮助到有需要的小伙伴们~

/**
     * @param {转换代码的过程} imageUrl
     */
    headimgHD: function(imageUrl) {
        imageUrl = imageUrl.split('/'); //把头像的路径切成数组
        //把大小数值为 46 || 64 || 96 || 132 的转换为0
        if (
            imageUrl[imageUrl.length - 1] &&
            (imageUrl[imageUrl.length - 1] == 46 ||
                imageUrl[imageUrl.length - 1] == 64 ||
                imageUrl[imageUrl.length - 1] == 96 ||
                imageUrl[imageUrl.length - 1] == 132)
        ) {
            imageUrl[imageUrl.length - 1] = 0;
        }
        imageUrl = imageUrl.join('/'); //重新拼接为字符串
        return imageUrl;
    },

贴一下自己做的小程序路过的可以帮忙扫一下;提提BUG和意见等谢谢~

gh_af88ca3ac9c4_430.jpg