zs 1 year ago
parent
commit
8062b99b66

+ 4 - 0
app.wxss

@@ -25,4 +25,8 @@ page {
     --rgb3AB: #3ABDB8;
     --rgb8b8: #8b8b8b;
     --rgbD8D: #D8D8D8;
+    --rgb67c: #67c23a;
+    --rgbffd: #FFD700;
+    --rgbff0: #ff0000;
+    --rgb46a: #46aedf;
 }

+ 1 - 1
pagesCommon/login/index.js

@@ -23,13 +23,13 @@ Page({
     },
     // 提交登录
     onSubmit: async function (e) {
+        const that = this;
         const params = e.detail.value;
         if (!this.WxValidate.checkForm(params)) {
             const error = this.WxValidate.errorList[0];
             wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
             return false
         } else {
-            params.openid = that.data.form.openid
             const res = await app.$api('user/login', 'POST', params);
             if (res.errcode === 0) {
                 app.globalData.userInfo = res.data;//存用户信息到app.js

+ 74 - 5
pagesHome/home/index.js

@@ -1,7 +1,13 @@
 const app = getApp()
 Page({
     data: {
-        info: {}
+        searchInfo: {},
+        list: [],
+        total: 0,
+        page: 0,
+        skip: 0,
+        limit: 5,
+        statusList: []
     },
     toPath(e) {
         let data = e.detail;
@@ -11,21 +17,84 @@ Page({
         else if (data.type == '2') wx.relaunch({ url })
         else if (data.type == '3') wx.switchTab({ url })
     },
-
+    // 查询
+    async toSearch(e) {
+        const that = this;
+        that.setData({ 'searchInfo.name': e.detail.value })
+        that.clearPage();
+        that.search()
+    },
     /**
      * 生命周期函数--监听页面加载
      */
-    onLoad(options) {
+    async onLoad(options) {
         const that = this;
         wx.showLoading({ title: '加载中', mask: true })
-        that.search()
+        await that.searchOther()
+        await that.search()
         wx.hideLoading()
     },
     // 查询通知
     async search() {
         const that = this;
+        let info = { skip: that.data.skip, limit: that.data.limit, status: '2' };
+        let res = await app.$api('match', 'GET', { ...info, ...that.data.searchInfo })
+        if (res.errcode == '0') {
+            let list = [...that.data.list, ...res.data]
+            for (const val of list) {
+                val.status_name = that.getDict(val.status, 'status')
+            }
+            that.setData({ list })
+            that.setData({ total: res.total })
+        }
+    },
+    // 分页-触底
+    toLower() {
+        const that = this;
+        let list = that.data.list;
+        let limit = that.data.limit;
+        if (that.data.total > list.length) {
+            wx.showLoading({ title: '加载中', mask: true })
+            let page = that.data.page + 1;
+            that.setData({ page })
+            let skip = page * limit
+            that.setData({ skip })
+            that.search()
+            wx.hideLoading()
+        } else {
+            wx.showToast({ title: `到底了没数据了`, icon: 'none' });
+        }
+    },
+    // 分页-滚动
+    toScroll() {
+        // console.log('滚动');
+    },
+    // 字典
+    getDict(value, model) {
+        const that = this;
+        if (model == 'status') {
+            if (value) {
+                let data = that.data.statusList.find(i => i.value == value)
+                if (data) return data.label
+                else return '暂无'
+            }
+        }
+    },
+    // 查询其他信息
+    async searchOther() {
+        const that = this;
+        let res;
+        res = await app.$api('dictData', 'GET', { type: 'match_status', is_use: '0' })
+        if (res.errcode == '0') that.setData({ statusList: res.data })
+    },
+    // 清空列表
+    clearPage() {
+        const that = this;
+        that.setData({ list: [] })
+        that.setData({ skip: 0 })
+        that.setData({ limit: 5 })
+        that.setData({ total: 0 })
     },
-
     /**
      * 生命周期函数--监听页面初次渲染完成
      */

+ 27 - 1
pagesHome/home/index.wxml

@@ -1,5 +1,31 @@
 <home-frame bind:toPath="toPath">
     <view class="main">
-       首页
+        <view class="one">
+            <input class="input" type="text" bindconfirm="toSearch" confirm-type="search" placeholder-style='text-align:center' placeholder="搜索" />
+        </view>
+        <view class="two">
+            <scroll-view class="scroll-view" scroll-y="true" bindscrolltolower="toLower" bindscroll="toScroll">
+                <view class="list" wx:for="{{list}}" wx:key="index" wx:for-item="item">
+                    <view class="list_1">
+                        <view class="name textOver"> {{item.name||"暂无比赛名称"}} </view>
+                        <view class="color{{item.status}}"> {{item.status_name||'暂无状态'}} </view>
+                    </view>
+                    <view class="other">
+                        <view class="other_1">
+                            开始时间:{{item.start_time||'暂无开始时间'}}
+                        </view>
+                        <view class="other_1">
+                            结束时间:{{item.end_time||'暂无结束时间'}}
+                        </view>
+                        <view class="other_1">
+                            报名截止时间:{{item.sign_deadline||'暂无报名截止时间'}}
+                        </view>
+                        <view class="other_1 textOver">
+                            比赛地点:{{item.address||'暂无比赛地点'}}
+                        </view>
+                    </view>
+                </view>
+            </scroll-view>
+        </view>
     </view>
 </home-frame>

+ 58 - 1
pagesHome/home/index.wxss

@@ -1,3 +1,60 @@
+@import "../../app.wxss";
+
 .main {
-    padding: 1vw;
+    padding: 2vw;
+}
+
+.main .one {
+    padding: 2vw 0;
+}
+
+.main .one .input {
+    border: 1px solid var(--rgb8b8);
+    padding: 5rpx;
+    border-radius: 25rpx;
+}
+
+.main .two .scroll-view {
+    height: 82vh;
+}
+
+.main .two .list {
+    margin: 0 0 2vw 0;
+    padding: 2vw;
+    border-radius: 5px;
+    border: 1px solid var(--rgb40E);
+}
+
+.main .two .list .list_1 {
+    display: flex;
+    justify-content: space-between;
+    margin: 0 0 1vw 0;
+
+}
+
+.main .two .list .list_1 .name {
+    font-size: 18px;
+    font-weight: bold;
+}
+
+.main .two .list .list_1 .color0 {
+    color: var(--rgb67c)
+}
+
+.main .two .list .list_1 .color1 {
+    color: var(--rgbff0)
+}
+
+.main .two .list .list_1 .color2 {
+    color: var(--rgb46a)
+}
+
+.main .two .list .list_1 .color-1 {
+    color: var(--rgb8b8)
+}
+
+.main .two .list .other .other_1 {
+    margin: 0 0 1vw 0;
+    font-size: 14px;
+    color: #868686;
 }

+ 74 - 5
pagesMatch/home/index.js

@@ -1,7 +1,13 @@
 const app = getApp()
 Page({
     data: {
-        info: {}
+        searchInfo: {},
+        list: [],
+        total: 0,
+        page: 0,
+        skip: 0,
+        limit: 5,
+        statusList: []
     },
     toPath(e) {
         let data = e.detail;
@@ -11,21 +17,84 @@ Page({
         else if (data.type == '2') wx.relaunch({ url })
         else if (data.type == '3') wx.switchTab({ url })
     },
-
+    // 查询
+    async toSearch(e) {
+        const that = this;
+        that.setData({ 'searchInfo.name': e.detail.value })
+        that.clearPage();
+        that.search()
+    },
     /**
      * 生命周期函数--监听页面加载
      */
-    onLoad(options) {
+    async onLoad(options) {
         const that = this;
         wx.showLoading({ title: '加载中', mask: true })
-        that.search()
+        await that.searchOther()
+        await that.search()
         wx.hideLoading()
     },
     // 查询通知
     async search() {
         const that = this;
+        let info = { skip: that.data.skip, limit: that.data.limit };
+        let res = await app.$api('match', 'GET', { ...info, ...that.data.searchInfo })
+        if (res.errcode == '0') {
+            let list = [...that.data.list, ...res.data]
+            for (const val of list) {
+                val.status_name = that.getDict(val.status, 'status')
+            }
+            that.setData({ list })
+            that.setData({ total: res.total })
+        }
+    },
+    // 分页-触底
+    toLower() {
+        const that = this;
+        let list = that.data.list;
+        let limit = that.data.limit;
+        if (that.data.total > list.length) {
+            wx.showLoading({ title: '加载中', mask: true })
+            let page = that.data.page + 1;
+            that.setData({ page })
+            let skip = page * limit
+            that.setData({ skip })
+            that.search()
+            wx.hideLoading()
+        } else {
+            wx.showToast({ title: `到底了没数据了`, icon: 'none' });
+        }
+    },
+    // 分页-滚动
+    toScroll() {
+        // console.log('滚动');
+    },
+    // 字典
+    getDict(value, model) {
+        const that = this;
+        if (model == 'status') {
+            if (value) {
+                let data = that.data.statusList.find(i => i.value == value)
+                if (data) return data.label
+                else return '暂无'
+            }
+        }
+    },
+    // 查询其他信息
+    async searchOther() {
+        const that = this;
+        let res;
+        res = await app.$api('dictData', 'GET', { type: 'match_status', is_use: '0' })
+        if (res.errcode == '0') that.setData({ statusList: res.data })
+    },
+    // 清空列表
+    clearPage() {
+        const that = this;
+        that.setData({ list: [] })
+        that.setData({ skip: 0 })
+        that.setData({ limit: 5 })
+        that.setData({ total: 0 })
     },
-
     /**
      * 生命周期函数--监听页面初次渲染完成
      */

+ 27 - 1
pagesMatch/home/index.wxml

@@ -1,5 +1,31 @@
 <home-frame bind:toPath="toPath">
     <view class="main">
-        比赛
+        <view class="one">
+            <input class="input" type="text" bindconfirm="toSearch" confirm-type="search" placeholder-style='text-align:center' placeholder="搜索" />
+        </view>
+        <view class="two">
+            <scroll-view class="scroll-view" scroll-y="true" bindscrolltolower="toLower" bindscroll="toScroll">
+                <view class="list" wx:for="{{list}}" wx:key="index" wx:for-item="item">
+                    <view class="list_1">
+                        <view class="name textOver"> {{item.name||"暂无比赛名称"}} </view>
+                        <view class="color{{item.status}}"> {{item.status_name||'暂无状态'}} </view>
+                    </view>
+                    <view class="other">
+                        <view class="other_1">
+                            开始时间:{{item.start_time||'暂无开始时间'}}
+                        </view>
+                        <view class="other_1">
+                            结束时间:{{item.end_time||'暂无结束时间'}}
+                        </view>
+                        <view class="other_1">
+                            报名截止时间:{{item.sign_deadline||'暂无报名截止时间'}}
+                        </view>
+                        <view class="other_1 textOver">
+                            比赛地点:{{item.address||'暂无比赛地点'}}
+                        </view>
+                    </view>
+                </view>
+            </scroll-view>
+        </view>
     </view>
 </home-frame>

+ 58 - 1
pagesMatch/home/index.wxss

@@ -1,3 +1,60 @@
+@import "../../app.wxss";
+
 .main {
-    padding: 1vw;
+    padding: 2vw;
+}
+
+.main .one {
+    padding: 2vw 0;
+}
+
+.main .one .input {
+    border: 1px solid var(--rgb8b8);
+    padding: 5rpx;
+    border-radius: 25rpx;
+}
+
+.main .two .scroll-view {
+    height: 82vh;
+}
+
+.main .two .list {
+    margin: 0 0 2vw 0;
+    padding: 2vw;
+    border-radius: 5px;
+    border: 1px solid var(--rgb40E);
+}
+
+.main .two .list .list_1 {
+    display: flex;
+    justify-content: space-between;
+    margin: 0 0 1vw 0;
+
+}
+
+.main .two .list .list_1 .name {
+    font-size: 18px;
+    font-weight: bold;
+}
+
+.main .two .list .list_1 .color0 {
+    color: var(--rgb67c)
+}
+
+.main .two .list .list_1 .color1 {
+    color: var(--rgbff0)
+}
+
+.main .two .list .list_1 .color2 {
+    color: var(--rgb46a)
+}
+
+.main .two .list .list_1 .color-1 {
+    color: var(--rgb8b8)
+}
+
+.main .two .list .other .other_1 {
+    margin: 0 0 1vw 0;
+    font-size: 14px;
+    color: #868686;
 }

+ 11 - 15
pagesMy/basic/index.js

@@ -44,8 +44,6 @@ Page({
                         if (form.gender) form.gender_name = that.getDict(form.gender, 'gender')
                         // 工作状态
                         if (form.type) form.type_name = that.getDict(form.type, 'type')
-                    } else {
-                        form.status = '0';
                     }
                 } else {
                     wx.showToast({ title: `${aee.errmsg}`, icon: 'error' });
@@ -80,9 +78,7 @@ Page({
     // 选择类别
     typeChange(e) {
         const that = this;
-        // 所取数据
         const index = e.detail.value;
-        // 选择项
         let data = that.data.typeList[index];
         if (data) {
             that.setData({ 'form.type': data.value })
@@ -98,17 +94,17 @@ Page({
             wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
             return false
         } else {
-           // 判断id使用
-           let form = that.data.form;
-           let res;
-           if (form._id) res = await app.$api(`user/${form._id}`, 'POST', parmas);
-           else res = await app.$api('user', 'POST', parmas);
-           if (res.errcode == '0') {
-               wx.showToast({ title: `信息提交成功`, icon: 'success' });
-               that.search()
-           } else {
-               wx.showToast({ title: `${res.errmsg}`, icon: 'none' });
-           }
+            // 判断id使用
+            let form = that.data.form;
+            let res;
+            if (form._id) res = await app.$api(`user/${form._id}`, 'POST', parmas);
+            else res = await app.$api('user', 'POST', parmas);
+            if (res.errcode == '0') {
+                wx.showToast({ title: `信息提交成功`, icon: 'success' });
+                wx.navigateBack({ delta: 1 });
+            } else {
+                wx.showToast({ title: `${res.errmsg}`, icon: 'none' });
+            }
         }
     },
     // 查询其他信息

+ 1 - 1
pagesMy/basic/index.wxml

@@ -43,7 +43,7 @@
                         用户类别:
                     </view>
                     <view class="value">
-                        <picker bindchange="typeChange" value="{{form.type}}" name="type" range="{{typeList}}" range-key='label'>
+                        <picker disabled bindchange="typeChange" value="{{form.type}}" name="type" range="{{typeList}}" range-key='label'>
                             <view class="picker">
                                 {{form.type_name||''}}
                             </view>

+ 2 - 2
pagesMy/home/index.js

@@ -26,6 +26,7 @@ Page({
             if (route) wx.navigateTo({ url: `/${route}` })
         } else {
             wx.showToast({ title: `暂无用户信息,无法查看`, icon: 'none' });
+            wx.navigateTo({ url: '/pagesCommon/login/index' })
         }
     },
     // 获取头像
@@ -91,10 +92,9 @@ Page({
                 } else {
                     wx.showToast({ title: `${arr.errmsg}`, icon: 'error' });
                 }
-
             },
             fail(err) {
-                console.log(err);
+                wx.navigateTo({ url: '/pagesCommon/login/index' })
             }
         })
     },