当前位置:网站首页>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)
}
边栏推荐
- What does Huawei's minutes on patents say? (including Huawei's top ten inventions)
- Leetcode game 297
- leetcode 968. Monitoring binary tree
- Redis+Caffeine两级缓存的实现
- Performance of recommender algorithms on top-N recommendation tasks
- 别再用 System.currentTimeMillis() 统计耗时了,太 Low,StopWatch 好用到爆!
- 防火墙基础之策略部署
- 12306 ticket grabbing tutorial
- Chapter 1 overview of naturallanguageprocessing and deep learning
- Leetcode dichotomy
猜你喜欢

能让Jellyfin直接挂载阿里云盘的aliyundrive-fuse

Acwing 241 Loulan totem (detailed explanation of tree array)

HW is around the corner. Can't you read the danger message?

Eureka的InstanceInfoReplicator类(服务注册辅助类)

HMS core news industry solution: let technology add humanistic temperature

Uninstall MySQL 8

leetcode 834. Sum of distances in the tree

如何给VR全景作品添加遮罩?作用是什么?

leetcode-并查集

"Dare not doubt the code, but have to doubt the code" a network request timeout analysis
随机推荐
机器人方向的刚性需求→个人思考←
A simple scientific research secret
leetcode-数学题
leetcode-子序列/子串问题
SQL Server common functions
leetcode 32. Longest valid bracket
VCIP2021:利用解码信息进行超分辨率
Docker installing PostgreSQL
epoch_num和predict_num的换算
Leetcode union search set
[Nacos cloud native] the first step of reading the source code is to start Nacos locally
Simple integration of client go gin IX create
leetcode每日一题202110
BSN发展联盟理事长单志广:DDC可为中国元宇宙产业发展提供底层支撑
Linux setting enables Oracle10g to start automatically
防火墙基础之策略部署
Locks in MySQL
如何给VR全景作品添加遮罩?作用是什么?
Stored procedures in MySQL
What does Huawei's minutes on patents say? (including Huawei's top ten inventions)