Browse Source

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

zs 2 years ago
parent
commit
2a2d0942cc
6 changed files with 573 additions and 21 deletions
  1. 123 0
      pages/match/schedule.js
  2. 2 1
      pages/match/schedule.json
  3. 57 1
      pages/match/schedule.wxml
  4. 379 0
      pages/match/schedule.wxss
  5. 11 18
      pages/me/index.js
  6. 1 1
      pages/me/index.wxml

+ 123 - 0
pages/match/schedule.js

@@ -10,16 +10,139 @@ Page({
         frameStyle: { useTop: true, name: '比赛信息', leftArrow: true, useBar: false },
         // 主体高度
         infoHeight: '',
+        // 数据id
+        id: '',
+        //详情数据
+        info: {},
+        //用户信息
+        userdata: {},
+        //判断用户类别
+        type: '',
+        //团队id
+        blueTeam: {},
+        redTeam: {},
+        // 现场图片
+        match_file: [],
     },
     back: function () {
         wx.navigateBack({ delta: 1 })
     },
+    //上传图片
+    imgUpload: async function (e) {
+        const that = this;
+        let type = that.data.type;
+        let redTeam = that.data.redTeam;
+        let blueTeam = that.data.blueTeam;
+        let user = that.data.userdata;
+        let info = that.data.info;
+        if (type == '0') {
+            wx.showToast({ title: '不可上传', duration: 2000, icon: 'error', })
+        } else if (type == '1') {
+            if (redTeam || blueTeam) {
+                if (redTeam && redTeam.create_id == user._id || blueTeam && blueTeam.create_id == user._id) {
+                    let data = that.data.match_file;
+                    let id = that.data.id;
+                    data.push(e.detail);
+                    const arr = await app.$post(`/courtAdmin/api/schedule/${id}`, { match_file: data });
+                    if (arr.errcode === 0) {
+                        wx.showToast({ title: `上传图片成功`, icon: 'success', duration: 2000 })
+                        that.watchLogin();
+                    } else {
+                        wx.showToast({ title: arr.errmsg, icon: 'success', duration: 2000 })
+                    }
+                } else {
+                    wx.showToast({ title: '不可上传', duration: 2000, icon: 'error', })
+                }
+            }
+        } else if (type == '2') {
+            let redM = info.red_members.find((i) => i.id == user._id);
+            let blueM = info.blue_members.find((i) => i.id == user._id);
+            if (redM || blueM) {
+                let data = that.data.match_file;
+                let id = that.data.id;
+                data.push(e.detail);
+                const arr = await app.$post(`/courtAdmin/api/schedule/${id}`, { match_file: data });
+                if (arr.errcode === 0) {
+                    wx.showToast({ title: `上传图片成功`, icon: 'success', duration: 2000 })
+                    that.watchLogin();
+                } else {
+                    wx.showToast({ title: arr.errmsg, icon: 'success', duration: 2000 })
+                }
+            } else {
+                wx.showToast({ title: '不可上传', duration: 2000, icon: 'error', })
+            }
+        }
+    },
+    //删除图片
+    imgDel: async function (e) {
+        const that = this;
+        let type = that.data.type;
+        let redTeam = that.data.redTeam;
+        let blueTeam = that.data.blueTeam;
+        let user = that.data.userdata;
+        let info = that.data.info;
+        if (type == '0') {
+            wx.showToast({ title: '不可删除', duration: 2000, icon: 'error', })
+        } else if (type == '1') {
+            if (redTeam || blueTeam) {
+                if (redTeam && redTeam.create_id == user._id || blueTeam && blueTeam.create_id == user._id) {
+                    let id = that.data.id;
+                    let data = that.data.match_file;
+                    let arr = data.filter((i, index) => index != e.detail.index)
+                    const res = await app.$post(`/courtAdmin/api/schedule/${id}`, { match_file: arr });
+                    if (res.errcode === 0) {
+                        wx.showToast({ title: `删除图片成功`, icon: 'success', duration: 2000 })
+                        that.watchLogin();
+                    } else {
+                        wx.showToast({ title: arr.errmsg, icon: 'success', duration: 2000 })
+                    }
+                } else {
+                    wx.showToast({ title: '不可上传', duration: 2000, icon: 'error', })
+                }
+            }
+        } else if (type == '2') {
+            wx.showToast({ title: '不可删除', duration: 2000, icon: 'error', })
+        }
+    },
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
+        const that = this;
+        that.setData({ id: options.id })
         // 计算高度
         this.searchHeight()
+        // 监听用户是否登录
+        this.watchLogin();
+    },
+    // 监听用户是否登录
+    watchLogin: async function () {
+        const that = this;
+        let id = that.data.id;
+        wx.getStorage({
+            key: 'token',
+            success: async res => {
+                // 用户类别,用户信息
+                that.setData({ type: res.data.type, userdata: res.data })
+                const arr = await app.$get(`/courtAdmin/api/schedule/${id}`);
+                if (arr.errcode === 0) {
+                    // 比赛信息,红方id,蓝方id
+                    that.setData({ info: arr.data })
+                    // 现场图片
+                    that.setData({ match_file: arr.data.match_file })
+                    // 查询红方,蓝方信息
+                    const p1 = await app.$get(`/courtAdmin/api/team/${arr.data.red_id}`);
+                    const p2 = await app.$get(`/courtAdmin/api/team/${arr.data.blue_id}`);
+                    if (p1.errcode === 0 && p2.errcode === 0) {
+                        that.setData({ redTeam: p1.data })
+                        that.setData({ blueTeam: p2.data })
+                    }
+                }
+            },
+            fail: res => {
+                return wx.redirectTo({ url: '/pages/login/index', })
+            }
+        })
     },
     // 计算高度
     searchHeight: function () {

+ 2 - 1
pages/match/schedule.json

@@ -1,6 +1,7 @@
 {
     "component": true,
     "usingComponents": {
-      "mobile-main": "/commpents/mobile-frame/mobile-main"
+      "mobile-main": "/commpents/mobile-frame/mobile-main",
+      "upload": "/commpents/upload/index"
     }
   }

+ 57 - 1
pages/match/schedule.wxml

@@ -1,5 +1,61 @@
 <mobile-main frameStyle="{{frameStyle}}" bind:back="back">
   <view slot="info" class="main" style="height:{{infoHeight}}px;">
-    模板
+    <view class="one">
+      <view class="one_1">
+        <view class="one_1_1">
+          <image src="{{info.blue_logo[0].url}}"></image>
+          <view class="textOver">{{info.blue_name}}</view>
+        </view>
+        <view class="one_1_1 one_1_2">
+          <view class="time">{{info.match_time}}</view>
+          <view class="branch">
+            <text>{{info.blue_branch||0}}</text>
+            <text>:</text>
+            <text>{{info.red_branch||0}}</text>
+          </view>
+          <view class="status">{{info.status=='0'?'未开始':info.status=='1'?'进行中':'已结束'}}</view>
+        </view>
+        <view class="one_1_1">
+          <image src="{{info.red_logo[0].url}}"></image>
+          <view class="textOver">{{info.red_name}}</view>
+        </view>
+      </view>
+      <view class="one_2">{{info.match_name}}</view>
+    </view>
+    <view class="two">
+      <view class="two_1">参赛阵容</view>
+      <view class="two_2">
+        <view class="two_2_1">
+          <view class="two_2_1_logo">
+            <image src="{{info.blue_logo[0].url}}"></image>
+            <view class="bname">{{info.blue_name}}</view>
+          </view>
+          <view class="two_2_1_members">
+            <view class="list" wx:for="{{info.blue_members}}" wx:key="item">
+              <image class="img" src="{{item.icon[0].url}}"></image>
+              <view class="nickname">{{item.nickname}}</view>
+            </view>
+          </view>
+        </view>
+        <view class="two_2_1 two_2_2">
+          <view class="two_2_1_logo">
+            <image src="{{info.red_logo[0].url}}"></image>
+            <view class="bname">{{info.red_name}}</view>
+          </view>
+          <view class="two_2_1_members">
+            <view class="list" wx:for="{{info.red_members}}" wx:key="item">
+              <image class="img" src="{{item.icon[0].url}}"></image>
+              <view class="nickname">{{item.nickname}}</view>
+            </view>
+          </view>
+        </view>
+      </view>
+    </view>
+    <view class="thr">
+      <view class="thr_1">现场图片</view>
+      <view class="thr_2">
+        <upload list="{{match_file}}" count="{{4}}" previewSize="{{170}}" bind:imgUpload="imgUpload" bind:imgDel="imgDel"></upload>
+      </view>
+    </view>
   </view>
 </mobile-main>

+ 379 - 0
pages/match/schedule.wxss

@@ -1,4 +1,383 @@
 .main {
     position: relative;
     width: 100%;
+}
+
+.main .one {
+    float: left;
+    width: 100%;
+    background-color: #fff;
+    margin: 0 0 10px 0;
+}
+
+.main .one .one_1 {
+    float: left;
+    width: 100%;
+}
+
+.main .one .one_1 .one_1_1 {
+    float: left;
+    width: 30%;
+    text-align: center;
+}
+
+.main .one .one_1 .one_1_2 {
+    width: 40%;
+}
+
+.main .one .one_1 .one_1_2 .time {
+    float: left;
+    width: 100%;
+    font-size: 14px;
+    text-align: center;
+    margin: 0 0 8px 0;
+}
+
+.main .one .one_1 .one_1_2 .branch {
+    float: left;
+    width: 100%;
+    text-align: center;
+    margin: 0 0 8px 0;
+}
+
+.main .one .one_1 .one_1_2 .branch text {
+    font-size: 25px;
+    padding: 0 5px;
+}
+
+.main .one .one_1 .one_1_2 .branch text:nth-child(1) {
+    color: #0000ff;
+    font-weight: bold;
+    background-color: #f1f1f1;
+}
+
+.main .one .one_1 .one_1_2 .branch text:nth-child(3) {
+    color: #ff0000;
+    font-weight: bold;
+    background-color: #f1f1f1;
+}
+
+.main .one .one_1 .one_1_1 image {
+    width: 60px;
+    height: 60px;
+    overflow: hidden;
+    border-radius: 90px;
+}
+
+.main .one .one_1 .one_1_1 view {
+    font-size: 14px;
+
+}
+
+.main .one .one_2 {
+    float: left;
+    width: 100%;
+    text-align: center;
+    color: #666;
+    padding: 10px 0;
+}
+
+.main .two {
+    float: left;
+    width: 95%;
+    background-color: #fff;
+    margin: 0 0 10px 0;
+    padding: 10px;
+}
+
+.main .two .two_1 {
+    float: left;
+    width: 100%;
+    font-size: 16px;
+    font-weight: bold;
+    margin: 0 0 8px 0;
+}
+
+.main .two .two_2 {
+    float: left;
+    width: 100%;
+}
+
+.main .two .two_2 .two_2_1 {
+    float: left;
+    width: 100%;
+    padding: 0 0 8px 0;
+    margin: 0 0 8px 0;
+    border-bottom: 1px solid #ccc;
+}
+
+.main .two .two_2 .two_2_1 .two_2_1_logo {
+    float: left;
+    width: 18%;
+    text-align: center;
+    margin: 0 10px 0 0;
+}
+
+.main .two .two_2 .two_2_1 .two_2_1_logo image {
+    width: 50px;
+    height: 50px;
+    border-radius: 90px;
+}
+
+.main .two .two_2 .two_2_1 .two_2_1_logo .bname {
+    font-size: 12px;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    -webkit-line-clamp: 2;
+    word-break: break-all;
+    display: -webkit-box;
+    -webkit-box-orient: vertical;
+}
+
+.main .two .two_2 .two_2_1 .two_2_1_members {
+    float: left;
+    width: 70%;
+}
+
+.main .two .two_2 .two_2_1 .two_2_1_members .list {
+    float: left;
+    width: 25%;
+    text-align: center;
+}
+
+.main .two .two_2 .two_2_1 .two_2_1_members .list image {
+    width: 40px;
+    height: 40px;
+    border-radius: 90px;
+}
+
+.main .two .two_2 .two_2_1 .two_2_1_members .list .nickname {
+    font-size: 12px;
+}
+
+.main .two .two_2 .two_2_2 {
+    float: left;
+    width: 100%;
+    padding: 0 0 8px 0;
+    border-bottom: none;
+}
+
+.main .thr {
+    float: left;
+    width: 95%;
+    padding: 10px;
+    background-color: #fff;
+    margin: 0 0 10px 0;
+}
+
+.main .thr .thr_1 {
+    float: left;
+    width: 100%;
+    font-size: 16px;
+    font-weight: bold;
+    margin: 0 0 8px 0;
+}
+
+.main .thr .thr_2 {
+    float: left;
+    width: 100%;
+}
+
+.main .four {
+    float: left;
+    width: 95%;
+    background-color: #fff;
+    padding: 10px;
+    text-align: center;
+}
+
+.main .four button {
+    width: 50%;
+    padding: 5px 0;
+    background-color: rgb(247, 89, 16);
+    background-image: linear-gradient(to right, rgb(245, 122, 65), rgb(247, 89, 41));
+    border-radius: 30px;
+    color: #ffffff;
+    font-size: 13px;
+}
+
+.mask {
+    width: 100%;
+    height: 100%;
+    position: fixed;
+    top: 0;
+    left: 0;
+    background: #000;
+    opacity: 0.2;
+    overflow: hidden;
+    z-index: 1000;
+    color: #fff;
+}
+
+/*对话框 */
+.modal {
+    height: 400px;
+    width: 100%;
+    overflow: hidden;
+    position: fixed;
+    border-radius: 30px 30px 0px 0px;
+    bottom: 0;
+    left: 0;
+    z-index: 2000;
+    background: #fff;
+    padding-top: 20rpx;
+}
+
+.title {
+    width: 100%;
+    padding: 20px;
+}
+
+.modal_title {
+    width: 40%;
+    float: left;
+    font-size: 18px;
+}
+
+.go {
+    width: 50%;
+    float: left;
+    text-align: right;
+}
+
+.cuo {
+    width: 20px;
+    height: 20px;
+}
+
+.modal_main {
+    padding: 20px;
+}
+
+.modal_l {
+    width: 30%;
+    float: left;
+}
+
+.modal_r {
+    width: 60%;
+    float: left;
+}
+
+.modal_l1 {
+    margin: 30px 0;
+}
+
+.modal_l2 {
+    margin: 30px 0;
+}
+
+.modal_r1 {
+    height: 60px;
+    padding: 0 0 0 0;
+    margin: 40px 20px;
+}
+
+.modal_r2 {
+    height: 60px;
+    padding: 0 0 0 0;
+    margin: 40px 20px;
+}
+
+.modal_text {
+    font-size: 16px;
+    float: left;
+}
+
+.input {
+    width: 50px;
+    float: left;
+    text-align: center;
+    border-bottom: 1px solid rgb(228, 228, 228);
+}
+
+.button {
+    width: 300px !important;
+    background-color: #ff7815;
+    border-radius: 30px;
+    color: #ffffff;
+    text-align: center;
+}
+
+.two_logo1 {
+    margin-left: 15%;
+    align-items: center;
+    width: 50px;
+    height: 45px;
+}
+
+.two_logo2 {
+    margin-left: 15%;
+    align-items: center;
+    width: 45px;
+    height: 45px;
+    border: solid 1px #999;
+}
+
+.van-dialog__footer {
+    display: none !important;
+}
+
+.dialog {
+    float: left;
+    width: 95%;
+    padding: 10px;
+    max-height: 300px;
+    overflow-y: auto;
+}
+
+.dialog .content {
+    float: left;
+    width: 100%;
+    border-bottom: 1px solid #f1f1f1;
+    padding: 5px 0;
+}
+
+.dialog .content .label {
+    float: left;
+    width: 25%;
+    text-align: center;
+}
+
+.dialog .content .label image {
+    width: 50px;
+    height: 50px;
+    overflow: hidden;
+    border-radius: 90px;
+}
+
+.dialog .content .label view {
+    font-size: 14px;
+}
+
+.dialog .content .value {
+    float: left;
+    width: 75%;
+    padding: 20px 0;
+}
+
+.dialog .content .value text {
+    float: left;
+    font-size: 14px;
+    margin: 0 5px 0 0;
+}
+
+.dialog .content .value input {
+    float: left;
+    width: 25%;
+    border-bottom: 1px solid #ccc;
+    font-size: 14px;
+    text-align: center;
+}
+
+.dialog .btn {
+    float: left;
+    width: 100%;
+    text-align: center;
+    margin: 10px 0;
+}
+
+.dialog .btn button {
+    width: 40%;
+    margin: 0 10px;
 }

+ 11 - 18
pages/me/index.js

@@ -23,6 +23,8 @@ Page({
         // 弹框
         dialog: { title: '上传比分', show: false, type: '1' },
         form: {},
+        // 上传比分
+        scoreList: []
 
     },
     initValidate() {
@@ -36,21 +38,19 @@ Page({
         if (route) wx.redirectTo({ url: `/${route}` })
     },
     // 上传比分
-    toScore: function () {
+    toScore: async function () {
         const that = this;
+        const arr = await app.$get(`/courtAdmin/api/schedule/getByTeamCreater`, { user_id: that.data.userInfo._id, status: '1' });
+        if (arr.errcode == '0') that.setData({ scoreList: arr.data })
         that.setData({ dialog: { title: '上传比分', show: true, type: '1' } })
     },
     // 选择比赛
     ismatchChange: function (e) {
         const that = this;
-        const list = that.data.ismatchList;
+        const list = that.data.scoreList;
         const { value } = e.detail;
         const data = list[value];
-        if (data) {
-            that.setData({ 'form._id': data._id })
-            that.setData({ 'form.red_name': data.red_name })
-            that.setData({ 'form.blue_name': data.blue_name })
-        }
+        if (data) that.setData({ form: data })
     },
     // 提交上传比分
     async onSubmit(e) {
@@ -108,8 +108,8 @@ Page({
         this.initValidate();
         // 计算高度
         this.searchHeight();
-        // // 监听用户是否登录
-        // this.watchLogin();
+        // 监听用户是否登录
+        this.watchLogin();
     },
     // 监听用户是否登录
     watchLogin: function () {
@@ -139,15 +139,8 @@ Page({
                             that.setData({ userInfo: user })
                         } else { wx.showToast({ title: `${err.errmsg}`, icon: 'error', duration: 2000 }) }
                         // 查询正在比赛的赛事
-                        let ismatchList = [];
-                        // 红方
-                        arr = await app.$get(`/courtAdmin/api/schedule`, { red_id: team[0]._id });
-                        // arr = await app.$get(`/courtAdmin/api/schedule`, { red_id: team[0]._id });
-                        // if (arr.errcode == '0') ismatchList.push(...arr.data);
-                        // // 蓝方
-                        // arr = await app.$get(`/courtAdmin/api/schedule`, { blue_id: team[0]._id });
-                        // if (arr.errcode == '0') ismatchList.push(...arr.data);
-                        // that.setData({ ismatchList: ismatchList })
+                        arr = await app.$get(`/courtAdmin/api/schedule/getByTeamCreater`, { user_id: res.data._id });
+                        if (arr.errcode == '0') that.setData({ ismatchList: arr.data })
                     } else if (user.type == '2') {
                         arr = await app.$get(`/courtAdmin/api/team/userteams`, { user_id: user._id });
                         if (arr.errcode == '0') {

+ 1 - 1
pages/me/index.wxml

@@ -97,7 +97,7 @@
                 <view class="content">
                     <view class="label textOver">比赛</view>
                     <view class="value">
-                        <picker mode="selector" bindchange="ismatchChange" name="_id" value="{{form._id}}" range-key="{{'red_name'}}" range="{{ismatchList}}">
+                        <picker mode="selector" bindchange="ismatchChange" name="_id" value="{{form._id}}" range-key="{{'red_name'}}" range="{{scoreList}}">
                             <view class="input">{{form.red_name||"红方团队"}}--{{form.blue_name||'蓝方团队'}}</view>
                         </picker>
                     </view>