소스 검색

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

guhongwei 2 년 전
부모
커밋
b27b75b907

+ 2 - 1
app.json

@@ -115,7 +115,8 @@
                 "userAdmin/bill/list",
                 "userAdmin/bill/info",
                 "test/index",
-                "match/info"
+                "match/info",
+                "match/sign"
             ]
         }
     ],

+ 5 - 1
pagesMatch/match/info.js

@@ -27,7 +27,11 @@ Page({
         const that = this;
         that.setData({ 'tabs.active': e.detail.active });
     },
-
+    //比赛报名
+    toSign: function (e) {
+        const { item } = e.currentTarget.dataset;
+        wx.navigateTo({ url: `/pagesMatch/match/sign?id=${item._id}` })
+    },
     /**
      * 生命周期函数--监听页面加载
      */

+ 19 - 0
pagesMatch/match/info.less

@@ -109,4 +109,23 @@
         display: flex;
         flex-direction: column;
     }
+}
+
+.inMatch {
+    position: fixed;
+    width: 96vw;
+    bottom: 8vh;
+    right: 2vw;
+    text-align: right;
+
+    .btn {
+        display: inline-block;
+        width: 10vw;
+        padding: 1vw;
+        text-align: center;
+        background-color: green;
+        color: var(--whiteColor);
+        font-size: var(--font14Size);
+        border-radius: 5px;
+    }
 }

+ 16 - 9
pagesMatch/match/info.wxml

@@ -11,43 +11,50 @@
                             <image class="image" src="{{fileUrl}}/files/court/elimg/20220729140648.png"></image>
                             <view class="a_1_info">
                                 <view class="a_1_1">
-                                    <view class="name">{{info.name}}</view>
-                                    <view class="status"><text>{{info.zhStatus}}</text></view>
+                                    <view class="name">{{info.name||'暂无'}}</view>
+                                    <view class="status"><text>{{info.zhStatus||'暂无'}}</text></view>
                                     <view class="other">
                                         <view class="other_1">
                                             <text>报名截止时间:</text>
-                                            <text>{{info.sign_time}}</text>
+                                            <text>{{info.sign_time||'暂无'}}</text>
                                         </view>
                                         <view class="other_1">
                                             <text>比赛时间:</text>
-                                            <text>{{info.start_time}}-{{info.end_time}}</text>
+                                            <text>{{info.start_time||'暂无'}}-{{info.end_time||'暂无'}}</text>
                                         </view>
                                         <view class="other_1">
                                             <text>比赛地点:</text>
-                                            <text>{{info.address}}</text>
+                                            <text>{{info.address||'暂无'}}</text>
                                         </view>
                                         <view class="other_1">
                                             <text>报名费用说明:</text>
-                                            <text>{{info.money_remark}}</text>
+                                            <text>{{info.money_remark||'暂无'}}</text>
                                         </view>
                                         <view class="other_1">
                                             <text>付款方式:</text>
-                                            <text>{{info.money_mode}}</text>
+                                            <text>{{info.money_mode||'暂无'}}</text>
+                                        </view>
+                                        <view class="other_1">
+                                            <text>报名费用(元):</text>
+                                            <text>{{info.money||'暂无'}}</text>
                                         </view>
                                     </view>
                                 </view>
                                 <view class="a_1_1 a_1_2">
                                     <view class="a_1_2t">
                                         <view class="txt">报名说明:</view>
-                                        <view class="cont">{{info.explain}}</view>
+                                        <view class="cont">{{info.explain||'暂无'}}</view>
                                     </view>
                                     <view class="a_1_2t">
                                         <view class="txt">赛事规程:</view>
-                                        <rich-text nodes="{{info.zhRegular}}"></rich-text>
+                                        <rich-text nodes="{{info.zhRegular||'暂无'}}"></rich-text>
                                     </view>
                                 </view>
                             </view>
                         </view>
+                        <view class="inMatch" wx:if="{{user.type=='0'}}">
+                            <text class="btn" bindtap="toSign" data-item="{{info}}">比赛报名</text>
+                        </view>
                     </view>
                 </scroll-view>
             </view>

+ 17 - 0
pagesMatch/match/info.wxss

@@ -87,3 +87,20 @@
   display: flex;
   flex-direction: column;
 }
+.inMatch {
+  position: fixed;
+  width: 96vw;
+  bottom: 8vh;
+  right: 2vw;
+  text-align: right;
+}
+.inMatch .btn {
+  display: inline-block;
+  width: 10vw;
+  padding: 1vw;
+  text-align: center;
+  background-color: green;
+  color: var(--whiteColor);
+  font-size: var(--font14Size);
+  border-radius: 5px;
+}

+ 171 - 0
pagesMatch/match/sign.js

