微信小程序头像上传

 changeavatar() {
        wx.chooseImage({
            count: 1,
            success:(res)=> {
                const tempFilePaths = res.tempFilePaths
                wx.uploadFile({
                    
                    url: 'https://showme2.myhope365.com/api/system/user/profile/update/avatar/nos',
                    filePath: tempFilePaths[0],
                    name: 'avatarfile',
                    header:{
                        "cookie": wx.getStorageSync("cookie") || ""
                    },
                    success:(res)=>{
                        const data = res.data
                        //do something
                        // 请求个人数据
                        getUserInfo().then(res=>{
                            app.globalData.userInfo = res.data.data
                            app.globalData.isLogin = true
                            this.setData({
                                userInfo: res.data.data,
                                isLogin: true
                        }) 
                })
            }
        })
        wx.chooseImage({

        })
        wx.uploadFile({
            filePath: 'https://showme2.myhope365.com/api/system/user/profile/update/avatar/nos',

        })
    }
    })
 },

猜你喜欢

转载自blog.csdn.net/m0_65849649/article/details/124372175
今日推荐