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.
118 lines
3.5 KiB
118 lines
3.5 KiB
// pages/home/employee/index.js
|
|
import Scene from '../../index/scene'
|
|
import { getCheckList, auditEmploye, createQrcode } from "../../../api/user"
|
|
import { getEmployeList } from "../../../api/saas"
|
|
const event = require('../../../utils/event')
|
|
const util = require('../../../utils/util')
|
|
const app = getApp()
|
|
|
|
Scene({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
type: 0,
|
|
height: app.globalData.fragmentHeight,
|
|
loading: true,
|
|
checkList: [],
|
|
memberList: [],
|
|
nowIndex: -1,
|
|
qrcode: null
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
if(options.type){
|
|
this.data.type = Number(options.type)
|
|
}
|
|
event.on('EventMessage', this, this.onEvent)
|
|
this.setData({ height: app.globalData.fragmentHeight })
|
|
this.fetchMemberList()
|
|
if(this.data.type == 0){
|
|
const form = { id: 5 }
|
|
form.metaData = { factoryId: app.userInfo.factoryId, factoryName: app.userInfo.factoryName }
|
|
createQrcode(form).then(result => {
|
|
this.setData({ qrcode: result.data.id })
|
|
}).catch(err => {
|
|
util.showToast(err)
|
|
})
|
|
}
|
|
},
|
|
onEvent: function(message){
|
|
if (message.what == 120) {
|
|
var that = this
|
|
this.timeout = setTimeout(() => {
|
|
that.fetchMemberList()
|
|
}, 1000)
|
|
}
|
|
},
|
|
fetchMemberList: function(){
|
|
wx.showLoading({ title: '加载中', mask: true })
|
|
if(this.data.type == 0){
|
|
getCheckList({enterpriseId: app.userInfo.enterpriseId}).then(result => {
|
|
this.setData({ checkList: result.data.records, loading: false})
|
|
}).catch(err => {
|
|
util.showToast(err)
|
|
})
|
|
}
|
|
getEmployeList({enterpriseId: app.userInfo.enterpriseId, isPassFromBackstage: 1}).then(result => {
|
|
this.setData({ memberList: result.data.records, loading: false })
|
|
wx.hideLoading()
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
},
|
|
lookItem: function(e){
|
|
this.data.nowIndex = e.currentTarget.dataset.index
|
|
var item = this.data.memberList[this.data.nowIndex]
|
|
if(this.data.type){
|
|
const channel = this.getOpenerEventChannel()
|
|
channel.emit('onCallback', { what: 121, detail: item })
|
|
wx.navigateBack()
|
|
} else {
|
|
wx.navigateTo({
|
|
url: `/pages/home/qrcode-info/index?type=1&id=${item.enterpriseMemberId}`,
|
|
success: function(res) {
|
|
res.eventChannel.emit('onParam', item)
|
|
}
|
|
})
|
|
}
|
|
},
|
|
agreeItem: function(e){
|
|
this.data.nowIndex = e.currentTarget.dataset.index
|
|
var item = this.data.checkList[this.data.nowIndex]
|
|
wx.navigateTo({
|
|
url: `/pages/home/employee-info/index?id=${item.enterpriseMemberId}`,
|
|
success: function(res) {
|
|
res.eventChannel.emit('onParam', item)
|
|
}
|
|
})
|
|
},
|
|
refuseItem: function(e){
|
|
wx.showLoading({ title: '加载中', mask: true })
|
|
var item = this.data.checkList[e.currentTarget.dataset.index]
|
|
auditEmploye({id: item.id, status: 2 }).then(result => {
|
|
this.setData({ ['checkList[' + e.currentTarget.dataset.index + '].status']: 2})
|
|
wx.hideLoading()
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
},
|
|
onShareAppMessage: function () {
|
|
return {
|
|
title: '邀请您加入' + app.userInfo.factoryName,
|
|
imageUrl: 'https://img.imgdb.cn/item/607660278322e6675ccd9960.png',
|
|
path: `pages/login/index?qrcode=${this.data.qrcode}`
|
|
}
|
|
},
|
|
onUnload: function(){
|
|
if(this.timeout){
|
|
clearTimeout(this.timeout)
|
|
this.timeout = null
|
|
}
|
|
event.remove('EventMessage', this)
|
|
}
|
|
})
|