Explorar o código

团队成员邮件信息脱敏(增加了全局脱敏方法)、推荐记录页面样式优化

htc hai 3 días
pai
achega
cdf53786af

+ 3 - 3
components/CusTeamUser/index.vue

@@ -8,10 +8,10 @@
 				<view class="dialog-box-list-item" v-for="(item,index) in list" :key="index">
 					<view class="dialog-box-list-item-status" :class="{'wzd':item.status===0,'yzd':item.status===1}">{{statusCfg[item.status]}}</view>
 					<view class="dialog-box-list-item-name adfac">
-						<text>{{item.realName}}</text>
-						<view class="type">{{item.categoryName}}</view>
+						<text>{{item.realName||''}}</text>
+						<view class="type">{{item.categoryName||''}}</view>
 					</view>
-					<view class="dialog-box-list-item-email">{{item.email}}</view>
+					<view class="dialog-box-list-item-email">{{item.emailTM||''}}</view>
 					<image class="dialog-box-list-item-delete" :src="imgBase+'icon_delete.png'" @click="deleteUser(item,index)" v-if="deluser"></image>
 				</view>
 			</view>

+ 1 - 0
pagesHome/components/createList.vue

@@ -255,6 +255,7 @@ export default {
 				this.teamUserList = res.data;
 				this.originTeamUserList = res.data;
 				this.teamUserList.forEach(l=>{
+					l.emailTM = this.$reg.desensitizeContent(l.email);
 					l.categoryName = this.categoryData.find(c=>c.id==l.category)?.name;
 				})
 				this.teamUserShow = true

+ 1 - 0
pagesHome/components/receiveList.vue

@@ -134,6 +134,7 @@
 						this.teamUserList = res.data;
 						this.originTeamUserList = res.data;
 						this.teamUserList.forEach(l=>{
+							l.emailTM = this.$reg.desensitizeContent(l.email);
 							l.categoryName = this.categoryData.find(c=>c.id==l.category)?.name;
 						})
 						this.teamUserShow = true

+ 7 - 4
pagesMy/recommendHistory.vue

@@ -1,10 +1,10 @@
 <template>
 	<view class="default_page adffc" :style="{'height':h+'px', 'padding-top':mt+'px'}">
 		<cus-header title='推荐记录'></cus-header>
-		<view class="top adfac" @click="show=true">
+		<!-- <view class="top adfac" @click="show=true">
 			<text>{{typeText}}</text>
 			<image :src="imgBase+'icon_down.png'"></image>
-		</view>
+		</view> -->
 		<view class="list" v-if="list.length">
 			<up-list @scrolltolower="scrolltolower" style="height: 100%">
 				<up-list-item v-for="(item, index) in list" :key="index">
@@ -123,7 +123,7 @@
 		}
 		
 		.list{
-			padding-top: 110rpx;
+			padding-top: 20rpx;
 			&-item{
 				background: #FFFFFF;
 				border-radius: 24rpx;
@@ -133,6 +133,7 @@
 					margin-top: 0;
 				}
 				&-left{
+					flex: 1;
 					image{
 						width: 88rpx;
 						height: 88rpx;
@@ -157,11 +158,13 @@
 					}
 				}
 				&-right{
+					width: 210rpx;
 					font-family: PingFangSC, PingFang SC;
 					font-weight: 400;
 					font-size: 24rpx;
 					color: #95A5B1;
-					line-height: 24rpx;
+					line-height: 32rpx;
+					text-align: right;
 				}
 			}
 		}

+ 2 - 1
pagesMy/teamUser.vue

@@ -24,7 +24,7 @@
 											</view>
 										</template>
 									</view>
-									<view class="lbox-info-email">{{item.email}}</view>
+									<view class="lbox-info-email">{{item.emailTM}}</view>
 								</view>
 								<view class="lbox-edit" @click.stop="handleEdit(item)">
 									<u-icon name="edit-pen" size="42rpx" color="#B9B9B9"></u-icon>
