zs 2 年 前
コミット
6b0e79f6dc

+ 17 - 15
pages/stuAdmin/open/sign.js

@@ -1,9 +1,10 @@
 const app = getApp()
 Page({
     data: {
-        frameStyle: { useTop: true, name: '公开课信息', leftArrow: true, useBar: false },
+        frameStyle: { useTop: true, name: '报名', leftArrow: true, useBar: false },
         id: '',
         form: {},
+        user: {},
         //状态
         statusList: []
     },
@@ -15,20 +16,20 @@ Page({
     onSubmit: async function (e) {
         const that = this;
         const form = that.data.form;
-        const params = e.detail.value;
-        params.icon = form.icon;
-        params.school_id = that.data.school_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 arr;
-            if (form._id) arr = await app.$post(`/student/${form._id}`, params);
-            else arr = await app.$post(`/student`, params)
-            if (arr.errcode == '0') { wx.showToast({ title: `维护信息完成`, icon: 'success', duration: 2000 }); that.back(); }
-            else wx.showToast({ title: `${errmsg}`, icon: 'error', duration: 2000 })
-        }
+        const user = that.data.user;
+        wx.showModal({
+            title: '提示',
+            content: '您是否确定报名?',
+            async success(res) {
+                if (res.confirm) {
+                    var student = { id: user.info.id, name: user.info.name }
+                    form.student.push(student);
+                    let arr = await app.$post(`/student/${form._id}`, form);
+                    if (arr.errcode == '0') { wx.showToast({ title: `报名完成`, icon: 'success', duration: 2000 }); that.back(); }
+                    else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
+                } else if (res.cancel) { }
+            }
+        });
     },
     /**
      * 生命周期函数--监听页面加载
@@ -55,6 +56,7 @@ Page({
         wx.getStorage({
             key: 'user',
             success: async res => {
+                that.setData({ user: res.data })
                 if (that.data.id) {
                     const arr = await app.$get(`/lessonPublic/${that.data.id}`);
                     if (arr.errcode == '0') {

+ 11 - 0
pages/stuAdmin/open/sign.less

@@ -33,5 +33,16 @@
                 flex-direction: column;
             }
         }
+
+        .btn {
+            width: 92vw;
+            text-align: center;
+            margin: 2vw 0 0 0;
+
+            button {
+                font-size: var(--font14Size);
+                background: -webkit-linear-gradient(right, lightblue, #53C9F8);
+            }
+        }
     }
 }

+ 3 - 3
pages/stuAdmin/open/sign.wxml

@@ -1,6 +1,6 @@
 <mobile-main frameStyle="{{frameStyle}}" bind:back="back">
     <view slot="info" class="container main">
-        <view class="one" catchsubmit="onSubmit">
+        <form class="one" catchsubmit="onSubmit">
             <view class="one_1">
                 <text class="text">课程标题:</text>
                 <text class="text1">{{form.title||'暂无'}}</text>
@@ -42,8 +42,8 @@
                 </view>
             </view>
             <view class="btn">
-                <button type="primary" size="mini" formType="submit">提交保存</button>
+                <button type="primary" size="mini" formType="submit">报名</button>
             </view>
-        </view>
+        </form>
     </view>
 </mobile-main>

+ 9 - 0
pages/stuAdmin/open/sign.wxss

@@ -29,3 +29,12 @@
   display: flex;
   flex-direction: column;
 }
+.main .one .btn {
+  width: 92vw;
+  text-align: center;
+  margin: 2vw 0 0 0;
+}
+.main .one .btn button {
+  font-size: var(--font14Size);
+  background: -webkit-linear-gradient(right, lightblue, #53C9F8);
+}