@@ -0,0 +1,171 @@
+const app = getApp();
+import WxValidate from '../../utils/wxValidate';
+const moment = require("../../utils/moment.min");
+Page({
+    data: {
+        frameStyle: { useTop: true, name: '报名', leftArrow: true, useBar: false },
+        id: '',
+        user: {},
+        form: {},
+        // 赛事分组
+        groupList: [],
+        //项目名称
+        projectList: [],
+    },
+    initValidate() {
+        const rules = { group_id: { required: true }, project_id: { required: true }, card: { required: true, idcard: true } }
+        // 验证字段的提示信息,若不传则调用默认的信息
+        const messages = { group_id: { required: '赛事分组' }, project_id: { required: '项目名称' }, card: { required: '身份证' } };
+        this.WxValidate = new WxValidate(rules, messages)
+    },
+    // 返回
+    back: function () { wx.navigateBack({ delta: 1 }) },
+    // 赛事分组
+    groupChange: function (e) {
+        const that = this;
+        let data = that.data.groupList[e.detail.value];
+        if (data) {
+            that.setData({ 'form.group_id': data._id, 'form.group_name': data.name, 'form.group_age': data.age })
+        }
+    },
+    // 项目名称
+    projectChange: function (e) {
+        const that = this;
+        let data = that.data.projectList[e.detail.value];
+        if (data) {
+            that.setData({ 'form.project_id': data._id, 'form.project_name': data.name, 'form.project_age': data.age })
+        }
+    },
+    //提交
+    onSubmit: async function (e) {
+        const that = this;
+        const params = e.detail.value;
+        const form = that.data.form;
+        params.match_id = that.data.id;
+        if (!this.WxValidate.checkForm(params)) {
+            const error = this.WxValidate.errorList[0];
+            wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
+            return false
+        } else {
+            let checkFit = await app.$post(`/matchSign/checkFit`, params, 'race')
+            if (checkFit.errcode == '0') {
+                wx.showModal({
+                    title: '提示',
+                    content: '您确定是否报名缴费?',
+                    async success(res) {
+                        if (res.confirm) {
+                            wx.getStorage({
+                                key: 'raceuser',
+                                success: async (res) => {
+                                    let obj = { openid: res.data.openid, money: form.money, match_id: params.match_id, group_id: params.group_id, project_id: params.project_id, payer_id: params.user_id, time: moment().format('YYYY-MM-DD HH:mm:ss'), desc: '报名' }
+                                    const arr = await app.$post(`/payOrder`, obj, 'race')
+                                    if (arr.errcode == '0') {
+                                        wx.requestPayment({
+                                            "timeStamp": arr.data.wxSign.timestamp,
+                                            "nonceStr": arr.data.wxSign.nonceStr,
+                                            "package": `prepay_id=${arr.data.wxSign.prepay_id}`,
+                                            "signType": arr.data.wxSign.signType,
+                                            "paySign": arr.data.wxSign.paySign,
+                                            "success": async function (res) {
+                                                const pay = await app.$post(`/payOrder/${arr.data.data._id}`, { status: '1' }, 'race');
+                                                if (pay.errcode == '0') { wx.showToast({ title: `报名成功`, icon: 'success', duration: 5000 }); that.back(); }
+                                                else wx.showToast({ title: `${sign.errmsg}`, icon: 'error', duration: 2000 })
+                                            },
+                                            "fail": async function (res) {
+                                                const pay = await app.$delete(`/payOrder/${arr.data.data._id}`, {}, 'race');
+                                                if (pay.errcode == '0') wx.showToast({ title: `报名未成功`, icon: 'error', duration: 2000 })
+                                            },
+                                        })
+                                    }
+                                },
+                                fail: async (res) => {
+                                    wx.redirectTo({ url: '/pages/index/index' });
+                                },
+                            });
+                        } else if (res.cancel) { }
+                    }
+                });
+            } else wx.showToast({ title: `${checkFit.errmsg}`, icon: 'none', duration: 2000 })
+        }
+    },
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: async function (options) {
+        const that = this;
+        that.setData({ id: options.id || '' });
+        //验证规则函数
+        that.initValidate();
+        // 查询其他信息
+        await that.searchOther();
+        // 监听用户是否登录
+        await that.watchLogin();
+    },
+    // 监听用户是否登录
+    watchLogin: async function () {
+        const that = this;
+        wx.getStorage({
+            key: 'raceuser',
+            success: async res => {
+                that.setData({ user: res.data })
+                const arr = await app.$get(`/match/${that.data.id}`, {}, 'race');
+                if (arr.errcode == '0') {
+                    that.setData({ form: arr.data });
+                }
+            },
+            fail: async res => {
+                wx.redirectTo({ url: '/pages/index/index' })
+            }
+        })
+    },
+    // 查询其他信息
+    searchOther: async function () {
+        const that = this;
+        let arr;
+        // 项目
+        arr = await app.$get(`/matchProject`, {}, 'race');
+        if (arr.errcode == '0' && arr.total > 0) that.setData({ projectList: arr.data });
+        // 组别
+        arr = await app.$get(`/matchGroup`, {}, 'race');
+        if (arr.errcode == '0') that.setData({ groupList: arr.data })
+    },
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () { },
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
+    },
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
+
+    }
+})

