// pages/login/login.js import WxValidate from '../../utils/wxValidate' const app = getApp() var url = app.globalData.url Page({ /** * 页面的初始数据 */ data: { src: '/image/fen.jpg', src3: '/image/huang.png', src4: '/image/zan.png', showMore: false, frameStyle: { useTop: true, name: '我的', leftArrow: false, useBar: true }, // 主体高度 infoHeight: '', total: '4', item: { id: '1', head2: '/image/head2.png', head1: '/image/head1.png', fraction2: '0', groupname2: '马尼拉组', fraction1: '0', site: '第一场', groupname1: '哈拉海组', week: '星期五', time: '13:00', state: '已结束', date: '01.15', start: '未开始' }, item1: {}, list3: [], //头像 icon: '', //团队logo showModal: false, }, tabPath(e) { let query = e.detail.detail; if (query) wx.redirectTo({ url: `/pages/${query}/index` }) }, //展开 listToggle: function () { this.setData({ showMore: !this.data.showMore }) }, //修改个人信息 modify: function () { wx.navigateTo({ url: `/pages/information/index`, }) }, //上传比分 upload: function () { wx.navigateTo({ url: `/pages/score/index`, }) }, //创建团队 create: function () { wx.navigateTo({ url: `/pages/createTeam/index`, }) }, ToDetails: function () { wx.navigateTo({ url: `/pages/teamDetails/detail`, }) }, //已上传图片 Uploaded: function () { wx.navigateTo({ url: `/pages/photo/index`, }) }, //修改密码 change: function () { wx.navigateTo({ url: `/pages/password/index`, }) }, //审核队员 examine: function () { wx.navigateTo({ url: `/pages/auditTeam/index`, }) }, //解散申请 apply: function (e) { let id= e.currentTarget.dataset.id; wx.navigateTo({ url: `/pages/dissolution/index?id=`+id, }) }, //解散团队弹窗 clickme: function () { this.setData({ showModal: true }) }, preventTouchMove: function () { }, //关闭弹窗 go: function () { this.setData({ showModal: false }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { // 计算高度 this.searchHeight() // 监听用户是否登录 this.watchLogin(); const that = this; wx.getStorage({ key: 'token', success: res => { //数据请求 wx.request({ url: `${app.globalData.publicUrl}/courtAdmin/api/team`, //接口地址 method: "get",//请求方法 data: {},//请求参数 header: {}, success: res => { // console.log(res); that.setData({ list3: res.data.data }) console.log(res.data.data); }, error: err => { console.log(err); } }) }, fail: res => { wx.redirectTo({ url: '/pages/login/index', }) } }) }, // 监听用户是否登录 watchLogin: function () { const that = this; wx.getStorage({ key: 'token', success: res => { //数据请求 wx.request({ url: `${app.globalData.publicUrl}/courtAdmin/api/user/${res.data.id}`, //接口地址 method: "get",//请求方法 data: {},//请求参数 header: {}, success: res => { // console.log(res); that.setData({ item1: res.data.data }) let icon = res.data.data.icon[0]; if (icon) this.setData({ icon: icon.url }) else this.setData({ icon: '/image/tou.png' }) console.log(res.data.data); }, error: err => { console.log(err); } }) }, fail: res => { wx.redirectTo({ url: '/pages/login/index', }) } }) }, tui() { wx.showModal({ title: '', content: '是否确认退出登录', success(res) { if (res.confirm) { wx.removeStorage({ key: 'token', success (res) { return wx.redirectTo({ url: '/pages/index/index', }) } }) } else if (res.cancel) { console.log('用户点击取消') } } }) }, // 计算高度 searchHeight: function () { let frameStyle = this.data.frameStyle; let client = app.globalData.client; // 减去状态栏 let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2); // 是否减去底部菜单 if (frameStyle.useBar) infoHeight = infoHeight - 50; if (infoHeight) this.setData({ infoHeight: infoHeight }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })