merchapp/java-mall-app-shop-admin/pages/my/shopQRcode/shopQRcode.vue
2025-08-30 16:01:24 +08:00

106 lines
2.3 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="shopQRcode-container">
<view class="img-contetn">
<u--image
class="qr-code-img"
:showLoading="true"
:src="dashboardInfo.store_info.wx_qrcode"
width="250px"
height="250px"
></u--image>
</view>
<view class="btn" @click="save">保存到相册</view>
</view>
</template>
<script>
import { mapState } from "vuex";
import { GetAccountDashboard } from "@/api/user";
export default {
data() {
return {
dashboardInfo: {
store_info: {
wx_qrcode: "",
},
},
};
},
onShow() {
this.getAccountDashboard();
},
methods: {
async getAccountDashboard() {
let res = await GetAccountDashboard();
if (res && res.status == 200) {
this.dashboardInfo = res.data;
}
},
save() {
uni.showLoading({
title: "保存中",
});
//下载图片
uni.downloadFile({
url: this.dashboardInfo.store_info.wx_qrcode,
success: (res) => {
if (res.statusCode === 200) {
//鉴权
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: () => {
uni.showToast({
title: "保存成功",
});
},
fail: (err) => {
//取消不为错h5端可能有这个问题
if (err.errMsg.includes("fail cancel")) {
uni.hideLoading();
return;
}
uni.showToast({
title: "保存失败",
icon: "error",
});
},
});
}
},
fail: (err) => {
// 地址有误处理
uni.showToast({
title: "图片解析失败",
icon: "error",
});
},
});
},
},
};
</script>
<style lang="scss">
@import "@/styles/variables.scss";
.shopQRcode-container {
.img-contetn {
display: flex;
justify-items: center;
margin: 20%;
}
.btn {
position: fixed;
bottom: 10%;
width: 54%;
margin: 20%;
padding: 32rpx;
text-align: center;
border-radius: 12rpx;
background: $base-color;
color: #fff;
}
}
</style>