zs 1 年之前
父节点
当前提交
62fa4e6278
共有 1 个文件被更改,包括 26 次插入22 次删除
  1. 26 22
      pagesMatch/enroll/index.js

+ 26 - 22
pagesMatch/enroll/index.js

@@ -100,6 +100,7 @@ Page({
         wx.showLoading({ title: '加载中', mask: true })
         //验证规则函数
         that.initValidate();
+        await that.searchUser()
         await that.searchOther()
         await that.search()
         wx.hideLoading()
@@ -109,39 +110,42 @@ Page({
         const messages = { match_name: { required: '请输入比赛名称' }, team_name: { required: '请输入团队名称' } };
         this.WxValidate = new WxValidate(rules, messages)
     },
-    // 查询其他信息
-    async searchOther() {
-        const that = this;
-        let res;
-        // 团队
-        res = await app.$api('team', 'GET', { administrator: that.data.user._id, status: '1' })
-        if (res.errcode == '0') that.setData({ teamList: res.data })
-    },
-    search() {
+    async searchUser() {
         const that = this;
         wx.getStorage({
             key: 'user',
             async success(res) {
                 that.setData({ user: res.data })
-                if (that.data.id) {
-                    let arr = await app.$api(`application/${that.data.id}`, 'GET', {})
-                    if (arr.errcode == '0') {
-                        let data = that.data.teamList.find(i => i._id == arr.data.team_id);
-                        if (data) that.setData({ userList: data.member })
-                        that.setData({ form: arr.data, memberList: arr.data.user_id })
-                    }
-                } else {
-                    let aee = await app.$api(`match/${that.data.match_id}`, 'GET', {})
-                    if (aee.errcode == '0') {
-                        that.setData({ 'form.match_id': aee.data._id, 'form.match_name': aee.data.name })
-                    }
-                }
             },
             fail(err) {
                 // console.log(err);
             }
         })
     },
+    // 查询其他信息
+    async searchOther() {
+        const that = this;
+        let res;
+        // 团队
+        res = await app.$api('team', 'GET', { administrator: that.data.user._id, status: '1' })
+        if (res.errcode == '0') that.setData({ teamList: res.data })
+    },
+    async search() {
+        const that = this;
+        if (that.data.id) {
+            let arr = await app.$api(`application/${that.data.id}`, 'GET', {})
+            if (arr.errcode == '0') {
+                let data = that.data.teamList.find(i => i._id == arr.data.team_id);
+                if (data) that.setData({ userList: data.member })
+                that.setData({ form: arr.data, memberList: arr.data.user_id })
+            }
+        } else {
+            let aee = await app.$api(`match/${that.data.match_id}`, 'GET', {})
+            if (aee.errcode == '0') {
+                that.setData({ 'form.match_id': aee.data._id, 'form.match_name': aee.data.name })
+            }
+        }
+    },
 
     /**
      * 生命周期函数--监听页面初次渲染完成