Files
app-govern/pages/user/erweima.vue

193 lines
5.3 KiB
Vue
Raw Normal View History

2023-02-20 14:19:28 +08:00
<template>
<Cn-page :loading="loading" before-render>
<view class="transfer" slot="body">
<!-- <div class="transfer-img" ref="qrCodeUrl" /> -->
<Cn-htmlToImg domId="content" @renderFinish="renderFinish" style="display: flex">
<view class="content" id="content">
<view class="user-info">
<image class="avatar" :src="userInfo.avatar" v-if="userInfo.avatar"></image>
<image class="avatar" src="/static/head.png" v-else></image>
<view class="right">
<view class="user-info-name">{{ userInfo.nickname }}</view>
<view class="user-info-role">{{ roleName }}</view>
</view>
2023-08-17 15:37:19 +08:00
</view>
<uqrcode size="260" ref="uqrcode" canvas-id="qrcode" :value="content" @complete="loading = false"
:loading="false"></uqrcode>
2023-08-17 15:37:19 +08:00
</view>
</Cn-htmlToImg>
<view class="transfer-text">
<!-- <view>换个样式</view>-->
<view @click="save">保存图片</view>
2023-02-20 14:19:28 +08:00
</view>
<!-- <view class="transfer-btn">
<button class="transfer-btn-item" style="background-color: #fff; color: #111" @click="back">
返回
</button>
<button class="transfer-btn-item ml20" @click="home">转移成功</button>
</view> -->
2023-02-20 14:19:28 +08:00
</view>
</Cn-page>
2023-02-20 14:19:28 +08:00
</template>
<script>
2023-08-11 11:03:31 +08:00
// import QRCode from 'qrcodejs2'
// import UQRCode from '@/uni_modules/Sansnn-uQRCode/js_sdk/uqrcode/uqrcode.js';
2023-08-17 15:37:19 +08:00
import {base64ToPath} from "image-tools";
import setting from "@/pages/engineering/setting.vue";
2023-02-20 14:19:28 +08:00
export default {
2023-08-11 11:03:31 +08:00
data() {
2023-02-20 14:19:28 +08:00
return {
2023-08-11 11:03:31 +08:00
loading: false,
content: '',
2023-08-17 15:37:19 +08:00
img: '',
2023-08-11 11:03:31 +08:00
userInfo: {},
2023-02-20 14:19:28 +08:00
}
},
2023-08-17 15:37:19 +08:00
computed: {
roleName() {
let roleName = ''
switch (this.userInfo.authorities) {
case 'tourist':
roleName = '游客'
break
case 'engineering_user':
roleName = '工程用户'
break
case 'app_vip_user':
2023-10-26 09:03:16 +08:00
roleName = '正式用户'
2023-08-17 15:37:19 +08:00
break
case 'market_user':
roleName = '营销用户'
break
case 'operation_manager':
roleName = '运维管理员'
break
}
return roleName
2023-08-11 11:03:31 +08:00
},
2023-08-17 15:37:19 +08:00
},
methods: {
renderFinish(e) {
this.img = e
2023-08-11 11:03:31 +08:00
},
2023-08-17 15:37:19 +08:00
save() {
console.log(this.img)
if (!this.img) {
setTimeout(() => {
2023-08-17 15:37:19 +08:00
this.save()
}, 500)
return
2023-08-17 15:37:19 +08:00
}
base64ToPath(this.img).then((res) => {
console.log(res)
uni.saveImageToPhotosAlbum({
filePath: res,
success: () => {
this.$util.toast('已保存到系统相册')
},
fail: function (err) {
console.log(err)
},
});
})
}
2023-08-11 11:03:31 +08:00
},
onLoad(options) {
this.userInfo = uni.getStorageSync(this.$cacheKey.userInfo)
2023-08-23 16:22:08 +08:00
console.log(this.userInfo)
2023-08-11 11:03:31 +08:00
this.content = JSON.stringify({
type: 'userId',
id: this.userInfo.userIndex,
})
},
2023-02-20 14:19:28 +08:00
}
</script>
2023-08-11 11:03:31 +08:00
<style lang="scss">
2023-08-17 15:37:19 +08:00
.content {
width: 330px;
padding: 30px 0;
border-radius: 12rpx;
overflow: hidden;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: #fff;
}
.user-info {
display: flex;
align-items: center;
margin-bottom: 50rpx;
width: 260px;
.avatar {
margin-right: 20rpx;
height: 100rpx;
width: 100rpx;
border-radius: 8rpx;
2023-08-23 16:22:08 +08:00
flex-shrink: 0;
2023-08-17 15:37:19 +08:00
}
.right {
display: flex;
flex-direction: column;
justify-content: space-between;
.user-info-name {
font-size: 32rpx;
color: #333333;
2023-08-23 16:22:08 +08:00
word-break: break-all;
2023-08-17 15:37:19 +08:00
}
.user-info-role {
margin-top: 10rpx;
font-size: 28rpx;
color: #999999;
}
}
}
2023-08-11 11:03:31 +08:00
.transfer {
display: flex;
flex-direction: column;
align-items: center;
2023-08-17 15:37:19 +08:00
justify-content: space-between;
height: 100vh;
background: #fff;
box-sizing: border-box;
padding: 100rpx 0;
2023-08-11 11:03:31 +08:00
.transfer-img {
}
.transfer-text {
2023-08-17 15:37:19 +08:00
display: flex;
2023-08-11 11:03:31 +08:00
font-size: 28rpx;
2023-08-17 15:37:19 +08:00
color: rgb(122, 126, 153);
2023-08-11 11:03:31 +08:00
}
.transfer-btn {
display: flex;
flex-direction: row;
justify-content: space-between;
margin-top: 100rpx;
width: 100%;
.transfer-btn-item {
flex: 1;
height: 80rpx;
border-radius: 12rpx;
background-color: $uni-theme-color;
font-size: 28rpx;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
}
}
2023-02-20 14:19:28 +08:00
}
2023-08-11 11:03:31 +08:00
</style>