您的位置:首页 > 移动开发 > 微信开发

微信小程序获取用户高清头像

2018-10-16 18:00 344 查看

获取到用户头像的路径之后执行此函数,  返回值及时高清头像路径

[code]function headimgHD(imageUrl) {        console.log('原来的头像', 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('/');   //重新拼接为字符串

        console.log('高清的头像', imageUrl);        return imageUrl;
    }

headimgHD('https://wx.qlogo.cn/mmopen/vi_32/DYAIOgq83er5prllVA37yiac4Vv8ZAXwbg0Zicibn6ZjsgJ4ha0hmFBY8MUTRMnRTmSlvzPd8XJZzd0icuyGoiakj4A/132');
阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: