123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- // 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 () {
- }
- })
|