<template>
	<view class="app">
		<view class="tips">
			<view class="tip">群管理可以拥有的能力</view>
			<view class="tip">·可以拉群申请，邀请其他人加群里</view>
			<view class="tip">·移除群聊成员（群主/管理员除外）</view>
			<view class="tip">·发布群公告</view>
			<view class="tip">·修改群名称</view>
		</view>
		<view class="cath-user fx-r">
			<view class="item fx-h fx-bc fx-ac" v-for="item in data">
					<image class="avatar" :src="item.avatar == '' ? '/static/chat/user-avatar.png' : item.avatar" mode="aspectFill"></image>
					<view class="text" style="width: 16vw;">{{item.nickname}}</view>
				</view>
				<view class="item fx-h fx-bc fx-ac" @tap="tapAdd" >
					<image  class="avatar" src="/static/chat/id_chat_add.png" mode="aspectFill"></image>
					<view class="text">添加成员</view>
				</view>
				<view class="item fx-h fx-bc fx-ac" @tap="tapJdd">
					<image  class="avatar" src="/static/chat/id_chat_reduce.png" mode="aspectFill"></image>
					<view class="text">移除成员</view>
				</view>
			</view>
		</view>
		
		
	</view>
</template>
<style>
	.tips{padding: 10px;border-bottom: 1px solid #f1f1f1;}
	.tips .tip{font-size: 14px;color: #787878;margin-top: 4px;}
	
	.cath-user{padding: 10px;}
	.cath-user .item{width:16.5%;margin-bottom: 10px;}
	.cath-user .item .avatar{width:40px;height: 40px;border-radius: 6px;}
	.cath-user .item .text{font-size: 12px;margin-top: 4px;overflow:hidden; white-space:nowrap; text-overflow:ellipsis;text-align: center;}
</style>

<script>
		import {mapState,mapMutations} from 'vuex';
		export default {
			computed: mapState(['user','sysData','txbagenum']),
			data() {
				return {
					data  : [],
					groupId	: 0
				}
			},
			onLoad(options) {
				this.groupId = options.groupId;
				this.checkUserLogin({
					page:this,isLogin:true,fn:this.initView
				});
				uni.$on('groupAdmin',this.initView);
			},
			onUnload() {
				uni.$off('groupAdmin',this.initView);
			},
			methods: {
				...mapMutations(['checkUserLogin','setSys']),
				/**
				 * 
				 */
				initView:function(){
					uni.showLoading({ title:"加载中..." });
					this
						.request
						.post("chatGroupAdminuser",{groupId : this.groupId})
						.then(res=>{
							uni.hideLoading();
							if(res.code == 200) {
								this.data = res.data;
							} else {
								this.utils.showModal(res.msg);
							}
						})
						.catch(err=>{
							uni.hideLoading();
							uni.showModal({title: '系统提示',content: '加载失败，返回在尝试',showCancel: false});
						});
				},
				
				tapAdd:function(){
					var nAr = [];
					for(var i in this.data){
						nAr.push(this.data[i].uid);
					}
					uni.navigateTo({
						url:"adminAdd?groupId=" + this.groupId + "&notData=" + JSON.stringify(nAr)
					})
				},
				
				tapJdd:function(){
					uni.navigateTo({
						url:"adminJdd?groupId=" + this.groupId
					})
				}
				
				
		   }
		}
</script>
	

