万粉博主推荐,微信小程序 Flask后端调用AnimeGanV2(3)
2022-10-30 来源:旧番剧
chooseImage() { var that = this; wx.showActionSheet({ itemList: ["从相册中选择", "拍照"], itemColor: "#FAD143", success: function (res) { if (!res.cancel) { wx.showLoading({ title: "正在读取...", }) if (res.tapIndex == 0) { that.chooseWxImage1("album", 1) } else if (res.tapIndex == 1) { that.chooseWxImage1("camera", 1) } } } }) },
savePic函数保存照片。
savePic(e) { let that = this var baseImg = that.data.baseImg //保存图片 var save = wx.getFileSystemManager(); var number = Math.random(); save.writeFile({ filePath: wx.env.USER_DATA_PATH "/pic" number ".png", data: baseImg, encoding: "base64", success: res => { wx.saveImageToPhotosAlbum({ filePath: wx.env.USER_DATA_PATH "/pic" number ".
png", success: function (res) { wx.showToast({ title: "保存成功", }) }, fail: function (err) { console.log(err) } }) console.log(res) }, fail: err => { console.log(err) } }) },
generateAvantar函数调用postdata函数实现头像动漫化。
generateAvantar:function(e){ var that = this console.log(that.data.prurl) wx.uploadFile({ url: "http://127.0.0.1:8090/postdata", filePath: that.data.prurl, name: "content", success: function (res) { console.log(res.data); var resurl=JSON.parse(res.data)["resurl"] that.setData({ prurl: resurl }) if (res) { wx.showToast({ title: "转换完成", duration: 3000 });