当前位置:网站首页>Screenshot of the uniapp app and save it locally
Screenshot of the uniapp app and save it locally
2022-06-22 13:49:00 【Amy's cat (silly steel)】
down() {
setTimeout(() => {
let pages = getCurrentPages();
let page = pages[pages.length - 1];
let ws = page.$getAppWebview();
let bitmap = new plus.nativeObj.Bitmap('drawScreen');
// take webview The content is drawn to Bitmap In the object
ws.draw(bitmap, () => {
// Save pictures to local
bitmap.save("_doc/drawScreen.jpg", {
overwrite: true
}, res => {
console.log(res.target); // Picture address
uni.saveImageToPhotosAlbum({
// Save picture to system album .
filePath: res.target, // Image file path
success: () => {
uni.showModal({
title: ' reminder ',
content: ' Picture saved successfully , Hurry to forward it to your friends ~',
showCancel: false,
confirmColor: "#34CE98",
confirmText: ' got it ',
success: () => {
this.canSave = false;
}
})
uni.hideLoading()
},
fail: function(e) {
uni.showModal({
title: ' reminder ',
content: ' Failed to save picture , Try again ~',
showCancel: false,
confirmColor: "#34CE98",
confirmText: ' got it ',
success: () => {
this.canSave = false;
}
})
uni.hideLoading()
}
});
bitmap.clear(); // eliminate Bitmap object
}, error => {
console.log(JSON.stringify(error)); // Save failure information
uni.showModal({
title: ' reminder ',
content: ' Failed to save picture , Try again ~',
showCancel: false,
confirmColor: "#34CE98",
confirmText: ' got it ',
success: () => {
this.canSave = false;
}
})
uni.hideLoading()
bitmap.clear(); // eliminate Bitmap object
});
// bitmap.clear(); // eliminate Bitmap object
}, error => {
uni.showModal({
title: ' reminder ',
content: ' Failed to save picture , Try again ~',
showCancel: false,
confirmColor: "#34CE98",
confirmText: ' got it ',
success: () => {
this.canSave = false;
}
})
uni.hideLoading()
console.log(JSON.stringify(error)); // Drawing failed
}, {
check: true, // Set to detect white screen
});
}, 2000)
}
边栏推荐
- 性能相关指标
- leetcode 99. Restore binary search tree
- Processing statement on price selection of several manufacturers
- epoch_ Num and predict_ Conversion of num
- SSM based community garbage classification and transportation management system, high-quality graduation thesis example (can be used directly), source code, database script, project introduction and o
- Implementation of connecting SQL server to Oracle server_ Including query implementation
- Stephencovey's tips for efficient work for young people
- Mysql中的锁
- SQL Server common functions
- What you must understand before you are 30
猜你喜欢

leetcode 11. Container with the most water

Tasks and responsibilities of the test team and basic concepts of testing

leetcode-背包问题

leetcode 85. Max rectangle

Tables converting to latex format

Query rewriting for opengauss kernel analysis
![[cloud native] event publishing and subscription in Nacos -- observer mode](/img/0f/34ab42b7fb0085f58f36eb67b6f107.png)
[cloud native] event publishing and subscription in Nacos -- observer mode

"Dare not doubt the code, but have to doubt the code" a network request timeout analysis

Leetcode knapsack problem

In June, China database industry analysis report was released! Smart wind, train storage and regeneration
随机推荐
“不敢去怀疑代码,又不得不怀疑代码”记一次网络请求超时分析
After several years of writing at CSDN, I published "the first book". Thank you!
Number of times Oracle uses cursor to decompose numbers
Istio服务网格中的流量复制
leetcode 11. Container with the most water
Linux setting enables Oracle10g to start automatically
“不敢去怀疑代码,又不得不怀疑代码”记一次网络请求超时分析
"N'osez pas douter du Code, vous devez douter du Code" notez une analyse de délai de demande réseau
Leetcode knapsack problem
Leetcode subsequence / substring problem
Tasks and responsibilities of the test team and basic concepts of testing
Views in MySQL
【云原生】Nacos中的事件发布与订阅--观察者模式
leetcode 854. String with similarity K
SSM based community garbage classification and transportation management system, high-quality graduation thesis example (can be used directly), source code, database script, project introduction and o
Problème de sous - séquence / substrat leetcode
Leetcode daily question 202110
SQL Server common functions
leetcode-子序列/子串問題
华为这份关于专利的会议纪要,都说了什么?(内含华为十大发明彩蛋)