浏览代码

帮我找房必选项

1002884655 3 年前
父节点
当前提交
7ef85483c0

+ 2
- 2
project.config.json 查看文件

@@ -2,7 +2,7 @@
2 2
 	"miniprogramRoot": "dist/",
3 3
 	"projectname": "miniapp",
4 4
 	"description": "",
5
-	"appid": "wxc96058d57e77f373",
5
+	"appid": "wxe44244d1a5ea3364",
6 6
 	"setting": {
7 7
 		"urlCheck": false,
8 8
 		"es6": false,
@@ -27,7 +27,7 @@
27 27
 			"outputPath": ""
28 28
 		},
29 29
 		"useIsolateContext": true,
30
-		"useCompilerModule": true,
30
+		"useCompilerModule": false,
31 31
 		"userConfirmedUseCompilerModuleSwitch": false
32 32
 	},
33 33
 	"compileType": "miniprogram",

+ 28
- 13
src/pages/index/addedValueService/index.jsx 查看文件

@@ -4,6 +4,7 @@ import { Image, Slider, Textarea, ScrollView } from '@tarojs/components'
4 4
 import { fetch } from '@/utils/request'
5 5
 import { API_HELP_FIND_HOUSE_SUBMIT } from '@/constants/api'
6 6
 import { useSelector } from 'react-redux'
7
+import Taro from '@tarojs/taro'
7 8
 import './index.scss'
8 9
 import questions from './formData'
9 10
 import SubmitBuyHouseResult from '../helpToFindHouse/components/SubmitBuyHouseResult/index'
@@ -90,20 +91,34 @@ export default function AddedValueService () {
90 91
   }
91 92
 
