Silent 6 years ago
parent
commit
0132bb8fc6
2 changed files with 33 additions and 3 deletions
  1. 15 1
      app/Http/Controllers/Admin/FormSetController.php
  2. 18 2
      wechat/pages/form/index.js

+ 15 - 1
app/Http/Controllers/Admin/FormSetController.php

@@ -64,13 +64,27 @@ class FormSetController extends Controller
         if(empty($request->input('data')) || !is_array($request->input('data'))) {
         if(empty($request->input('data')) || !is_array($request->input('data'))) {
             return response()->json(['status' => 'fail', 'info' => '参数错误']);
             return response()->json(['status' => 'fail', 'info' => '参数错误']);
         }
         }
+
+        $form_set = FormData::first();
+        if(empty($form_set)) {
+            return response()->json(['status' => 'fail', 'info' => '参数错误']);
+        }
+
         $data = $request->input('data');
         $data = $request->input('data');
         if(!isset($data['type']) || !in_array($data['type'], ['pay', 'form'])) {
         if(!isset($data['type']) || !in_array($data['type'], ['pay', 'form'])) {
             return response()->json(['status' => 'fail', 'info' => '参数错误']);
             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'])) {
         if(isset($data['checkbox']) && is_array($data['checkbox'])) {
             $data['checkbox'] = implode(',', $data['checkbox']);
             $data['checkbox'] = implode(',', $data['checkbox']);
+            $data['checkbox'] = $form_set['checkbox'] . ':' . $data['checkbox'];
         }
         }
         unset($data['type']);
         unset($data['type']);
         $res = FormData::create($data);
         $res = FormData::create($data);

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

@@ -38,8 +38,12 @@ Page({
     var that = this,
     var that = this,
         data = that.data.data,
         data = that.data.data,
         value = e.detail.value;
         value = e.detail.value;
-    value.id = '1';
-    console.log(value)
+    
+    if(data.money && data.money != '0') {
+      value.type = 'pay';
+    } else {
+      value.type = 'form';
+    }
     if(data.text_1_need == 1 && !value.text_1) {
     if(data.text_1_need == 1 && !value.text_1) {
       wx.showToast({
       wx.showToast({
         icon: 'none',
         icon: 'none',
@@ -91,6 +95,18 @@ Page({
 
 
       wx.request({
       wx.request({
         url: api.submitFormUrl,
         url: api.submitFormUrl,
+        method: 'POST',
+        data: {
+          data: value
+        },
+        success: res => {
+          if(res.data.status == 'success') {
+            wx.showToast({
+              icon: 'none',
+              title: '提交成功',
+            })
+          }
+        }
       })
       })
     }
     }