zbb il y a 4 semaines
Parent
commit
6d997ab57d
2 fichiers modifiés avec 145 ajouts et 48 suppressions
  1. 117 25
      pages/mine/card.vue
  2. 28 23
      pages/mine/index.vue

+ 117 - 25
pages/mine/card.vue

@@ -41,6 +41,8 @@
 					</view>
 				</view>
 			</view>
+			
+			
 			<view class="control-card">
 				<view class="item" @click="shareCard">
 					<image src="/static/image/public/card-sharing.png"></image>
@@ -84,7 +86,7 @@
 			<!-- 企业简介 -->
 			<view class="company-section" v-if="currentTab === 'company'">
 				<view class="company-content">
-					<rich-text  class="company-text" :nodes="companyInfo.introduce"></rich-text>
+					<rich-text class="company-text" :nodes="companyInfo.introduce"></rich-text>
 				</view>
 			</view>
 		</view>
@@ -125,6 +127,57 @@
 				</view>
 			</view>
 		</uni-popup>
+
+
+		<!-- 二维码弹窗 -->
+		<uni-popup ref="cardPopup" type="center">
+			<view class="qr-popup">
+				<view class="user-card">
+					<!-- 背景图 -->
+					<image class="user-card-bg" src="/static/image/home/usecard-bg.png" />
+				
+					<!-- 左上:姓名 + 职位 -->
+					<view class="user-header">
+						<view class="name-row">
+							<text class="user-name">{{ cardInfo.nickName || '用户' }}</text>
+							<text class="user-role">{{ cardInfo.postName || '职位' }}</text>
+						</view>
+						<text class="company-name">{{ cardInfo.companyName || '公司名称' }}</text>
+					</view>
+				
+					<!-- 右上:头像 -->
+					<view class="avatar-wrapper">
+						<image class="avatar" :src="cardInfo.avatar || '/static/image/public/avatar-default.png'" />
+						<image class="badge-icon" src="/static/image/public/badge-icon.png" />
+					</view>
+				
+					<!-- 左下:联系方式 -->
+					<view class="user-contact">
+						<view class="contact-row" @click="makeCall">
+							<uni-icons type="phone" :size="18" color="#666666"></uni-icons>
+							<text class="contact-text">{{ cardInfo.phonenumber || '暂无电话' }}</text>
+						</view>
+						<view class="contact-row">
+							<uni-icons type="email" :size="18" color="#666666"></uni-icons>
+							<text class="contact-text">{{ cardInfo.email || '暂无邮箱' }}</text>
+						</view>
+						<view class="contact-row">
+							<uni-icons type="location" :size="18" color="#666666"></uni-icons>
+							<text class="contact-text">{{ cardInfo.companyAddress || '暂无地址' }}</text>
+						</view>
+					</view>
+				</view>
+				
+				<view class="qr-actions">
+					<view class="action-btn" @click="close">
+						<text>取消</text>
+					</view>
+					<view class="action-btn" @click="shareConfirm">
+						<text class="action-text">确认</text>
+					</view>
+				</view>
+			</view>
+		</uni-popup>
 	</view>
 </template>
 
@@ -163,14 +216,15 @@
 	const qrCodePoster = ref('')
 	// 二维码弹窗引用
 	const qrPopup = ref(null)
+	const cardPopup = ref(null)
 
-	const productList = ref([ ])
+	const productList = ref([])
+	let shareImage = ref('data:image/png;base64,' + qrInfo.value.image)
 	onShareAppMessage(() => {
 		return {
 			userName: '小程序',
-			path: 'pages/index/index',
+			path: 'pages/splash/splash?userId=' + cardInfo.value.userId,
 			title: '布尔销销乐',
-			imagePath: 'data:image/png;base64,' + qrInfo.value.image,
 		};
 	});
 	onMounted(async () => {
@@ -195,15 +249,49 @@
 			})
 		}
 	}
