You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.2 KiB
91 lines
2.2 KiB
<template>
|
|
<view class="">
|
|
<!-- // <view class="" v-if="tempPath==''"> -->
|
|
<!-- <image :src="tempPath" mode="heightFix" :style="style" /> -->
|
|
<!-- <u-loading-icon v-if="tempPath==''" text="加载中" textSize="18"></u-loading-icon> -->
|
|
|
|
<!-- </view> -->
|
|
<!-- 二维码隐藏,size控制清晰度,过大,隐藏展示临时地址 -->
|
|
<uv-qrcode :hide="false" ref="qrcode" size="200" :value="qrcodeValue" :options="optionCode"
|
|
@complete="completeCode">
|
|
</uv-qrcode>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
props: {
|
|
//二维码内容
|
|
qrcodeValue: {
|
|
typeof: Object
|
|
},
|
|
//中心图
|
|
foregroundImageSrc: {
|
|
typeof: String
|
|
},
|
|
//二维码大小
|
|
size: {
|
|
typeof: Number,
|
|
default: 125
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
style: {
|
|
height: null,
|
|
},
|
|
//二维码
|
|
optionCode: {
|
|
data: '',
|
|
useDynamicSize: false,
|
|
margin: 5,
|
|
quality: 100, // 图片质量,100 是最高质量
|
|
foregroundColor: '#2B58DA',
|
|
// areaColor: "#F95F6B",
|
|
// backgroundColor: "#3c9cff",
|
|
// 指定二维码前景,一般可在中间放logo
|
|
foregroundImageSrc: '/static/login/logo.png'
|
|
},
|
|
// tempPath: '/static/img/me/loading.png', //二维码异常显示图
|
|
tempPath: '', //二维码异常显示图
|
|
}
|
|
},
|
|
created() {
|
|
this.optionCode.foregroundImageSrc = this.foregroundImageSrc;
|
|
this.style.height = this.size + 'rpx';
|
|
},
|
|
methods: {
|
|
completeCode(obj) {
|
|
if (obj && obj.success) {
|
|
this.getTempPath()
|
|
} else {
|
|
// uni.$u.toast(this.$languageData.settings.genQRCodeEx)
|
|
}
|
|
},
|
|
getTempPath() {
|
|
this.$refs.qrcode.toTempFilePath({
|
|
success: (res) => {
|
|
// this.qrCodeSuccess = true
|
|
this.tempPath = res.tempFilePath
|
|
// console.log("---",this.tempPath)
|
|
}
|
|
});
|
|
},
|
|
// 保存图片到相册的具体操作
|
|
saveImageToAlbum() {
|
|
uni.saveImageToPhotosAlbum({
|
|
filePath: this.tempPath,
|
|
success: () => {
|
|
uni.$u.toast(this.$languageData.settings.saveCodeSuccess);
|
|
},
|
|
fail: (err) => {
|
|
uni.$u.toast(this.$languageData.settings.saveFailed+ ',' + err.errMsg);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
</style>
|