Explorar el Código

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

lrf hace 2 años
padre
commit
951e3df469

+ 5 - 0
pages/usermysign/index.js

@@ -41,6 +41,11 @@ Page({
             that.setData({ dialog: { title: '详细信息', show: true, type: '1' } })
         }
     },
+    // 组队申请
+    toTeam: function (e) {
+        const { item } = e.currentTarget.dataset;
+        wx.navigateTo({ url: `/pages/usermyteam/add?id=${item._id}` })
+    },
     // 关闭弹框
     toClose: function () {
         const that = this;

+ 111 - 5
pages/usermyteam/add.js

@@ -1,23 +1,129 @@
 const app = getApp()
+import WxValidate from '../../utils/wxValidate'
+const moment = require("../../utils/moment.min")
 Page({
 
     /**
      * 页面的初始数据
      */
     data: {
-        frameStyle: { useTop: true, name: '话题', leftArrow: false, useBar: true },
+        frameStyle: { useTop: true, name: '组队申请', leftArrow: true, useBar: false },
+        searchInfo: {},
+        form: {},
+        teammateList: [],
+        id: '',
+        // 用户信息
+        userinfo: {}
+    },
+    initValidate() {
+        const rules = { teammate_id: { required: true }, teammate_name: { required: true } }
+        // 验证字段的提示信息,若不传则调用默认的信息
+        const messages = { teammate_id: { required: '请输入组队用户', }, teammate_name: { required: '请输入组队用户姓名', } };
+        this.WxValidate = new WxValidate(rules, messages)
     },
     // 跳转菜单
-    tabPath(e) {
-        let { route } = e.detail.detail;
-        if (route) wx.redirectTo({ url: `/${route}` })
+    back(e) {
+        wx.navigateBack({ delta: 1 })
+    },
+    // 查询
+    toSearch: function (e) {
+        const that = this;
+        that.setData({ 'searchInfo.name': e.detail.value });
+        that.watchLogin()
+    },
+    // 选择组队用户
+    toChoose: function (e) {
+        const that = this;
+        const { item } = e.currentTarget.dataset;
+        let form = { teammate_id: item._id, teammate_name: item.name }
+        wx.showModal({
+            title: '',
+            content: '是否确认选择',
+            success(res) {
+                if (res.confirm) {
+                    that.onSubmit(form)
+                } else if (res.cancel) {
+                    that.setData({ form: {} });
+                }
+            }
+        });
+    },
+    // 提交登录
+    onSubmit: async function (e) {
+        const that = this;
+        const params = e;
+        const data = that.data.form;
+        params.match_id = data.match_id;
+        params.grouping_id = data.grouping_id;
+        params.project_id = data.project_id;
+        params.applyuser_id = that.data.userinfo.openid;
+        params.applyuser_name = that.data.userinfo.name;
+        params.apply_time = moment().format('YYYY-MM-DD HH:mm:ss');
+        if (!this.WxValidate.checkForm(params)) {
+            const error = this.WxValidate.errorList[0];
+            wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
+            return false
+        } else {
+            let arr;
+            arr = await app.$post(`/newCourt/api/teamApply`, params);
+            if (arr.errcode == '0') { wx.showToast({ title: `添加信息完成`, icon: 'success', duration: 2000 }); that.back(); }
+            else wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
+        }
     },
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
         const that = this;
-
+        if (options && options.id) that.setData({ id: options.id })
+        //验证规则函数
+        that.initValidate();
+        // 监听用户是否登录
+        that.watchLogin();
+    },
+    // 监听用户是否登录
+    watchLogin: async function () {
+        const that = this;
+        let searchInfo = that.data.searchInfo;
+        wx.getStorage({
+            key: 'user',
+            success: async res => {
+                const arr = await app.$get(`/newCourt/api/enroll/${that.data.id}`);
+                if (arr.errcode == '0') {
+                    that.setData({ form: arr.data });
+                    that.setData({ userinfo: res.data });
+                }
+                let info = {};
+                if (searchInfo && searchInfo.name) {
+                    info.name = searchInfo.name;
+                    info.match_id = that.data.form.match_id;
+                    info.grouping_id = that.data.form.grouping_id;
+                    info.project_id = that.data.form.project_id;
+                    const team = await app.$get(`/newCourt/api/enroll/findTeamMeta`, { ...info });
+                    if (team.errcode == '0') {
+                        that.setData({ teammateList: team.data })
+                    } else {
+                        wx.showToast({ title: `${team.errMsg}`, icon: 'fail', duration: 2000 });
+                    }
+                } else {
+                    let info = {};
+                    info.match_id = that.data.form.match_id;
+                    info.grouping_id = that.data.form.grouping_id;
+                    info.project_id = that.data.form.project_id;
+                    info.openid = that.data.userinfo.openid;
+                    const team = await app.$get(`/newCourt/api/enroll/findTeamMeta`, { ...info });
+                    if (team.errcode == '0') {
+                        for (const val of team.data) {
+                            val.card = val.card.substr(0, 4) + "*".repeat(val.card.length - 8) + val.card.substr(-4);
+                        }
+                        that.setData({ teammateList: team.data })
+                    }
+                }
+            },
+            fail: res => {
+                wx.redirectTo({ url: '/pages/index/index', })
+            }
+        })
     },
     /**
      * 生命周期函数--监听页面初次渲染完成

+ 95 - 2
pages/usermyteam/add.less

@@ -1,4 +1,97 @@
 .main {
-    height: 80.8vh;
-    background-color: #ff0000;
+    height: 88vh;
+    background: #ffffff;
+
+    .zero {
+        width: 96vw;
+        margin: 0 0 2vw 0;
+    }
+
+    .zero:nth-child(2) {
+        margin: 0;
+    }
+
+    .one {
+        width: 92vw;
+        padding: 2vw;
+        background-color: #f1f1f1;
+
+        input {
+            font-size: 14px;
+        }
+    }
+
+    .two {
+        flex-grow: 1;
+        width: 100%;
+        position: relative;
+
+        .scroll-view {
+            position: absolute;
+            top: 0;
+            left: 0;
+            right: 0;
+            bottom: 0;
+
+            .list-scroll-view {
+                display: flex;
+                flex-direction: column;
+
+                .list {
+                    border-bottom: 1px solid #cccccc;
+                    padding: 2vw 0;
+                    display: flex;
+                    flex-direction: row;
+                    justify-content: space-between;
+
+                    .list_1 {
+                        .image {
+                            width: 60px;
+                            height: 60px;
+                            border-radius: 60px;
+                        }
+                    }
+
+                    .list_2 {
+                        display: flex;
+                        flex-direction: column;
+                        width: 80vw;
+                        padding: 0 0 0 2vw;
+
+                        .name {
+                            font-size: 16px;
+                            font-weight: bold;
+                            margin: 0 0 1vw 0;
+                            overflow: hidden;
+                            text-overflow: ellipsis;
+                            -webkit-line-clamp: 2;
+                            word-break: break-all;
+                            display: -webkit-box;
+                            -webkit-box-orient: vertical;
+
+                            .status {
+                                background-color: #ff0000;
+                                color: #fff;
+                                padding: 0 2vw;
+                                font-size: 14px;
+                            }
+                        }
+
+
+                        .other_1 {
+                            margin: 0 0 1vw 0;
+                            color: #000000a6;
+                            font-size: 12px;
+                            overflow: hidden;
+                            text-overflow: ellipsis;
+                            -webkit-line-clamp: 2;
+                            word-break: break-all;
+                            display: -webkit-box;
+                            -webkit-box-orient: vertical;
+                        }
+                    }
+                }
+            }
+        }
+    }
 }

+ 28 - 2
pages/usermyteam/add.wxml

@@ -1,5 +1,31 @@
-<mobile-main frameStyle="{{frameStyle}}" bind:back="back" bind:tabPath="tabPath">
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
     <view slot="info" class="container main">
-        话题
+        <view class="zero one">
+            <input type="text" value="{{searchInfo.name}}" bindconfirm="toSearch" placeholder="请输入组队用户名称" />
+        </view>
+        <view class="zero two">
+            <scroll-view scroll-y="true" class="scroll-view">
+                <view class="list-scroll-view">
+                    <view class="list" wx:for="{{teammateList}}" wx:key="item" bindtap="toChoose" data-item="{{item}}">
+                        <view class="list_1">
+                            <image class="image" src="{{item.icon&&item.icon.length>0?item.icon[0].url:''}}"></image>
+                        </view>
+                        <view class="list_2">
+                            <view class="name">
+                                <text>{{item.name}}</text>
+                            </view>
+                            <view class="other_1">
+                                <text>身份证号:</text>
+                                <text>{{item.card||'暂无'}}</text>
+                            </view>
+                            <view class="other_1">
+                                <text>电话号:</text>
+                                <text>{{item.phone||'暂无'}}</text>
+                            </view>
+                        </view>
+                    </view>
+                </view>
+            </scroll-view>
+        </view>
     </view>
 </mobile-main>

+ 78 - 1
pages/usermyteam/add.wxss

@@ -1,4 +1,81 @@
 .main {
-  height: 80.8vh;
+  height: 88vh;
+  background: #ffffff;
+}
+.main .zero {
+  width: 96vw;
+  margin: 0 0 2vw 0;
+}
+.main .zero:nth-child(2) {
+  margin: 0;
+}
+.main .one {
+  width: 92vw;
+  padding: 2vw;
+  background-color: #f1f1f1;
+}
+.main .one input {
+  font-size: 14px;
+}
+.main .two {
+  flex-grow: 1;
+  width: 100%;
+  position: relative;
+}
+.main .two .scroll-view {
+  position: absolute;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+}
+.main .two .scroll-view .list-scroll-view {
+  display: flex;
+  flex-direction: column;
+}
+.main .two .scroll-view .list-scroll-view .list {
+  border-bottom: 1px solid #cccccc;
+  padding: 2vw 0;
+  display: flex;
+  flex-direction: row;
+  justify-content: space-between;
+}
+.main .two .scroll-view .list-scroll-view .list .list_1 .image {
+  width: 60px;
+  height: 60px;
+  border-radius: 60px;
+}
+.main .two .scroll-view .list-scroll-view .list .list_2 {
+  display: flex;
+  flex-direction: column;
+  width: 80vw;
+  padding: 0 0 0 2vw;
+}
+.main .two .scroll-view .list-scroll-view .list .list_2 .name {
+  font-size: 16px;
+  font-weight: bold;
+  margin: 0 0 1vw 0;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  -webkit-line-clamp: 2;
+  word-break: break-all;
+  display: -webkit-box;
+  -webkit-box-orient: vertical;
+}
+.main .two .scroll-view .list-scroll-view .list .list_2 .name .status {
   background-color: #ff0000;
+  color: #fff;
+  padding: 0 2vw;
+  font-size: 14px;
+}
+.main .two .scroll-view .list-scroll-view .list .list_2 .other_1 {
+  margin: 0 0 1vw 0;
+  color: #000000a6;
+  font-size: 12px;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  -webkit-line-clamp: 2;
+  word-break: break-all;
+  display: -webkit-box;
+  -webkit-box-orient: vertical;
 }