You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							186 lines
						
					
					
						
							4.4 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							186 lines
						
					
					
						
							4.4 KiB
						
					
					
				
								import { getAssociationMember, incomingVerify } from '../../utils/api'
							 | 
						|
								import convertPY from '../../utils/convertPY'
							 | 
						|
								
							 | 
						|
								Page({
							 | 
						|
								  data: {
							 | 
						|
								    chooseAllValue: false,
							 | 
						|
								    noticeVerifyVisible: false,
							 | 
						|
								    incomingMemberList: [],
							 | 
						|
								    initIncomingMemberList: [],
							 | 
						|
								    groupId: '',
							 | 
						|
								    id: '',
							 | 
						|
								    userId: ''
							 | 
						|
								  },
							 | 
						|
								  onLoad (options) {
							 | 
						|
								    this.getAssociationMember(options.id)
							 | 
						|
								    this.setData({
							 | 
						|
								      groupId: options.id
							 | 
						|
								    })
							 | 
						|
								  },
							 | 
						|
								  chooseAll () {
							 | 
						|
								    if (this.data.initIncomingMemberList.length === 0) {
							 | 
						|
								      wx.showToast({
							 | 
						|
								        title: '暂无可审核群成员',
							 | 
						|
								        icon: 'none',
							 | 
						|
								        duration: 2000
							 | 
						|
								      })
							 | 
						|
								      this.setData({
							 | 
						|
								        chooseAllValue: false
							 | 
						|
								      })
							 | 
						|
								    } else {
							 | 
						|
								      this.setData({
							 | 
						|
								        chooseAllValue: !this.data.chooseAllValue
							 | 
						|
								      })
							 | 
						|
								    }
							 | 
						|
								  },
							 | 
						|
								  // 全部通过 审核入群
							 | 
						|
								  verify () {
							 | 
						|
								    const members = []
							 | 
						|
								    this.data.initIncomingMemberList.forEach(item => {
							 | 
						|
								      members.push({
							 | 
						|
								        state: 10,
							 | 
						|
								        auditOpinion: '',
							 | 
						|
								        id: item.id,
							 | 
						|
								        userId: item.userId
							 | 
						|
								      })
							 | 
						|
								    })
							 | 
						|
								    const para = {
							 | 
						|
								      groupId: this.data.groupId,
							 | 
						|
								      members
							 | 
						|
								    }
							 | 
						|
								    wx.showLoading({
							 | 
						|
								      title: '加载中'
							 | 
						|
								    })
							 | 
						|
								    incomingVerify(para).then(res => {
							 | 
						|
								      wx.hideLoading()
							 | 
						|
								      console.log('审核群成员', res)
							 | 
						|
								      wx.showToast({
							 | 
						|
								        title: '审核群成员成功',
							 | 
						|
								        icon: 'none',
							 | 
						|
								        duration: 2000
							 | 
						|
								      })
							 | 
						|
								      const pages = getCurrentPages()
							 | 
						|
								      const page = pages[pages.length - 2]
							 | 
						|
								      page.getAssociationDetail()
							 | 
						|
								      setTimeout(() => {
							 | 
						|
								        wx.navigateBack({
							 | 
						|
								          delta: 1
							 | 
						|
								        })
							 | 
						|
								      }, 500)
							 | 
						|
								      // this.getAssociationMember(this.data.groupId)
							 | 
						|
								      console.log(res)
							 | 
						|
								    }).catch(err => {
							 | 
						|
								      console.log(err)
							 | 
						|
								    })
							 | 
						|
								  },
							 | 
						|
								  // 审核 未通过
							 | 
						|
								  unpass (e) {
							 | 
						|
								    this.setData({
							 | 
						|
								      noticeVerifyVisible: !this.data.noticeVerifyVisible
							 | 
						|
								    })
							 | 
						|
								    if (e.detail.data === '') {
							 | 
						|
								      wx.showToast({
							 | 
						|
								        title: '备注不能为空',
							 | 
						|
								        icon: 'none',
							 | 
						|
								        duration: 2000
							 | 
						|
								      })
							 | 
						|
								      return false
							 | 
						|
								    }
							 | 
						|
								    const para = {
							 | 
						|
								      groupId: this.data.groupId,
							 | 
						|
								      members: [{
							 | 
						|
								        state: 5,
							 | 
						|
								        auditOpinion: e.detail.data,
							 | 
						|
								        id: this.data.id,
							 | 
						|
								        userId: this.data.userId
							 | 
						|
								      }]
							 | 
						|
								    }
							 | 
						|
								    wx.showLoading({
							 | 
						|
								      title: '加载中'
							 | 
						|
								    })
							 | 
						|
								    incomingVerify(para).then(res => {
							 | 
						|
								      wx.hideLoading()
							 | 
						|
								      console.log('审核群成员', res)
							 | 
						|
								      wx.showToast({
							 | 
						|
								        title: '审核群成员成功',
							 | 
						|
								        icon: 'none',
							 | 
						|
								        duration: 2000
							 | 
						|
								      })
							 | 
						|
								      this.getAssociationMember(this.data.groupId)
							 | 
						|
								      this.setData({
							 | 
						|
								        noticeVerifyVisible: !this.data.noticeVerifyVisible
							 | 
						|
								      })
							 | 
						|
								    }).catch(err => {
							 | 
						|
								      console.log(err)
							 | 
						|
								    })
							 | 
						|
								  },
							 | 
						|
								  // 审核 通过
							 | 
						|
								  pass (e) {
							 | 
						|
								    const para = {
							 | 
						|
								      groupId: this.data.groupId,
							 | 
						|
								      members: [{
							 | 
						|
								        state: 10,
							 | 
						|
								        auditOpinion: e.detail.data,
							 | 
						|
								        id: this.data.id,
							 | 
						|
								        userId: this.data.userId
							 | 
						|
								      }]
							 | 
						|
								    }
							 | 
						|
								    wx.showLoading({
							 | 
						|
								      title: '加载中'
							 | 
						|
								    })
							 | 
						|
								    incomingVerify(para).then(res => {
							 | 
						|
								      wx.hideLoading()
							 | 
						|
								      console.log('审核群成员', res)
							 | 
						|
								      wx.showToast({
							 | 
						|
								        title: '审核群成员成功',
							 | 
						|
								        icon: 'none',
							 | 
						|
								        duration: 2000
							 | 
						|
								      })
							 | 
						|
								      const pages = getCurrentPages()
							 | 
						|
								      const page = pages[pages.length - 2]
							 | 
						|
								      page.getAssociationDetail()
							 | 
						|
								      this.getAssociationMember(this.data.groupId)
							 | 
						|
								    }).catch(err => {
							 | 
						|
								      console.log(err)
							 | 
						|
								    })
							 | 
						|
								  },
							 | 
						|
								  // 获取群成员列表
							 | 
						|
								  getAssociationMember (groupId) {
							 | 
						|
								    const para = {
							 | 
						|
								      state: 0,
							 | 
						|
								      groupId,
							 | 
						|
								    }
							 | 
						|
								    getAssociationMember(para).then(res => {
							 | 
						|
								      console.log('待审核群成员',res)
							 | 
						|
								      this.setData({
							 | 
						|
								        initIncomingMemberList: res.data
							 | 
						|
								      })
							 | 
						|
								      let incomingMemberList = []
							 | 
						|
								      res.data.forEach(item => {
							 | 
						|
								        const alphabet = convertPY.convertPYs(item.nickname)
							 | 
						|
								        const index = incomingMemberList.findIndex(item => item.alphabet === alphabet)
							 | 
						|
								        if (index > -1) {
							 | 
						|
								          incomingMemberList[index].memberList.push(item)
							 | 
						|
								        } else {
							 | 
						|
								          incomingMemberList.push({
							 | 
						|
								            alphabet: alphabet,
							 | 
						|
								            memberList: [item]
							 | 
						|
								          })
							 | 
						|
								        }
							 | 
						|
								      })
							 | 
						|
								      incomingMemberList.sort((a,b) => a.alphabet.charCodeAt() - b.alphabet.charCodeAt())
							 | 
						|
								      this.setData({
							 | 
						|
								        incomingMemberList
							 | 
						|
								      })
							 | 
						|
								    }).catch(err => {
							 | 
						|
								      console.log(err)
							 | 
						|
								    })
							 | 
						|
								  },
							 | 
						|
								  operationBtn (e) {
							 | 
						|
								    this.setData({
							 | 
						|
								      id: e.detail.id,
							 | 
						|
								      userId: e.detail.userId,
							 | 
						|
								      noticeVerifyVisible: !this.data.noticeVerifyVisible
							 | 
						|
								    })
							 | 
						|
								  }
							 | 
						|
								})
							 |