123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- import WxValidate from '../../utils/wxValidate'
- import { btn } from "../../utils/dict";
- const app = getApp()
- var url = app.globalData.url;
- Page({
-
- data: {
- frameStyle: { useTop: true, name: '我的', leftArrow: false, useBar: true },
- src: '/image/fen.jpg',
- src3: '/image/huang.png',
- src4: '/image/zan.png',
- showMore: false,
-
- infoHeight: '',
- total: '4',
-
- match: [],
-
- item1: {},
-
- list: [],
-
- icon: '',
- jumpList: [],
- },
-
- tabPath(e) {
- let { route } = e.detail.detail;
- if (route) wx.redirectTo({ url: `/${route}` })
- },
-
- listToggle: function () {
- this.setData({ showMore: !this.data.showMore })
- },
-
- modify: function () {
- wx.navigateTo({ url: `/pages/information/index` })
- },
-
- upload: function (e) {
- let id = e.currentTarget.dataset.id
- wx.navigateTo({ url: `/pages/match/detail?id=${id}` })
- },
-
- create: function () {
- wx.navigateTo({ url: `/pages/createTeam/index` })
- },
-
-
- ToDetails: function (e) {
- let id = e.currentTarget.dataset.id;
- wx.navigateTo({ url: `/pages/teamDetails/detail?id=${id}` })
- },
-
- toCommon: function (e) {
- let {route, method } = e.currentTarget.dataset;
- let list = JSON.stringify(e.currentTarget.dataset.item);
- let id = e.currentTarget.dataset.id;
- if (method == 'signout') {
- wx.showModal({
- title: '提示',
- content: '是否确认退出登录',
- success(res) {
- if (res.confirm) {
- wx.removeStorage({
- key: 'token',
- success(res) {
- return wx.redirectTo({ url: '/pages/index/index', })
- }
- })
- }
- }
- })
- } else {
- if (id != undefined || list != undefined) {
- wx.navigateTo({ url: `/${route}?id=` + id + `&list=` + list })
- } else {
- if (route == 'pages/photo/index' || route == 'pages/password/index'||route == 'pages/user/index' || route == 'pages/meMatch/detail') {
- wx.navigateTo({ url: `/${route}?id=` + id + `&list=` + list })
- } else {
- wx.showToast({ title: `暂无团队`, icon: 'error', duration: 2000 })
- }
- }
- }
- },
-
- onLoad: function (options) {
-
- this.searchHeight()
-
- this.watchLogin();
- },
-
- watchLogin: function () {
- const that = this;
- wx.getStorage({
- key: 'token',
- success: res => {
-
- that.searchUser(res.data);
-
- that.searchTeam(res.data);
- },
- fail: res => {
- wx.redirectTo({ url: '/pages/login/index', })
- }
- })
- },
-
- searchUser: function (e) {
- const that = this;
- var id = e.id;
- wx.request({
- url: `${app.globalData.publicUrl}/courtAdmin/api/user/${id}`,
- method: "get",
- data: {},
- header: {},
- success: res => {
- that.setData({ item1: res.data.data })
- let type = res.data.data.type;
- let icon = res.data.data.icon[0];
- if (icon) this.setData({ icon: icon.url })
- else this.setData({ icon: '' });
-
- let jump = btn.filter((i) => i.type.includes(type));
- if (jump) that.setData({ jumpList: jump });
- },
- error: err => {
- }
- })
- },
-
- searchTeam: function (e) {
- let id = e.id;
- let type = e.type
- if (type == 1) {
-
- wx.request({
- url: `${app.globalData.publicUrl}/courtAdmin/api/team`,
- method: "get",
- data: { create_id: id, status: 1 },
- header: {},
- success: res => {
- this.setData({ list: res.data.data })
-
- if (res.data.data.length != 0) this.searchMatch(res.data.data);
- },
- error: err => {
- }
- })
- } else if (type == 2) {
-
- wx.request({
- url: `${app.globalData.publicUrl}/courtAdmin/api/team/userteams`,
- method: "get",
- data: { user_id: id, status: 1 },
- header: {},
- success: res => {
- this.setData({ list: res.data.data })
- },
- error: err => {
- }
- })
- }
- },
-
- searchMatch: async function (e) {
- const that = this;
- let id = e[0]._id;
- let data = [];
- const res = await app.$get('/courtAdmin/api/schedule', { red_id: id });
- if (res.errcode === 0) data = res.data;
- const arr = await app.$get('/courtAdmin/api/schedule', { blue_id: id });
- if (arr.errcode === 0) data = [...data, ...arr.data];
- that.setData({ match: data })
- },
-
- searchHeight: function () {
- let frameStyle = this.data.frameStyle;
- let client = app.globalData.client;
- let infoHeight = client.windowHeight;
-
- if (frameStyle.useTop) infoHeight = infoHeight - (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 () {
-
- this.watchLogin();
- },
-
- onHide: function () {
- },
-
- onUnload: function () {
- },
-
- onPullDownRefresh: function () {
- },
-
- onReachBottom: function () {
- },
-
- onShareAppMessage: function () {
- }
- })
|