二维码下载
This commit is contained in:
parent
d217caf63f
commit
1d8b3740e1
@ -1,32 +1,67 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="page">
|
<view class="page" @longpress="handleSavePic">
|
||||||
<view style="margin-bottom: 50rpx;text-align: center;font-size: 40rpx;color: yellow;padding-top: 150rpx;">惠农生活APP</view>
|
</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>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {},
|
|
||||||
onShow() {},
|
methods: {
|
||||||
methods: {},
|
handleSavePic() {
|
||||||
onPullDownRefresh() {
|
// 获取要保存的图片路径或URL
|
||||||
uni.stopPullDownRefresh()
|
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>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.page{
|
.page {
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
background: linear-gradient(#ea6241, #ffebc5);
|
background-image: url(https://lihai001.oss-cn-chengdu.aliyuncs.com/def/97359202403161619147876.webp);
|
||||||
}
|
background-size: cover;
|
||||||
</style>
|
}
|
||||||
|
</style>
|
Loading…
x
Reference in New Issue
Block a user