groupQRCode.nvue 3.7 KB
Newer Older
DCloud_JSON's avatar
DCloud_JSON 已提交
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 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
<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>
			<!-- #ifndef APP-NVUE -->
			<image class="group-avatar" :src="avatar_file || '/uni_modules/uni-im/static/avatarUrl.png'" mode="">
			</image>
			<!-- #endif -->

		</view>
		<!-- #ifdef APP-NVUE -->
		<image class="group-avatar" :src="avatar_file || '/uni_modules/uni-im/static/avatarUrl.png'" mode=""></image>
		<!-- #endif -->

		<!-- <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>
	.container {
		/* #ifndef APP-NVUE */
		height: 100vh;
		/* #endif */
		flex: 1;
		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;
		/* #ifdef APP-NVUE */
		top: 150rpx;
		/* #endif */
		/* #ifndef APP-NVUE */
		top: -60rpx;
		/* #endif */
	}

	.group-name {
		width: 400rpx;
		font-size: 46rpx;
		/* #ifdef APP-NVUE */
		lines: 1;
		/* #endif */
		/* #ifndef APP-PLUS */
		white-space: nowrap;
		overflow: hidden;
		/* #endif */
		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>