李志伟 3 jaren geleden
bovenliggende
commit
8f876c2515
1 gewijzigde bestanden met toevoegingen van 17 en 2 verwijderingen
  1. 17
    2
      src/hotel/pages/landlord/addRoom/addRoom.jsx

+ 17
- 2
src/hotel/pages/landlord/addRoom/addRoom.jsx Bestand weergeven

138
       }
138
       }
139
     })
139
     })
140
   }
140
   }
141
+  const isError = (s) => {
142
+    if (!s) { return true }
143
+    else {
144
+      // 根据,(逗号)进行分割
145
+      let split = s.split(",");
146
+      if (split.length != 2) {
147
+        return true
148
+      } else {
149
+        if (!split[0] || !split[1]) {
150
+          return true
151
+        }
152
+      }
153
+    }
154
+    return false
155
+  }
141
   return (
156
   return (
142
     <view className='page-index'>
157
     <view className='page-index'>
143
       <view className="index-navbar">
158
       <view className="index-navbar">
170
             <mp-cells title='房屋位置'>
185
             <mp-cells title='房屋位置'>
171
               <mp-cell>
186
               <mp-cell>
172
                 <Input style={{ color: '#000', fontWeight: 'bold', marginBottom: '13px' }} onInput={(e) => setRoomModel({ ...roomModel, address: e.detail.value })} value={roomModel.address} placeholder='请输入房屋位置(必填)' />
187
                 <Input style={{ color: '#000', fontWeight: 'bold', marginBottom: '13px' }} onInput={(e) => setRoomModel({ ...roomModel, address: e.detail.value })} value={roomModel.address} placeholder='请输入房屋位置(必填)' />
173
-                <Label style={{ color: '#666' }} onClick={onRoomMap}>{roomModel.location == '' ? '房间定位(必填)' : roomModel.location}</Label>
188
+                <Label style={{ color: '#666' }} onClick={onRoomMap}>{isError(roomModel.location)? '房间定位(必填)' : roomModel.location}</Label>
174
               </mp-cell>
189
               </mp-cell>
175
             </mp-cells>
190
             </mp-cells>
176
             {
191
             {
178
                 <mp-cells title='停车场位置'>
193
                 <mp-cells title='停车场位置'>
179
                   <mp-cell>
194
                   <mp-cell>
180
                     <Input onInput={(e) => setRoomModel({ ...roomModel, parkingAddress: e.detail.value })} value={roomModel.parkingAddress} placeholder='请输入停车场位置' />
195
                     <Input onInput={(e) => setRoomModel({ ...roomModel, parkingAddress: e.detail.value })} value={roomModel.parkingAddress} placeholder='请输入停车场位置' />
181
-                    <Label style={{ color: '#666', lineHeight: '30px' }} onClick={onParkMap}>{roomModel.parkingLocation == '' ? '停车场定位' : roomModel.parkingLocation}</Label>
196
+                    <Label style={{ color: '#666', lineHeight: '30px' }} onClick={onParkMap}>{isError(roomModel.parkingLocation)? '停车场定位' : roomModel.parkingLocation}</Label>
182
                   </mp-cell>
197
                   </mp-cell>
183
                 </mp-cells> : null
198
                 </mp-cells> : null
184
             }
199
             }