Silent 6 年之前
父节点
当前提交
d3edcc7758

+ 0 - 35
app/Http/Controllers/Admin/FormSetController.php

@@ -58,39 +58,4 @@ class FormSetController extends Controller
         }
         }
         return $this->showMessage('操作成功');
         return $this->showMessage('操作成功');
     }
     }
-
-    public function submitForm(Request $request)
-    {
-        if(empty($request->input('data')) || !is_array($request->input('data'))) {
-            return response()->json(['status' => 'fail', 'info' => '参数错误']);
-        }
-
-        $form_set = FormData::first();
-        if(empty($form_set)) {
-            return response()->json(['status' => 'fail', 'info' => '参数错误']);
-        }
-
-        $data = $request->input('data');
-        if(!isset($data['type']) || !in_array($data['type'], ['pay', 'form'])) {
-            return response()->json(['status' => 'fail', 'info' => '参数错误']);
-        }
-
-        $items = ['text_1', 'text_2', 'text_3', 'text_4', 'multi_text', 'radio'];
-        foreach($items as $item) {
-            if(isset($data[$item])) {
-                $data[$item] = $form_set[$item] . ':' . $data[$item];
-            }
-        }
-
-        if(isset($data['checkbox']) && is_array($data['checkbox'])) {
-            $data['checkbox'] = implode(',', $data['checkbox']);
-            $data['checkbox'] = $form_set['checkbox'] . ':' . $data['checkbox'];
-        }
-        unset($data['type']);
-        $res = FormData::create($data);
-        if(empty($res)) {
-            return response()->json(['status' => 'fail', 'info' => '保存失败']);
-        }
-        return response()->json(['status' => 'success', 'info' => '提交成功']);
-    }
 }
 }

+ 36 - 0
app/Http/Controllers/WeChat/ApiController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers\WeChat;
 
 
 use App\Models\CheckCard;
 use App\Models\CheckCard;
 use App\Models\Content;
 use App\Models\Content;
+use App\Models\FormData;
 use App\Models\FormSet;
 use App\Models\FormSet;
 use App\Models\Leave;
 use App\Models\Leave;
 use App\Models\Remark;
 use App\Models\Remark;
@@ -504,4 +505,39 @@ class ApiController extends Controller
         }
         }
         return response()->json(['status' => 'success', 'data' => $form_set]);
         return response()->json(['status' => 'success', 'data' => $form_set]);
     }
     }
+
+    public function submitForm(Request $request)
+    {
+        if(empty($request->input('data')) || !is_array($request->input('data'))) {
+            return response()->json(['status' => 'fail', 'info' => '参数错误']);
+        }
+
+        $form_set = FormData::first();
+        if(empty($form_set)) {
+            return response()->json(['status' => 'fail', 'info' => '参数错误']);
+        }
+
+        $data = $request->input('data');
+        if(!isset($data['type']) || !in_array($data['type'], ['pay', 'form'])) {
+            return response()->json(['status' => 'fail', 'info' => '参数错误']);
+        }
+
+        $items = ['text_1', 'text_2', 'text_3', 'text_4', 'multi_text', 'radio'];
+        foreach($items as $item) {
+            if(isset($data[$item])) {
+                $data[$item] = $form_set[$item] . ':' . $data[$item];
+            }
+        }
+
+        if(isset($data['checkbox']) && is_array($data['checkbox'])) {
+            $data['checkbox'] = implode(',', $data['checkbox']);
+            $data['checkbox'] = $form_set['checkbox'] . ':' . $data['checkbox'];
+        }
+        unset($data['type']);
+        $res = FormData::create($data);
+        if(empty($res)) {
+            return response()->json(['status' => 'fail', 'info' => '保存失败']);
+        }
+        return response()->json(['status' => 'success', 'info' => '提交成功']);
+    }
 }
 }

+ 15 - 18
wechat/pages/form/index.js

@@ -18,7 +18,6 @@ Page({
       url: api.getFormSetUrl,
       url: api.getFormSetUrl,
       method: 'GET',
       method: 'GET',
       success: res => {
       success: res => {
-        console.log(res)
         if(res.data.status == 'success') {
         if(res.data.status == 'success') {
           that.setData({
           that.setData({
             data: res.data.data
             data: res.data.data
@@ -92,24 +91,22 @@ Page({
         title: data.checkbox + '必填',
         title: data.checkbox + '必填',
       })
       })
       return false;
       return false;
-
-      wx.request({
-        url: api.submitFormUrl,
-        method: 'POST',
-        data: {
-          data: value
-        },
-        success: res => {
-          if(res.data.status == 'success') {
-            wx.showToast({
-              icon: 'none',
-              title: '提交成功',
-            })
-          }
-        }
-      })
     }
     }
-    
+    wx.request({
+      url: api.submitFormUrl,
+      method: 'POST',
+      data: {
+        data: value
+      },
+      success: res => {
+        if (res.data.status == 'success') {
+          wx.showToast({
+            icon: 'none',
+            title: '提交成功',
+          })
+        }
+      }
+    })
   },
   },
   /**
   /**
    * 生命周期函数--监听页面初次渲染完成
    * 生命周期函数--监听页面初次渲染完成