92 93
   const NextStep = () => {
93
-    if (StepId < 4) {
94
-      setStepId(StepId + 1)
95
-    } else {
96
-      let Arr = [...FormData]
97
-      Arr.map((item) => {
98
-        if (item.type === 'checkboxs') {
99
-          item.options.map((subItem) => {
100
-            if (subItem.selected) {
101
-              item.result.push(subItem.name)
102
-            }
103
-          })
94
+    let Bool = true
95
+    let IndexArr = []
96
+    FormData.map((item, index) => {
97
+      if(index >= StepRange[0] && index < StepRange[1]) {
98
+        if(!!item.required && item.result === '') {
99
+          Bool = false
100
+          IndexArr.push(index)
104 101
         }
105
-      })
106
-      SubmitForm(Arr)
102
+      }
103
+    })
104
+    if(Bool) {
105
+      if (StepId < 4) {
106
+        setStepId(StepId + 1)
107
+      } else {
108
+        let Arr = [...FormData]
109
+        Arr.map((item) => {
110
+          if (item.type === 'checkboxs') {
111
+            item.options.map((subItem) => {
112
+              if (subItem.selected) {
113
+                item.result.push(subItem.name)
114
+              }
115
+            })
116
+          }
117
+        })
118
+        SubmitForm(Arr)
119
+      }
120
+    } else {
121
+      Taro.showToast({title: `请选择${FormData[IndexArr[0]].question}`, icon: 'none'})
107 122
     }
108 123
   }
109 124
 

+ 6
- 2
src/pages/index/helpToFindHouse/components/BuyHouse/formData.js 查看文件

@@ -3,9 +3,10 @@ const questions = [
3 3
     question: '你的购房预算是多少?',
4 4
     key: 'budget',
5 5
     type: 'range',
6
-    result: '300',
6
+    result: 300,
7 7
     resultId: null,
8
-    options: [100, 1000]
8
+    required: true,
9
+    options: [100, 2000]
9 10
   },
10 11
   {
11 12
     question: '你想购买的是新房还是二手房?',
@@ -13,6 +14,7 @@ const questions = [
13 14
     type: 'checkbox',
14 15
     result: '',
15 16
     resultId: null,
17
+    required: true,
16 18
     options: [
17 19
       { name: '新房', id: 1 },
18 20
       { name: '二手房', id: 2 },
@@ -50,6 +52,7 @@ const questions = [
50 52
     type: 'checkbox',
51 53
     result: '',
52 54
     resultId: null,
55
+    required: true,
53 56
     options: [
54 57
       { name: '刚需', id: 1 },
55 58
       { name: '结婚', id: 2 },
@@ -138,6 +141,7 @@ const questions = [
138 141
     type: 'checkbox',
139 142
     result: '',
140 143
     resultId: null,
144
+    required: true,
141 145
     options: [
142 146
       { name: '5年以内', id: 1 },
143 147
       { name: '10年以内', id: 2 },

+ 19
- 4
src/pages/index/helpToFindHouse/components/BuyHouse/index.jsx 查看文件

@@ -1,11 +1,12 @@
1 1
 import { useState, useEffect } from 'react'
2 2
 import '@/assets/css/iconfont.css'
3 3
 import { Image, Slider, Textarea } from '@tarojs/components'
4
+import Taro from '@tarojs/taro'
4 5
 import './index.scss'
5 6
 import questions from './formData'
6 7
 
7 8
 export default function BuyHouse (props) {
8
-  const { change = () => { }, toSubmit = () => { }, AreaInfo = {}, selectArea = () => {} } = props
9
+  const { change = () => { }, toSubmit = () => { }, AreaInfo = {}, selectArea = () => { } } = props
9 10
 
10 11
   const [FormData, setFormData] = useState(questions)
11 12
   const [StepId, setStepId] = useState(1)
@@ -52,10 +53,24 @@ export default function BuyHouse (props) {
52 53
   }
53 54
 
54 55
   const NextStep = () => {
55
-    if (StepId < 4) {
56
-      setStepId(StepId + 1)
56
+    let Bool = true
57
+    let IndexArr = []
58
+    FormData.map((item, index) => {
59
+      if (index >= StepRange[0] && index < StepRange[1]) {
60
+        if (!!item.required && item.result === '') {
61
+          Bool = false
62
+          IndexArr.push(index)
63
+        }
64
+      }
65
+    })
66
+    if (Bool) {
67
+      if (StepId < 4) {
68
+        setStepId(StepId + 1)
69
+      } else {
70
+        toSubmit(FormData)
71
+      }
57 72
     } else {
58
-      toSubmit(FormData)
73
+      Taro.showToast({ title: `请选择${FormData[IndexArr[0]].question}`, icon: 'none' })
59 74
     }
60 75
   }
61 76
 

+ 1
- 1
src/pages/index/helpToFindHouse/components/HousePurchasing/formData.js 查看文件

@@ -12,7 +12,7 @@ const questions = [
12 12
     type: 'range',
13 13
     result: '',
14 14
     resultId: null,
15
-    options: [100, 1000]
15
+    options: [100, 2000]
16 16
   },
17 17
   {
18 18
     question: '优先选择的房屋类型是?',

+ 18
- 3
src/pages/index/helpToFindHouse/components/HousePurchasing/index.jsx 查看文件

@@ -1,6 +1,7 @@
1 1
 import { useState, useEffect } from 'react'
2 2
 import '@/assets/css/iconfont.css'
3 3
 import { Image, Slider, Textarea } from '@tarojs/components'
4
+import Taro from '@tarojs/taro'
4 5
 import './index.scss'
5 6
 import questions from './formData'
6 7
 
@@ -47,10 +48,24 @@ export default function HousePurchasing (props) {
47 48
   }
48 49
 
49 50
   const NextStep = () => {
50
-    if (StepId < 1) {
51
-      setStepId(StepId + 1)
51
+    let Bool = true
52
+    let IndexArr = []
53
+    FormData.map((item, index) => {
54
+      if(index >= StepRange[0] && index < StepRange[1]) {
55
+        if(!!item.required && item.result === '') {
56
+          Bool = false
57
+          IndexArr.push(index)
58
+        }
59
+      }
60
+    })
61
+    if(Bool) {
62
+      if (StepId < 4) {
63
+        setStepId(StepId + 1)
64
+      } else {
65
+        toSubmit(FormData)
66
+      }
52 67
     } else {
53
-      toSubmit(FormData)
68
+      Taro.showToast({title: `请选择${FormData[IndexArr[0]].question}`, icon: 'none'})
54 69
     }
55 70
   }
56 71
 

+ 1
- 1
src/pages/index/helpToFindHouse/components/RentingHouse/formData.js 查看文件

@@ -5,7 +5,7 @@ const questions = [
5 5
     type: 'range',
6 6
     result: '',
7 7
     resultId: null,
8
-    options: [500, 4500]
8
+    options: [500, 20000]
9 9
   },
10 10
   {
11 11
     question: '你的租房偏好?',

+ 28
- 13
src/pages/index/helpToFindHouse/components/RentingHouse/index.jsx 查看文件

@@ -1,6 +1,7 @@
1 1
 import { useState, useEffect } from 'react'
2 2
 import '@/assets/css/iconfont.css'
3 3
 import { Image, Slider, Textarea } from '@tarojs/components'
4
+import Taro from '@tarojs/taro'
4 5
 import './index.scss'
5 6
 import questions from './formData'
6 7
 
@@ -57,20 +58,34 @@ export default function RentingHouse (props) {
57 58
   }
58 59
 
59 60
   const NextStep = () => {
60
-    if (StepId < 2) {
61
-      setStepId(StepId + 1)
62
-    } else {
63
-      let Arr = [...FormData]
64
-      Arr.map((item) => {
65
-        if (item.type === 'checkbox') {
66
-          item.options.map((subItem) => {
67
-            if (subItem.selected) {
68
-              item.result.push(subItem.name)
69
-            }
70
-          })
61
+    let Bool = true
62
+    let IndexArr = []
63
+    FormData.map((item, index) => {
64
+      if(index >= StepRange[0] && index < StepRange[1]) {
65
+        if(!!item.required && item.result === '') {
66
+          Bool = false
67
+          IndexArr.push(index)
71 68
         }
72
-      })
73
-      toSubmit(Arr)
69
+      }
70
+    })
71
+    if(Bool) {
72
+      if (StepId < 2) {
73
+        setStepId(StepId + 1)
74
+      } else {
75
+        let Arr = [...FormData]
76
+        Arr.map((item) => {
77
+          if (item.type === 'checkbox') {
78
+            item.options.map((subItem) => {
79
+              if (subItem.selected) {
80
+                item.result.push(subItem.name)
81
+              }
82
+            })
83
+          }
84
+        })
85
+        toSubmit(Arr)
86
+      }
87
+    } else {
88
+      Taro.showToast({title: `请选择${FormData[IndexArr[0]].question}`, icon: 'none'})
74 89
     }
75 90
   }
76 91