const api = require('../../utils/api') import { getTimestamp } from "../../../../utils/common" const app = getApp() Page({ data: { statusHeight: 0, // 自定义头部状态栏高度 navigationHeight: 0, // 自定义头部导航栏高度 selectTab: "tab1", pageIndex: 1, pageSize: 10, loadMoreVisible: false, loadMoreType: "none", list: [], // 团队成员列表 teamDetail: {}, teamId: '', dialogVisible: false, dialogTitle: "", dialogContent: "", dialogConfirmText: "", dialogCancelText: "", }, onLoad: function (options) { this.setData({ statusHeight: app.globalData.deviceInfo.statusHeight, navigationHeight: app.globalData.deviceInfo.navigationHeight }) if (options.id) { this.setData({ teamId: options.id }) this.getAppTeamDetail() } let params = { pageIndex: 1, pageSize: 10, timestamp: getTimestamp(), actType: 0, qkdat: true, selectedTab: 'tab0', teamId: this.data.teamId } this.selectComponent("#state-0").getActivityList(params) }, onShow: function () { }, onReachBottom: function () { this.setData({ loadMoreVisible: true }) if (this.data.loadMoreType === "loading") { this.setData({ pageIndex: this.data.pageIndex + 1 }) this.getTeamVolunteerList() } }, // 返回上一级 goback () { wx.navigateBack({ delta: 1 }) }, // 志愿者认证 confirmDialog () { wx.navigateTo({ url: "/subpages/heart/pages/volunteer/volunteer" }) }, // 加入团队 joinTeam () { let that = this api.getVolunteerVerify().then(res => { if (res.code == 0) { if (res.data && res.data.id) { let param = { volunteerId: this.data.teamDetail.volunteerId, teamId: this.data.teamId } wx.showModal({ content: '请确认加入团队', confirmColor: '#04BCA0', success (res) { if (res.confirm) { console.log('用户点击确定') api.joinTeam(param).then(res => { if (res.code == 0 && res.msg == 'success') { wx.showToast({ title: '加入成功', icon: 'none', durantion: 2000 }) that.getAppTeamDetail() } else { wx.showToast({ title: res.msg, icon: 'none', durantion: 2000 }) } }) } else if (res.cancel) { console.log('用户点击取消') } } }) } else { this.setData({ dialogVisible: !this.data.dialogVisible, dialogTitle: "志愿者认证", dialogContent: ["是否前往认证志愿者"], dialogConfirmText: "是", dialogCancelText: "否" }) } } }).catch(err => { console.log(err) }) }, // tab 切换 onTabChange (e) { this.setData({ selectTab: e.currentTarget.dataset.tab, pageIndex: 1 }) if (e.currentTarget.dataset.tab == "tab1") { this.setData({ list: [], nodata: false }) let params = { pageIndex: 1, pageSize: 10, timestamp: getTimestamp(), actType: 0, qkdat: true, sponsor: '', selectedTab: 'tab0', teamId: this.data.teamId } this.selectComponent("#state-0").getActivityList(params) } else { this.setData({ list: [], }) this.getTeamVolunteerList() } }, // 通过判断列表的长度断定是否显示加载中 toActDetailDown (e) { if (e.detail.listLength !== this.data.pageSize) { this.setData({ loadMoreVisible: true, loadMoreType: "none", }) } this.setData({ actId: e.detail.actId, listLength: e.detail.listLength }) }, // 团队详情 getAppTeamDetail () { api.getAppTeamDetail({ id: this.data.teamId }).then(res => { this.setData({ teamDetail: res.data }) }) }, // 团队成员列表 // 获取团队列表 getTeamVolunteerList () { const para = { pageIndex: this.data.pageIndex, pageSize: this.data.pageSize, id: this.data.teamId } api.getTeamVolunteerList(para).then(res => { this.setData({ list: [...this.data.list,...res.data], loadMoreType: res.data.length === this.data.pageSize ? 'loading' : 'none', loadMoreVisible: res.data.length === this.data.pageSize ? false : true, nodata: false, }) if (this.data.list.length == 0) { this.setData({ nodata: true, loadMoreType: 'none', loadMoreVisible: false, }) } }).catch(err => { this.setData({ list: [], nodata: true, loadMoreType: 'none', loadMoreVisible: false, }) console.log(err) }) } })