-
-	const shareCard = () => {
-		uni.showShareMenu({
-			withShareTicket: true
+	// 分享图片
+	const shareConfirm = () => {
+		wx.showShareImageMenu({
+			path: shareImage.value,
+			success() {
+				// 分享菜单成功打开
+			}
 		})
-		uni.showToast({
-			title: '分享名片',
-			icon: 'none'
+	}
+	// 分享名片
+	const shareCard = async () => {
+		uni.showLoading({
+			title: '生成名片中...',
+			mask: true
 		})
+
+		try {
+			// 生成名片图片
+			const cardPath = await generateCardPoster(cardInfo.value)
+
+			// #ifdef MP-WEIXIN
+			// 微信小程序:显示分享提示
+			uni.hideLoading()
+			cardPopup.value.open()
+			// #endif
+
+			// #ifndef MP-WEIXIN
+			// H5 等其他平台:使用系统分享
+			await shareImageToWeChat(cardPath)
+			uni.hideLoading()
+			uni.showToast({
+				title: '分享成功',
+				icon: 'success'
+			})
+			// #endif
+		} catch (error) {
+			console.error('分享失败:', error)
+			uni.hideLoading()
+			uni.showToast({
+				title: '分享失败,请重试',
+				icon: 'none'
+			})
+		}
 	}
 
 	// 生成名片快照并保存
@@ -217,18 +305,18 @@
 			// 打印 cardInfo 详细信息
 			console.log('[saveCard] cardInfo:', JSON.stringify(cardInfo.value, null, 2))
 			console.log('[saveCard] avatar:', cardInfo.value.avatar)
-			
+
 			// 生成名片快照
 			const snapshotPath = await generateCardPoster(cardInfo.value)
-			
+
 			// 用属性接收快照路径
 			cardSnapshot.value = snapshotPath
-			
+
 			console.log('名片快照路径:', cardSnapshot.value)
-			
+
 			// 保存到相册
 			await savePosterToAlbum(snapshotPath)
-			
+
 			uni.hideLoading()
 			uni.showToast({
 				title: '已保存到相册',
@@ -250,7 +338,9 @@
 		qrPopup.value.open()
 	}
 
-
+	const close = async () => {
+		cardPopup.value.close()
+	}
 
 
 	// 保存二维码到相册
@@ -295,7 +385,7 @@
 		try {
 			// 将 base64 转换为临时文件
 			const qrFilePath = await base64ToTempFile(qrInfo.value.image)
-
+			shareImage.value = 'data:image/png;base64,' + qrInfo.value.image
 			// #ifdef MP-WEIXIN
 
 			// #endif
@@ -431,12 +521,7 @@
 	}
 
 
-
-	/* 用户信息卡片 */
-	.page-top {
-		margin: 0 24rpx 24rpx;
-
-		.user-card {
+.user-card {
 			position: relative;
 			z-index: 2;
 			width: 100%;
@@ -502,6 +587,7 @@
 				box-shadow: 0rpx 0rpx 4rpx 0rpx rgba(21, 93, 252, 0.20);
 
 				.avatar {
+					border-radius: 50%;
 					width: 100%;
 					height: 100%;
 				}
@@ -539,6 +625,11 @@
 
 		}
 
+	/* 用户信息卡片 */
+	.page-top {
+		margin: 0 24rpx 24rpx;
+
+		
 		.control-card {
 			background-color: #fff;
 			border-radius: 0 0 24rpx 24rpx;
@@ -764,9 +855,10 @@
 				background: rgba(64, 128, 255, 0.08);
 
 				.action-text {
-					&::after{
+					&::after {
 						border: none;
 					}
+
 					line-height: 1;
 					background-color: transparent;
 					font-size: 26rpx;

+ 28 - 23
pages/mine/index.vue

@@ -11,7 +11,8 @@
 			<!-- 用户信息 -->
 			<view class="user-info-section">
 				<view class="avatar-wrapper">
-					<image class="avatar" :src="cardInfo.avatar || '/static/image/public/avatar-default.png'" mode="aspectFill" />
+					<image class="avatar" :src="cardInfo.avatar || '/static/image/public/avatar-default.png'"
+						mode="aspectFill" />
 					<image class="avatar-badge" src="/static/image/public/badge-icon.png" />
 				</view>
 				<view class="user-details">
@@ -29,10 +30,10 @@
 		</view>
 
 		<!-- 内容区域 -->
-		<view class="content-section" >
+		<view class="content-section">
 
 			<!-- 线索数据卡片 -->
-			<view class="data-card" v-if="false"> 
+			<view class="data-card" v-if="false">
 				<view class="card-header">
 					<text class="card-title">线索数据</text>
 				</view>
@@ -64,7 +65,8 @@
 						<text class="data-label">客户总数</text>
 					</view>
 					<view class="data-item highlight">
-						<text class="data-value orange">{{ statisticsData.customerNewThisMonth.toLocaleString() }}</text>
+						<text
+							class="data-value orange">{{ statisticsData.customerNewThisMonth.toLocaleString() }}</text>
 						<text class="data-label">本月新增</text>
 					</view>
 					<view class="data-item">
@@ -86,7 +88,8 @@
 						<text class="data-label">商机总数</text>
 					</view>
 					<view class="data-item highlight">
-						<text class="data-value orange">{{ statisticsData.opportunityNewThisMonth.toLocaleString() }}</text>
+						<text
+							class="data-value orange">{{ statisticsData.opportunityNewThisMonth.toLocaleString() }}</text>
 						<text class="data-label">本月新增</text>
 					</view>
 					<view class="data-item">
@@ -152,7 +155,10 @@
 
 	// 使用 Pinia 管理用户状态
 	const userStore = useUserStore()
-	const { cardInfo, companyInfo } = storeToRefs(userStore)
+	const {
+		cardInfo,
+		companyInfo
+	} = storeToRefs(userStore)
 
 	// 统计数据
 	const statisticsData = ref({
@@ -175,7 +181,7 @@
 		if (!companyInfo.value.name) {
 			await userStore.queryCompanyInfo()
 		}
-		
+
 		// 加载统计数据
 		loadStatisticsData()
 	})
@@ -218,24 +224,24 @@
 			success: (res) => {
 				if (res.confirm) {
 					console.log('用户确认退出登录')
-					
+
 					// 1. 清除 token
 					uni.removeStorageSync('token')
-					
+
 					// 2. 清除 store 中的用户数据
 					userStore.$reset()
-					
+
 					// 3. 清除其他可能存储的数据
 					uni.removeStorageSync('userInfo')
 					uni.removeStorageSync('companyInfo')
-					
+
 					console.log('已清除所有登录数据')
-					
+
 					// 4. 跳转到登录页
 					uni.reLaunch({
 						url: '/pages/login/login'
 					})
-					
+
 					uni.showToast({
 						title: '已退出登录',
 						icon: 'success'
@@ -331,22 +337,21 @@
 				margin-right: 24rpx;
 
 				.avatar {
-					width: 128rpx;
-					height: 128rpx;
+					width: 140rpx;
+					height: 140rpx;
 					border-radius: 50%;
 					border: 4rpx solid rgba(255, 255, 255, 0.4);
 					background: #ffffff;
 				}
 
 				.avatar-badge {
-					position: absolute;
-					bottom: -18rpx;
-					right: -18rpx;
 					width: 64rpx;
 					height: 64rpx;
-					background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
-					border-radius: 50%;
-					border: 3rpx solid #ffffff;
+					position: absolute;
+					bottom: 0;
+					right: 0;
+					transform: translate(50% 50%);
+					z-index: 1;
 				}
 			}
 
@@ -499,7 +504,7 @@
 				&.icon-blue {
 					background: rgba(74, 144, 226, 0.1);
 				}
-				
+
 				&.icon-red {
 					background: rgba(255, 77, 79, 0.1);
 				}
@@ -522,4 +527,4 @@
 	.bottom-spacer {
 		height: 40rpx;
 	}
-</style>
+</style>