123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- const app = getApp()
- Page({
- data: {
- logo: '',
- team_id: "",
- searchInfo: {},
- list: [],
- total: 0,
- page: 0,
- skip: 0,
- limit: 5,
- statusList: [],
- genderList: []
- },
- // 审核
- toExam(e) {
- const that = this;
- let item = e.currentTarget.dataset.item
- wx.showActionSheet({
- itemList: ['审核中', '审核通过', '审核拒绝'], // 文字数组
- success: async (res) => {
- switch (res.tapIndex) {
- case 0: {
- let data = { status: '0' }
- let res = await app.$api(`teamApply/${item._id}`, 'POST', data);
- if (res.errcode == '0') {
- that.clearPage();
- that.search()
- break;
- }
- }
- case 1: {
- let data = { status: '1' }
- let res = await app.$api(`teamApply/${item._id}`, 'POST', data);
- if (res.errcode == '0') {
- that.clearPage();
- that.search()
- break;
- }
- }
- case 2: {
- let data = { status: '-1' }
- let res = await app.$api(`teamApply/${item._id}`, 'POST', data);
- if (res.errcode == '0') {
- that.clearPage();
- that.search()
- break;
- }
- }
- }
- }, fail(res) { console.log('取消选项') }
- })
- },
- // 查询
- async toSearch(e) {
- const that = this;
- if (e.detail.value) that.setData({ 'searchInfo.name': e.detail.value })
- else that.setData({ searchInfo: {} })
- that.clearPage();
- that.search()
- },
- // 分页-触底
- toLower() {
- const that = this;
- let list = that.data.list;
- let limit = that.data.limit;
- if (that.data.total > list.length) {
- wx.showLoading({ title: '加载中', mask: true })
- let page = that.data.page + 1;
- that.setData({ page })
- let skip = page * limit
- that.setData({ skip })
- that.search()
- wx.hideLoading()
- } else {
- wx.showToast({ title: `到底了没数据了`, icon: 'none' });
- }
- },
- // 分页-滚动
- toScroll() {
- // console.log('滚动');
- },
- // 字典
- getDict(value, model) {
- const that = this;
- if (model == 'status') {
- if (value) {
- let data = that.data.statusList.find(i => i.value == value)
- if (data) return data.label
- else return '暂无'
- }
- }
- },
- // 清空列表
- clearPage() {
- const that = this;
- that.setData({ list: [] })
- that.setData({ skip: 0 })
- that.setData({ limit: 5 })
- that.setData({ total: 0 })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- async onLoad(options) {
- const that = this;
- that.setData({ team_id: options.id });
- wx.showLoading({ title: '加载中', mask: true })
- await that.searchConfig()
- await that.searchOther()
- await that.search()
- wx.hideLoading()
- },
- async searchConfig() {
- const that = this;
- wx.getStorage({
- key: 'config',
- async success(res) {
- // logo
- if (res.data && res.data.logo_url && res.data.logo_url.length > 0) {
- let logo = res.data.logo_url[0].url
- that.setData({ logo })
- }
- },
- fail(err) {
- // console.log(err);
- }
- })
- },
- // 查询其他信息
- async searchOther() {
- const that = this;
- let res;
- res = await app.$api('dictData', 'GET', { type: 'status', is_use: '0' })
- if (res.errcode == '0') that.setData({ statusList: res.data })
- res = await app.$api('dictData', 'GET', { type: 'gender', is_use: '0' })
- if (res.errcode == '0') that.setData({ genderList: res.data })
- },
- // 查询通知
- async search() {
- const that = this;
- let info = { skip: that.data.skip, limit: that.data.limit, team_id: that.data.team_id };
- let res = await app.$api('teamApply', 'GET', { ...info, ...that.data.searchInfo })
- if (res.errcode == '0') {
- let list = [...that.data.list, ...res.data]
- for (const val of list) {
- let arr = await app.$api(`user/${val.apply_id}`, 'GET', {})
- if (arr.errcode == '0') {
- let data = that.data.genderList.find(i => i.value == arr.data.gender)
- if (data) arr.data.gender_name = data.label
- val.userInfo = arr.data
- }
- val.status_name = that.getDict(val.status, 'status')
- }
- that.setData({ list })
- that.setData({ total: res.total })
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|