+ 6 - 0
pagesMatch/match/sign.json

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

+ 34 - 0
pagesMatch/match/sign.less

@@ -0,0 +1,34 @@
+@import (css) "/app.wxss";
+
+.main {
+    background-color: var(--mainColor);
+
+    .one {
+        .content {
+            display: flex;
+            flex-direction: row;
+            border-bottom: 1px dashed var(--f1Color);
+            padding: 2vw 0;
+            margin: 0 2vw 2vw 2vw;
+
+            .value {
+                flex-grow: 1;
+                color: var(--blackColor);
+
+                textarea {
+                    position: static;
+                    width: 72vw;
+                }
+            }
+        }
+
+        .btn {
+            text-align: center;
+            margin: 3vw 0;
+
+            button {
+                margin: 0 2vw;
+            }
+        }
+    }
+}

+ 51 - 0
pagesMatch/match/sign.wxml

@@ -0,0 +1,51 @@
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
+    <view slot="info" class="container main">
+        <view class="one">
+            <form catchsubmit="onSubmit">
+                <view class="content" style="display: none;">
+                    <view class="label">用户id:</view>
+                    <view class="value">
+                        <input type="text" name="user_id" value="{{user._id}}" placeholder="请输入用户id" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">赛事分组:</view>
+                    <view class="value">
+                        <picker mode="selector" bindchange="groupChange" name="group_id" value="{{form.group_id}}" range="{{groupList}}" range-key="name">
+                            <view class="picker">{{form.group_name||'请选择赛事分组'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">分组年龄限制:</view>
+                    <view class="value">
+                        <input type="text" name="group_age" value="{{form.group_age}}" disabled placeholder="请输入分组年龄限制" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">项目名称:</view>
+                    <view class="value">
+                        <picker mode="selector" bindchange="projectChange" name="project_id" value="{{form.project_id}}" range="{{projectList}}" range-key="name">
+                            <view class="picker">{{form.project_name||'请选择项目名称'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">项目年龄限制:</view>
+                    <view class="value">
+                        <input type="text" name="project_age" value="{{form.project_age}}" disabled placeholder="请输入项目年龄限制" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">身份证号:</view>
+                    <view class="value">
+                        <input type="number" name="card" value="{{form.card}}" placeholder="请输入身份证号" />
+                    </view>
+                </view>
+                <view class="btn">
+                    <button type="primary" size="mini" formType="submit">提交保存</button>
+                </view>
+            </form>
+        </view>
+    </view>
+</mobile-main>

+ 26 - 0
pagesMatch/match/sign.wxss

@@ -0,0 +1,26 @@
+@import "/app.wxss";
+.main {
+  background-color: var(--mainColor);
+}
+.main .one .content {
+  display: flex;
+  flex-direction: row;
+  border-bottom: 1px dashed var(--f1Color);
+  padding: 2vw 0;
+  margin: 0 2vw 2vw 2vw;
+}
+.main .one .content .value {
+  flex-grow: 1;
+  color: var(--blackColor);
+}
+.main .one .content .value textarea {
+  position: static;
+  width: 72vw;
+}
+.main .one .btn {
+  text-align: center;
+  margin: 3vw 0;
+}
+.main .one .btn button {
+  margin: 0 2vw;
+}

+ 3 - 4
project.config.json

@@ -26,7 +26,7 @@
         "checkInvalidKey": true,
         "checkSiteMap": true,
         "uploadWithSourceMap": true,
-        "compileHotReLoad": false,
+        "compileHotReLoad": true,
         "lazyloadPlaceholderEnable": false,
         "useMultiFrameRuntime": true,
         "useApiHook": true,
@@ -36,6 +36,7 @@
             "disablePlugins": [],
             "outputPath": ""
         },
+        "enableEngineNative": false,
         "useIsolateContext": false,
         "userConfirmedBundleSwitch": false,
         "packNpmManually": false,
@@ -44,9 +45,7 @@
         "disableUseStrict": false,
         "minifyWXML": true,
         "showES6CompileOption": false,
-        "useCompilerPlugins": false,
-        "ignoreUploadUnusedFiles": true,
-        "useStaticServer": true
+        "useCompilerPlugins": false
     },
     "compileType": "miniprogram",
     "libVersion": "2.19.4",