提交 608d3d3e59ed324ea901f5db44ed9254e7c956cc

作者 wangyu
1 个父辈 f1ecc36b

优化

... ... @@ -12,9 +12,9 @@ Page({
12 12 legal_entity_id: "",
13 13 legal_entity: "",
14 14 house_type: "",
15   - person_total_amount:0,
  15 + person_total_amount: 0,
16 16 remaining_amount: 0,
17   - input_disable:false,
  17 + input_disable: false,
18 18 declareStatus: {
19 19 "to_declare": "待申报",
20 20 "declaring": "申报中",
... ... @@ -166,20 +166,20 @@ Page({
166 166 handleAddition: function(data) {
167 167 var that = this
168 168 var newdata = data.items
169   - if (newdata && newdata.length>0){
  169 + if (newdata && newdata.length > 0) {
170 170 var issinglechild_Data = this.data.issinglechildData;
171 171 issinglechild_Data.disabled = true;
172   - issinglechild_Data.selected = data.is_single=='y'?"是":"否";
  172 + issinglechild_Data.selected = data.is_single == 'y' ? "是" : "否";
173 173
174 174 var shareMethod_Data = this.data.shareMethodData;
175 175 shareMethod_Data.disabled = true;
176   - shareMethod_Data.selected = data.share_method ? data.share_method:"";
  176 + shareMethod_Data.selected = data.share_method ? data.share_method : "";
177 177
178 178 this.setData({
179 179 issinglechildData: issinglechild_Data,
180 180 shareMethodData: shareMethod_Data,
181 181 reduce_amount: data.month_deduction_amount ? data.month_deduction_amount : that.data.reduce_amount,
182   - input_disable:true
  182 + input_disable: true
183 183 })
184 184 }
185 185 for (var i = 0; i < newdata.length; i++) {
... ... @@ -210,18 +210,18 @@ Page({
210 210 }
211 211 if (newdata[i].rent_end) {
212 212 newdata[i].rent_end = this.formatDate(newdata[i].rent_end)
213   - }
214   - if (newdata[i].loan_start) {//公积金
  213 + }
  214 + if (newdata[i].loan_start) { //公积金
215 215 newdata[i].loan_start = this.formatDate(newdata[i].loan_start)
216   - }
217   - if (newdata[i].sec_loan_start) {//商业
  216 + }
  217 + if (newdata[i].sec_loan_start) { //商业
218 218 newdata[i].sec_loan_start = this.formatDate(newdata[i].sec_loan_start)
219   - }
  219 + }
220 220
221 221 newdata[i].children_id_card_no = this.formatIdNum(newdata[i].children_id_card_no)
222 222 newdata[i].spouse_id_card_no = this.formatIdNum(newdata[i].spouse_id_card_no)
223 223 newdata[i].id_card_no = this.formatIdNum(newdata[i].id_card_no)
224   -
  224 +
225 225 if (newdata[i].house_address) {
226 226 if (newdata[i].house_address.province == newdata[i].house_address.city) {
227 227 newdata[i].house_address_new = newdata[i].house_address.city + newdata[i].house_address.district
... ... @@ -251,7 +251,7 @@ Page({
251 251 console.log("housetype_new", housetype_new)
252 252 this.setData({
253 253 house_type: housetype_new,
254   - person_total_amount: data.person_total_amount ? data.person_total_amount:0,
  254 + person_total_amount: data.person_total_amount ? data.person_total_amount : 0,
255 255 remaining_amount: data.remaining_amount ? data.remaining_amount : 0,
256 256 additionInfo: newdata
257 257 })
... ... @@ -332,10 +332,15 @@ Page({
332 332 this.showToast("请选择分摊方式")
333 333 return
334 334 }
335   - if (this.data.reduce_amount == -1){
  335 + if (this.data.reduce_amount == -1) {
336 336 this.showToast("请输入扣除金额")
337 337 return
338   - }else if (this.data.reduce_amount < 0 || this.data.reduce_amount > 1000) {
  338 + }
  339 + if (format.checkNumber(this.data.reduce_amount)){
  340 + this.showToast("请输入正确格式")
  341 + return
  342 + }
  343 + if (this.data.reduce_amount < 0 || this.data.reduce_amount > 1000) {
339 344 this.showToast("本年度月扣除金额不得大于1000")
340 345 return
341 346 }
... ... @@ -344,6 +349,7 @@ Page({
344 349 reduce_amount: 2000
345 350 })
346 351 }
  352 + console.log("reduce_amount", this.data.reduce_amount)
347 353 }
348 354 var modalinfo, senddata
349 355 if (this.data.cur_status == 'continuing_education' || this.data.cur_status == 'house_fund') {
... ... @@ -543,7 +549,7 @@ Page({
543 549 formatDate(date) {
544 550 if (date == 0 || date == -62135596800) {
545 551 date = ""
546   - }else{
  552 + } else {
547 553 date = format.formatTime_date(date)
548 554 }
549 555 console.log("formatDate", date)
... ... @@ -564,16 +570,20 @@ Page({
564 570
565 571 bindinput: function(e) {
566 572 console.log("bindinput", e)
567   - var inputamount
568   - if (e.detail.value && e.detail.value.replace(/\s|\xA0/g, "").length>0){
569   - inputamount = parseFloat(e.detail.value)+0
570   - }else{
571   - inputamount = -1
  573 + var inputamount
  574 + if (!e.detail.value || e.detail.value.length < 1 || parseFloat(e.detail.value).toString() == "NaN") {
  575 + this.showToast("请输入正确格式");
  576 + return;
572 577 }
  578 +
  579 + if (e.detail.value.length < 1 || !format.checkNumber(e.detail.value)) {
  580 + this.showToast("请输入正确格式");
  581 + return;
  582 + }
  583 +
573 584 this.setData({
574 585 reduce_amount: inputamount
575 586 })
576   - console.log("reduce_amount", inputamount)
577 587 },
578 588
579 589 showToast: function(data) {
... ...
... ... @@ -33,14 +33,14 @@
33 33 </view>
34 34 <view wx:else style='height:90rpx'>
35 35 <text style='line-height: 90rpx;text-align:right;font-size: 30rpx;color: #333;margin-left:26rpx'>本年度月扣除金额</text>
36   - <text class='float_right' style='line-height: 90rpx;text-align:right;font-size: 30rpx;color: #ff9f00;' name='country'>{{reduce_amount}}/月</text>
  36 + <text class='float_right' style='line-height: 90rpx;text-align:right;font-size: 30rpx;color: #ff9f00;' name='country'>¥{{reduce_amount}}/月</text>
37 37 </view>
38 38 </view>
39 39 <view wx:elif="{{issinglechildData.selected=='是'}}">
40 40 <view class='divide_line_f5f5f5'></view>
41 41 <view style='height:90rpx'>
42 42 <text style='line-height: 90rpx;text-align:right;font-size: 30rpx;color: #333;margin-left:26rpx'>本年度月扣除金额</text>
43   - <text class='float_right' style='line-height: 90rpx;text-align:right;font-size: 30rpx;color: #ff9f00;' name='country'>2000/月</text>
  43 + <text class='float_right' style='line-height: 90rpx;text-align:right;font-size: 30rpx;color: #ff9f00;' name='country'>¥2000/月</text>
44 44 </view>
45 45 </view>
46 46 </view>
... ...
... ... @@ -140,6 +140,15 @@ function isMobile(mobile) {
140 140 return regMobile.test(mobile)
141 141 }
142 142
  143 +//验证字符串是否是数字
  144 +function checkNumber(theObj) {
  145 + var reg = /^[0-9]+.?[0-9]*$/;
  146 + if (reg.test(theObj)) {
  147 + return true;
  148 + }
  149 + return false;
  150 +}
  151 +
143 152 module.exports = {
144 153 formatTime: formatTime,
145 154 formatTime_date: formatTime_date,
... ... @@ -151,5 +160,6 @@ module.exports = {
151 160 isIDCardNum: isIDCardNum,
152 161 curDateTime: curDateTime,
153 162 analyzeIDCard: analyzeIDCard,
  163 + checkNumber: checkNumber,
154 164 isMobile: isMobile
155 165 }
... ...
注册登录 后发表评论