Explorar o código

feat:选择角色

zhanghui hai 1 ano
pai
achega
9dd55a5977

+ 6 - 2
pages/index/attach/attach.vue

@@ -43,7 +43,7 @@
 				<text class="roleSelectLabel">选择规则:</text>
 			</view>
 			<view class="roleSelect">
-				<uni-data-select v-model="value" :localdata="ruleList" @change="selectChange" :clear="false"></uni-data-select>
+				<uni-data-select v-model="value" :localdata="roleBindRuleList" @change="selectChange" :clear="false"></uni-data-select>
 			</view>
 		</view>
 
@@ -90,6 +90,7 @@
 					foregroundImageBorderRadius:5,
 					foregroundImageSrc: '/static/logo.png'
 				},
+				value:0,
 			}
 		},
 		created() {
@@ -126,7 +127,10 @@
 					roleId:roleId
 				}).then(res=>{
 					this.roleBindRuleList = res.data.data
-					this.roleBindRuleList[0].select = true
+					// for (let i = 0;i<this.roleList.length;i++){
+					// 	this.roleBindRuleList[i].value = i;
+					// 	this.roleBindRuleList[i].text = this.roleList[i].name
+					// }
 				})
 			},
 

+ 9 - 9
pages/index/index.vue

@@ -6,15 +6,15 @@
 			title="首页" />
 		<!-- #endif -->
 
-<!--		<manager v-if="isManager == '1'" :height="height"></manager>-->
-<!--		<attach v-else-if="isManager == '0' && (roleTag == '0' || roleTag ==  '2')"></attach>-->
-<!--		<view :style="{height:height}" v-else-if="isManager == '0' && roleTag == '1'" class="flex-col justify-center">-->
-<!--			<view class="flex-row justify-center">-->
-<!--				<text>合作伙伴相关功能正在建设中...</text>-->
-<!--			</view>-->
-<!--		</view>-->
-		<manager></manager>
-		<attach></attach>
+		<manager v-if="isManager == '1'" :height="height"></manager>
+		<attach v-else-if="isManager == '0' && (roleTag == '0' || roleTag ==  '2')"></attach>
+		<view :style="{height:height}" v-else-if="isManager == '0' && roleTag == '1'" class="flex-col justify-center">
+			<view class="flex-row justify-center">
+				<text>合作伙伴相关功能正在建设中...</text>
+			</view>
+		</view>
+<!--		<manager></manager>-->
+<!--		<attach></attach>-->
 	</view>
 </template>
 

+ 1 - 0
pages/index/manager/index.rpx.css

@@ -4,6 +4,7 @@
     background-repeat: no-repeat;
     background-size: 750rpx 680rpx;
     background-color: #F9F9F9;
+    min-height: 680rpx;
 }
 .grid{
     width: 624rpx;

+ 44 - 2
pages/index/manager/manager.vue

@@ -55,7 +55,7 @@
 			</view>
 		</view>
 
-		<view class="flex-row justify-center">
+		<view class="flex-row justify-center" v-if="showQrCode">
 			<view class="qrView" @click="qrCodePopup">
 				<uv-qrcode ref="qrcode" size="600rpx" :value="qrcodeUrl" :options="options"></uv-qrcode>
 			</view>
@@ -89,7 +89,7 @@
 		},
 		data() {
 			return {
-				qrcodeUrl:this.$xcxUrl+'?expandUserId={expandUserId}&ruleId={ruleId}&timestamp={timestamp}&type=2&expand1=2',
+				qrcodeUrl: this.$tkUrl + '?roleId={roleId}&parentId={parentId}&timestamp={timestamp}&type=2&expand1=2',
 				options: {
 					// 指定二维码前景,一般可在中间放logo
 					foregroundImagePadding:2,
@@ -99,6 +99,8 @@
 				homeStaticsData:{},
 				value:0,
 				roleList:[],
+				roleBindRuleList:[],
+				showQrCode:true
 			}
 		},
 		created() {
@@ -110,6 +112,7 @@
 		methods: {
 			selectChange(e){
 				console.log(e)
+				this.getRuleByRoleId(this.roleList[this.value].id)
 			},
 			formatDate() {
 				this.qrCreateTime = commonUtils.formatDate(new Date())
@@ -135,6 +138,19 @@
 						this.roleList[i].value = i;
 						this.roleList[i].text = this.roleList[i].name
 					}
+					this.getRuleByRoleId(this.roleList[this.value].id)
+
+				})
+			},
+
+			//查询角色已经绑定的规则
+			 getRuleByRoleId(roleId) {
+				 this.$api.service.getRuleByRoleId({
+					roleId: roleId
+				}).then(res => {
+					console.log("1111111111111111111111")
+					this.roleBindRuleList = res.data.data
+					this.createQrCode()
 				})
 			},
 
@@ -147,6 +163,32 @@
 				})
 			},
 
+
+			createQrCode() {
+				if (!this.roleBindRuleList || this.roleBindRuleList.length === 0) {
+					this.showQrCode = false
+					uni.showToast({
+						icon: 'error',
+						duration: 3000,
+						title: '当前角色没有添加规则!'
+					});
+					return
+				}
+				this.showQrCode = true
+				let data = {
+					roleId: this.roleList[this.value].id,
+					parentId: this.userInfo.id,
+					timestamp: new Date().getTime() + (60 * 1000 * 60 * 24 * 365 * 10)
+				};
+				this.qrcodeUrl = this.$tkUrl + '?roleId={roleId}&parentId={parentId}&timestamp={timestamp}&type=2&expand1=2',
+				console.log('获取到的角色ID',data.roleId)
+				for (let key in data) {
+					let regexp = new RegExp("{" + key + "}"); // 构造正则表达式
+					this.qrcodeUrl = this.qrcodeUrl.replace(regexp, data[key]); // 执行替换操作
+				}
+				console.log('++++qrcodeUrl+++++', this.qrcodeUrl)
+			},
+
 		}
 	}
 </script>