Просмотр исходного кода

Merge branch 'master' of http://git.cc-lotus.info/ball-court/court-mobile

YY 3 лет назад
Родитель
Сommit
5f7ada247d
1 измененных файлов с 72 добавлено и 89 удалено
  1. 72 89
      pages/match/detail.js

+ 72 - 89
pages/match/detail.js

@@ -24,7 +24,8 @@ Page({
     //用户信息
     userdata: {},
     //团队id
-    team_id: '',
+    blue_id: '',
+    red_id: '',
   },
   //验证是否输入
   initValidate() {
@@ -49,7 +50,7 @@ Page({
     })
   },
   //上传图片
-  imgUpload: function (e) {
+  imgUpload: async function (e) {
     const that = this;
     if (that.data.type == '0') {
       return wx.showToast({
@@ -58,53 +59,43 @@ Page({
         icon: 'error',
       })
     } else if (that.data.type == '1') {
-      let id = that.data.team_id
+      let red_id = that.data.red_id
+      let blue_id = that.data.blue_id
       let user_id = that.data.userdata.id
-      //查询数据
-      wx.request({
-        url: `${app.globalData.publicUrl}/courtAdmin/api/team/${id}`, //接口地址
-        method: 'get',
-        data: '',
-        success(res) {
-          if (res.data.errcode == 0) {
-            let create_id = res.data.data.create_id;
-            if (create_id == user_id) {
-              let data = that.data.match_file;
-              let id = that.data.id;
-              data.push(e.detail)
-              wx.request({
-                url: `${app.globalData.publicUrl}/courtAdmin/api/schedule/${id}`, //接口地址
-                method: 'post',
-                data: { match_file: data },
-                success(res) {
-                  if (res.data.errcode == 0) {
-                    wx.showToast({
-                      title: '添加成功',
-                      duration: 2000,
-                      icon: 'success',
-                    })
-                    that.setData({ match_file: data })
-                  } else {
-                    wx.showToast({ title: res.data.errmsg, icon: 'error', duration: 2000 })
-                  }
-                }
-              })
-            } else {
-              return wx.showToast({
-                title: '不可上传',
+      let create_id_one = ''
+      let create_id_two = ''
+      const res = await app.$get('/courtAdmin/api/team', { id: red_id });
+      if (res.errcode === 0) create_id_one = res.data[0].create_id;
+      const arr = await app.$get('/courtAdmin/api/team', { id: blue_id });
+      if (arr.errcode === 0) create_id_two = arr.data[0].create_id;
+      if (create_id_one == user_id || create_id_two == user_id) {
+        let data = that.data.match_file;
+        let id = that.data.id;
+        data.push(e.detail)
+        wx.request({
+          url: `${app.globalData.publicUrl}/courtAdmin/api/schedule/${id}`, //接口地址
+          method: 'post',
+          data: { match_file: data },
+          success(res) {
+            if (res.data.errcode == 0) {
+              wx.showToast({
+                title: '添加成功',
                 duration: 2000,
-                icon: 'error',
+                icon: 'success',
               })
+              that.setData({ match_file: data })
+            } else {
+              wx.showToast({ title: res.data.errmsg, icon: 'error', duration: 2000 })
             }
-          } else {
-            wx.showToast({
-              title: res.data.errmsg,
-              icon: 'none',
-              duration: 2000
-            })
           }
-        }
-      })
+        })
+      } else {
+        return wx.showToast({
+          title: '不可上传',
+          duration: 2000,
+          icon: 'error',
+        })
+      }
     } else if (that.data.type == '2') {
       let userid = that.data.userdata.id
       let red_members = that.data.info.red_members;
@@ -134,7 +125,7 @@ Page({
         })
       } else {
         return wx.showToast({
-          title: '不可上传',
+          title: '不可删除',
           duration: 2000,
           icon: 'error',
         })
@@ -142,7 +133,7 @@ Page({
     }
   },
   //删除图片
-  imgDel: function (e) {
+  imgDel: async function (e) {
     const that = this;
     if (that.data.type == '0') {
       return wx.showToast({
@@ -151,53 +142,44 @@ Page({
         icon: 'error',
       })
     } else if (that.data.type == '1') {
-      let id = that.data.team_id
+      let red_id = that.data.red_id
+      let blue_id = that.data.blue_id
       let user_id = that.data.userdata.id
-      //查询数据
-      wx.request({
-        url: `${app.globalData.publicUrl}/courtAdmin/api/team/${id}`, //接口地址
-        method: 'get',
-        data: '',
-        success(res) {
-          if (res.data.errcode == 0) {
-            let create_id = res.data.data.create_id;
-            if (create_id == user_id) {
-              let data = that.data.match_file;
-              let id = that.data.id;
-              let arr = data.filter((i, index) => index != e.detail.index)
-              wx.request({
-                url: `${app.globalData.publicUrl}/courtAdmin/api/schedule/${id}`, //接口地址
-                method: 'post',
-                data: { match_file: arr },
-                success(res) {
-                  if (res.data.errcode == 0) {
-                    wx.showToast({
-                      title: '删除成功',
-                      duration: 2000,
-                      icon: 'success',
-                    })
-                    that.setData({ match_file: arr })
-                  } else {
-                    wx.showToast({ title: res.data.errmsg, icon: 'error', duration: 2000 })
-                  }
-                }
-              })
-            } else {
-              return wx.showToast({
-                title: '不可删除',
+      let create_id_one = ''
+      let create_id_two = ''
+      const res = await app.$get('/courtAdmin/api/team', { id: red_id });
+      if (res.errcode === 0) create_id_one = res.data[0].create_id;
+      const arr = await app.$get('/courtAdmin/api/team', { id: blue_id });
+      if (arr.errcode === 0) create_id_two = arr.data[0].create_id;
+      if (create_id_one == user_id || create_id_two == user_id) {
+        let data = that.data.match_file;
+        let id = that.data.id;
+        let arr = data.filter((i, index) => index != e.detail.index)
+        wx.request({
+          url: `${app.globalData.publicUrl}/courtAdmin/api/schedule/${id}`, //接口地址
+          method: 'post',
+          data: { match_file: arr },
+          success(res) {
+            if (res.data.errcode == 0) {
+              wx.showToast({
+                title: '删除成功',
                 duration: 2000,
-                icon: 'error',
+                icon: 'success',
               })
+              that.setData({ match_file: arr })
+            } else {
+              wx.showToast({ title: res.data.errmsg, icon: 'error', duration: 2000 })
             }
-          } else {
-            wx.showToast({
-              title: res.data.errmsg,
-              icon: 'none',
-              duration: 2000
-            })
           }
-        }
-      })
+        })
+      } else {
+        return wx.showToast({
+          title: '不可上传',
+          duration: 2000,
+          icon: 'error',
+        })
+      }
+
     } else if (that.data.type == '2') {
       let userid = that.data.userdata.id
       let red_members = that.data.info.red_members;
@@ -290,7 +272,8 @@ Page({
         if (arr.errcode === 0) {
           that.setData({
             info: arr.data,
-            team_id: arr.data.blue_id
+            blue_id: arr.data.blue_id,
+            red_id: arr.data.red_id
           })
           that.setData({ match_file: arr.data.match_file })
         }