二维码下载
This commit is contained in:
parent
d217caf63f
commit
1d8b3740e1
@ -1,32 +1,67 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view style="margin-bottom: 50rpx;text-align: center;font-size: 40rpx;color: yellow;padding-top: 150rpx;">惠农生活APP</view>
|
||||
<view style="width: 500rpx;height: 500rpx;margin: 0 auto;">
|
||||
<image style="width: 100%;height: 100%;" src="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/f668f202403151735165666.png"></image>
|
||||
</view>
|
||||
<view style="margin-top: 50rpx;text-align: center;font-size: 36rpx;color: yellow;">扫码即可下载最新版APP</view>
|
||||
</view>
|
||||
<view class="page" @longpress="handleSavePic">
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
onLoad() {},
|
||||
onShow() {},
|
||||
methods: {},
|
||||
onPullDownRefresh() {
|
||||
uni.stopPullDownRefresh()
|
||||
}
|
||||
}
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
handleSavePic() {
|
||||
// 获取要保存的图片路径或URL
|
||||
let imageUrl =
|
||||
"https://lihai001.oss-cn-chengdu.aliyuncs.com/def/97359202403161619147876.webp"; // 这里使用了网络上的图片作为示例
|
||||
|
||||
// #ifdef H5
|
||||
var a = document.createElement("a");
|
||||
a.download = imageUrl;
|
||||
a.href = imageUrl;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
// #endif
|
||||
|
||||
// #ifndef H5
|
||||
let that = this;
|
||||
uni.downloadFile({
|
||||
url: imageUrl,
|
||||
success(res) {
|
||||
if (res.statusCode === 200) {
|
||||
let tempFilePath = res.tempFilePath; // 临时文件路径
|
||||
uni.saveImageToPhotosAlbum({
|
||||
filePath: tempFilePath,
|
||||
success() {
|
||||
return that.$util.Tips({
|
||||
title: '图片已保存至相册!'
|
||||
});
|
||||
},
|
||||
fail(err) {
|
||||
console.error('保存失败', err);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.error('下载失败', res.statusCode);
|
||||
}
|
||||
},
|
||||
fail(err) {
|
||||
console.error('下载失败', err);
|
||||
}
|
||||
});
|
||||
// #endif
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.page{
|
||||
height: 100vh;
|
||||
background: linear-gradient(#ea6241, #ffebc5);
|
||||
}
|
||||
</style>
|
||||
.page {
|
||||
height: 100vh;
|
||||
background-image: url(https://lihai001.oss-cn-chengdu.aliyuncs.com/def/97359202403161619147876.webp);
|
||||
background-size: cover;
|
||||
}
|
||||
</style>
|
Loading…
x
Reference in New Issue
Block a user