@@ -100,6 +100,7 @@
 					if(res.code!==0) return this.$showToast(res.msg)
 					this.list = [...this.list,...res.data.list]
 					this.list.forEach((l,i)=>{
+						l.emailTM = this.$reg.desensitizeContent(l.email);
 						this.$set(this.list[i],'category','');
 						this.$set(this.list[i],'categoryName','');
 						this.$set(this.list[i],'select',false);

+ 4 - 0
pagesMy/teamUserDetail.vue

@@ -109,6 +109,10 @@
 					color: #002846;
 					line-height: 42rpx;
 				}
+				&-right{
+					flex: 1;
+					padding-left: 40rpx;
+				}
 			}
 		}
 		

+ 1 - 0
pagesPublish/questionnaireFill.vue

@@ -234,6 +234,7 @@
 					if(res.code!==0) return this.$showToast(res.msg)
 					this.teamUserList = res.data;
 					this.teamUserList.forEach(l=>{
+						l.emailTM = this.$reg.desensitizeContent(l.email);
 						l.categoryName = this.categoryData.find(c=>c.id==l.category)?.name;
 					})
 					this.userShow = true

+ 70 - 1
utils/reg.js

@@ -254,6 +254,74 @@ function video(value) {
  */
 function regExp(o) {
     return o && Object.prototype.toString.call(o) === '[object RegExp]'
+}
+
+/**
+ * 通用脱敏函数
+ * @param {string} content - 需要脱敏的内容(邮箱/手机号/姓名)
+ * @param {number} [type=1] - 脱敏类型:1-邮箱(默认),2-手机,3-姓名
+ * @returns {string} 脱敏后的内容,不符合规则返回原内容
+ */
+function desensitizeContent(content, type = 1) {
+  // 基础校验:内容为空或非字符串直接返回原内容
+  if (!content || typeof content !== 'string') {
+    return content;
+  }
+
+  // 去除首尾空格
+  const trimContent = content.trim();
+
+  switch (type) {
+    // 1 - 邮箱脱敏
+    case 1: {
+      // 邮箱基本校验:包含@,且@前后有内容,总长度至少5位(如a@b.c)
+      const emailReg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
+      if (!emailReg.test(trimContent) || trimContent.length < 5) {
+        return content; // 不符合邮箱格式返回原内容
+      }
+      // 拆分邮箱:用户名@域名
+      const [username, domain] = trimContent.split('@');
+      // 用户名保留前2位,不足2位则保留1位,其余用*代替
+      const safeUsername = username.length > 2 
+        ? username.substring(0, 2) + '*'.repeat(username.length - 2)
+        : username.substring(0, 1) + '*'.repeat(username.length - 1);
+      return `${safeUsername}@${domain}`;
+    }
+
+    // 2 - 手机号脱敏
+    case 2: {
+      // 手机号基本校验:11位数字,以1开头
+      const phoneReg = /^1\d{10}$/;
+      if (!phoneReg.test(trimContent) || trimContent.length !== 11) {
+        return content; // 不符合手机号格式返回原内容
+      }
+      // 保留前3位和后4位,中间4位用*代替
+      return trimContent.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
+    }
+
+    // 3 - 姓名脱敏
+    case 3: {
+      const nameLength = trimContent.length;
+      // 姓名长度校验:至少1位,最多6位(常规姓名长度)
+      if (nameLength < 1 || nameLength > 6) {
+        return content;
+      }
+      // 单字姓名:直接返回
+      if (nameLength === 1) {
+        return trimContent;
+      }
+      // 双字姓名:保留首字,第二个字用*代替(如:李*)
+      if (nameLength === 2) {
+        return trimContent.substring(0, 1) + '*';
+      }
+      // 三字及以上:保留首尾字,中间用*代替(如:张*三、王**明)
+      return trimContent.substring(0, 1) + '*'.repeat(nameLength - 2) + trimContent.substring(nameLength - 1);
+    }
+
+    // 未知类型:返回原内容
+    default:
+      return content;
+  }
 }
 
 export default {
@@ -285,5 +353,6 @@ export default {
     video,
     image,
     regExp,
-    string
+    string,
+	desensitizeContent
 }