groupQRCode.vue 3.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
<template>
	<view class="container">
		<view class="qr-code">
			<view class="code-info">
				<text class="group-name">{{name}}</text>
				<text class="group-id" @click="copyGroupID">群号:{{group_id}}</text>
				<!--uqrcode 组件来源,插件Sansnn-uQRCode 链接地址:https://ext.dcloud.net.cn/plugin?id=1287 -->
				<!-- #ifndef MP-WEIXIN -->
				<!-- <uqrcode ref="uqrcode" :start="false" :size="200" canvas-id="qrcode" :value="qrcodeData"></uqrcode> -->
				<!-- #endif -->
			</view>
			<image class="group-avatar" :src="avatar_file || '/uni_modules/uni-im/static/avatarUrl.png'" mode="">
			</image>
		</view>

		<!-- <view class="btn-box">
			<view class="btn-item" @click="save">
				<uni-icons type="arrow-down" size="30"></uni-icons>
				<text class="btn-text">保存</text>
			</view>
			<view class="btn-item" @click="share">
				<uni-icons type="paperplane" size="30"></uni-icons>
				<text class="btn-text">分享</text>
			</view>
		</view> -->
	</view>
</template>

<script>
	import uqrcode from "@/uni_modules/Sansnn-uQRCode/components/uqrcode/uqrcode"
	export default {
		components: {
			uqrcode
		},
		data() {
			return {
				group_id: '',
				name: '',
				avatar_file: ''
			}
		},
		computed: {
			qrcodeData() {
				let data = {
					"type": "uni-im",
					"subType": "groupInfo",
					"data": {
						group_id: this.group_id,
						name: this.name,
						avatar_file: this.avatar_file
					}
				}
				return JSON.stringify(data)
			}
		},
		onLoad(options) {
			// console.log("options: ",options);
			this.group_id = options.id
			this.name = options.name
			this.avatar_file = options.avatar_file
		},
		onReady(){
			setTimeout(()=>{
				this.$refs.uqrcode.make({
					success: () => {
						// console.log('生成成功');
					},
					fail: err => {
						// console.log(err)
					}
				});
			},1000)
		},
		methods: {
			copyGroupID() {
				uni.setClipboardData({
					data: this.group_id,
					success: function() {
						console.log('success');
					}
				});
			},
			save() {
				console.log('保存');
			},
			share() {
				console.log('分享');
			}
		}
	}
</script>

<style lang="scss" scoped>
  @import "@/uni_modules/uni-im/static/flex.scss";
	.container {
		height: 100vh;
		padding-top: 200rpx;
		// justify-content: center;
		align-items: center;
		background-color: #f5f5f5;
	}

	.qr-code {
		width: 550rpx;
		height: 780rpx;
		align-items: center;
		justify-content: center;
		border-radius: 20rpx;
		background-color: #fff;
		position: relative;
	}

	.code-info {
		align-items: center;
		justify-content: center;
	}

	.group-avatar {
		width: 150rpx;
		height: 150rpx;
		border-radius: 100rpx;
		position: absolute;
		top: -70rpx;
	}

	.group-name {
		width: 400rpx;
		font-size: 46rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		margin-top: 120rpx;
		text-align: center;
	}

	.group-id {
		margin: 40rpx 0;
		font-size: 30rpx;
	}

	.btn-box {
		flex-direction: row;
		margin-top: 100rpx;
	}

	.btn-item {
		align-items: center;
		justify-content: center;
		width: 130rpx;
		height: 130rpx;
		border-radius: 100rpx;
		background-color: #fff;
		margin: 0 80rpx;
		border: 1px solid #eee;
	}

	.btn-text {
		font-size: 28rpx;
	}
</style>