审查视图

pages/main/addtionalreduce/addextrainfo/addextrainfo.js 112.8 KB
wangyu authored
1
// pages/main/addtionalreduce/addextrainfo/addextrainfo.js
pangy authored
2
var format = require('../../../../utils/util.js');
3
// var countryInfo = require('../../../../utils/country.js');
pangy authored
4 5
const reg_18_Number = /^[0-9]{18}$/;
const reg_9_n_a = /^([a-zA-z]|[0-9]){9}$/;
pangy authored
6
const cardTypeArray = ['居民身份证', '中国护照', '港澳居民来往内地通行证', '港澳居民居住证', '台湾居民来往大陆通行证', '台湾居民居住证', '外国护照', '外国人永久居留身份证', '外国人工作许可证(A类)', '外国人工作许可证(B类)', '外国人工作许可证(C类)'];
wangyu authored
7
var OSSInit;
wangyu authored
8 9
var app = getApp();
var baseUrl = app.globalData.baseUrl;
wangyu authored
10 11 12
const AddTypeNames = {
  'children_education': '子女教育',
  'continuing_education': '继续教育',
pangy authored
13 14 15
  'support_duty': '被赡养老人',
  'medical_fund': '大病医疗支出',
  'house_fund': '住房租金'
wangyu authored
16 17 18 19 20 21
}
const Deduce_amounts_month = {
  'children_education': 1000,
  'continuing_education': 400,
  'support_duty': 2000,
  'medical_fund': 0,
22
  'house_fund_rent': 1000,
pangy authored
23
  "house_fund_loan":1000
wangyu authored
24 25 26 27
}
const Deduce_amounts_year = {
  'children_education': 12000,
  'continuing_education': 4800,
pangy authored
28
  'continuing_education_non': 3600,
wangyu authored
29 30
  'support_duty': 24000,
  'medical_fund': 0,
31
  'house_fund_rent': 12000,
pangy authored
32
  "house_fund_loan": 12000
wangyu authored
33
}
pangy authored
34
wangyu authored
35
Page({
wangyu authored
36
  idcard_belong: null, //照片信息获取返回时判断所属
pangy authored
37
  legal_entity_id: "",
wangyu authored
38
  legal_entity: "",
pangy authored
39
  supporttype:"",
40
  is_single:"",
pangy authored
41
  share_method:"",
42 43
  isEdit:false,
  edit_id:null,
wangyu authored
44
  data: {
pangy authored
45
    hasLover:false,
pangy authored
46
    hasGetLover:false,
wangyu authored
47 48
    house_type: "",
    deduction_amount: '',
wangyu authored
49 50
    lable: 0,
    title: '',
wangyu authored
51
    isIdCard: true,
wangyu authored
52 53 54
    workAddress_haschanged: false,
    loanAddress_haschanged: false,
    rentAddress_haschanged: false,
wangyu authored
55
    extrainfo_arr: ["请上传子女出生证明、学籍信息凭证、学费凭证、本人结婚证和分摊协议", "请上传学历学籍凭证", "请上传出生证明或关系证明、独生子女证、分摊协议、其他法定赡养人赡养证明", "请上传诊断书和医疗费用收据", "请上传首套房证明、还款证明、不动产登记证、结婚证和夫妻约定抵扣协议"],
pangy authored
56
    cur_index: '',
57
    child_edu_pre: false,
pangy authored
58 59 60 61 62 63 64 65 66 67 68

    hasLoverData: {
      label: '是否有配偶',
      isrequre: true,
      bindtype: 'hasLover',
      selected: '',
      isblack: 'true',
      placeholder: '请选择',
      values: ['是', '否'],
      onChange: 'onPickerSelect'
    },
wangyu authored
69
    lovercardtypeData: {
wangyu authored
70
      label: '配偶证照类型',
wangyu authored
71
      bindtype: 'lovercardtype',
72
      selected: '',
pangy authored
73
      // disabled: true,
wangyu authored
74
      placeholder: '请选择证照类型',
pangy authored
75
      values: cardTypeArray,
wangyu authored
76 77 78 79 80 81
      onChange: 'onPickerSelect'
    },
    loverbirthDate: {
      label: '出生日期',
      bindtype: 'loverbirthday',
      selected: '',
pangy authored
82
      // disabled: true,
wangyu authored
83 84 85 86 87
      placeholder: '请选择出生日期',
      mode: "date",
      fields: "day",
      onChange: 'onPickerSelect',
    },
88 89 90
    older_relativeData: {
      label: '与纳税人关系',
      isrequre: true,
pangy authored
91
      // disabled: true,
92 93 94 95 96 97 98
      bindtype: 'older_relative',
      selected: "",
      isblack: 'true',
      placeholder: '请选择与纳税人关系',
      values: ["父母", "其他"],
      onChange: 'onPickerSelect'
    },
wangyu authored
99 100
    taxperson_relativeData: {
      label: '与纳税人的关系',
pangy authored
101
      isrequre: true,
wangyu authored
102 103 104 105
      bindtype: 'taxperson_relative',
      selected: '',
      isblack: 'true',
      placeholder: '请选择与纳税人的关系',
pangy authored
106
      values: ["本人", "配偶", "子女"],
wangyu authored
107 108
      onChange: 'onPickerSelect'
    },
wangyu authored
109 110 111 112 113 114
    childrenpercentData: {
      label: '分配比例',
      bindtype: 'child_percent',
      selected: '',
      isrequre: true,
      isblack: 'true',
pangy authored
115
      values: ["50%", "100%"],
wangyu authored
116 117 118
      placeholder: '请选择分配比例',
      onChange: 'onPickerSelect'
    },
wangyu authored
119
    childrencardtypeData: {
wangyu authored
120
      label: '子女证照类型',
pangy authored
121
      isrequre: true,
wangyu authored
122
      bindtype: 'childrencardtype',
123
      selected: '',
pangy authored
124
      // disabled: true,
wangyu authored
125
      isblack: 'true',
wangyu authored
126
      placeholder: '请选择证照类型',
pangy authored
127
      values: cardTypeArray,
wangyu authored
128 129
      onChange: 'onPickerSelect'
    },
wangyu authored
130
    commonbirthDate: {
wangyu authored
131
      label: '出生日期',
pangy authored
132
      isrequre: true,
133
      disabled:true,
wangyu authored
134
      bindtype: 'commonbirthday',
wangyu authored
135 136
      selected: '',
      isblack: 'true',
137
      placeholder: '出生日期',
wangyu authored
138 139 140 141
      mode: "date",
      fields: "day",
      onChange: 'onPickerSelect',
    },
wangyu authored
142 143
    childedudegreeData: {
      label: '子女受教育阶段',
pangy authored
144
      isrequre: true,
pangy authored
145
      bindtype: 'child_edu_degree',
wangyu authored
146 147
      selected: '',
      isblack: 'true',
148 149
      // values: ["学前教育(满3岁)", "小学教育", "初中教育", "普通高中教育", "中等职业教育", "大学专科教育", "大学本科教育", "硕士研究生教育", "博士研究生教育"],
      values: ["学前教育阶段", "义务教育", "高中阶段教育", "高等教育"],
wangyu authored
150 151 152
      placeholder: '请选择教育阶段',
      onChange: 'onPickerSelect'
    },
wangyu authored
153 154 155 156 157 158 159 160 161
    // edudegreeData: {
    //   label: '教育阶段',
    //   bindtype: 'edu_degree',
    //   selected: '',
    //   isblack: 'true',
    //   values: ["专科", "本科", "硕士研究生", "博士研究生","其他"],
    //   placeholder: '请选择教育阶段',
    //   onChange: 'onPickerSelect'
    // },
wangyu authored
162
    edutypeData: {
wangyu authored
163
      label: '继续教育情况',
pangy authored
164
      isrequre: true,
wangyu authored
165
      bindtype: 'edu_type',
wangyu authored
166 167
      selected: '',
      isblack: 'true',
168
      values: ["学历(学位)继续教育", "职业资格继续教育"],
wangyu authored
169
      placeholder: '请选择教育情况',
wangyu authored
170 171
      onChange: 'onPickerSelect'
    },
wangyu authored
172
    edustyleData: {
wangyu authored
173
      label: '继续教育类型',
pangy authored
174
      isrequre: true,
wangyu authored
175
      bindtype: 'edu_style',
wangyu authored
176 177
      selected: '',
      isblack: 'true',
wangyu authored
178 179
      values: ["技能人员职业资格", "专业技术人员职业资格"],
      placeholder: '请选择教育类型',
wangyu authored
180 181
      onChange: 'onPickerSelect'
    },
pangy authored
182 183
    certificateDate: {
      label: '证书名称',
pangy authored
184
      maxWidth: 460,
pangy authored
185 186 187 188 189 190
      isrequre: true,
      bindtype: 'certificate',
      values: [],
      placeholder: '请输入证书名称',
      onChange: 'onPickerSelect'
    },
wangyu authored
191
    edulevelData: {
wangyu authored
192
      label: '教育阶段',
pangy authored
193
      isrequre: true,
wangyu authored
194 195 196
      bindtype: 'edu_level',
      selected: '',
      isblack: 'true',
197 198
      // values: ["专科", "本科", "硕士研究生", "博士研究生", "其他"],
      values: ["大学专科", "大学本科", "硕士研究生", "博士研究生", "其他"],
wangyu authored
199 200 201
      placeholder: '请选择学历教育阶段',
      onChange: 'onPickerSelect'
    },
pangy authored
202 203 204 205 206 207 208 209 210 211
    // supporttypeData: {
    //   label: '赡养类型',
    //   isrequre: true,
    //   bindtype: 'support_type',
    //   selected: '',
    //   isblack: 'true',
    //   values: ["独生子女", "非独生子女"],
    //   placeholder: '请选择赡养类型',
    //   onChange: 'onPickerSelect'
    // },
212 213 214 215 216 217 218 219 220 221
    shareMethodData: {
      label: '分摊方式',
      isrequre: true,
      bindtype: 'share_method',
      selected: '',
      isblack: 'true',
      values: ["赡养人平均分摊", "赡养人约定分摊", "被赡养人指定分摊"],
      placeholder: '请选择分摊方式',
      onChange: 'onPickerSelect'
    },
wangyu authored
222
    oldercardtypeData: {
wangyu authored
223
      label: '被赡养人证照类型',
pangy authored
224
      isrequre: true,
pangy authored
225
      // disabled: true,
wangyu authored
226
      bindtype: 'oldercardtype',
227
      selected: '',
wangyu authored
228
      isblack: 'true',
wangyu authored
229
      placeholder: '请选择被赡养人证照类型',
pangy authored
230
      values: cardTypeArray,
wangyu authored
231 232
      onChange: 'onPickerSelect'
    },
wangyu authored
233
    cardtypeData: {
pangy authored
234
      label: '证照类型',
pangy authored
235
      // isrequre: true,
236 237
      bindtype: 'ownercardtype',
      selected: '',
pangy authored
238
      // disabled: true,
pangy authored
239
      // isblack: 'true',
wangyu authored
240
      placeholder: '证照类型',
pangy authored
241 242
      values: cardTypeArray,
      //["居民身份证", "军官证", '士兵证', '武警警官证', '港澳居民来往内地通行证', '外交官证', '中国护照','外国护照', '香港永久性居民身份证', '澳门特别行政区永久性居民身份证', '台湾身份证', '台湾居民来往大陆通行证', '外国人永久居留证'],
wangyu authored
243 244
      onChange: 'onPickerSelect'
    },
wangyu authored
245 246
    olderbirthDate: {
      label: '被赡养人出生日期',
pangy authored
247
      isrequre: true,
248
      disabled: true,
wangyu authored
249 250 251
      bindtype: 'olderbirthday',
      selected: '',
      isblack: 'true',
252
      placeholder: '出生日期',
wangyu authored
253 254 255 256
      mode: "date",
      fields: "day",
      onChange: 'onPickerSelect',
    },
wangyu authored
257
    beforemarryData: {
pangy authored
258
      label: '是否首套婚前贷款且婚后分别扣除50%',
wangyu authored
259 260
      bindtype: 'before_marry',
      selected: '',
wangyu authored
261
      isrequre: true,
wangyu authored
262 263 264 265 266 267 268 269 270
      isblack: 'true',
      values: ["是", "否"],
      placeholder: '请选择',
      onChange: 'onPickerSelect'
    },
    isselfData: {
      label: '是否本人借款',
      bindtype: 'is_self_loan',
      selected: '',
wangyu authored
271
      isrequre: true,
wangyu authored
272 273 274 275 276
      isblack: 'true',
      values: ["是", "否"],
      placeholder: '请选择',
      onChange: 'onPickerSelect'
    },
wangyu authored
277 278
    reducetypeData: {
      label: '扣除方式',
wangyu authored
279
      isrequre: false,
pangy authored
280
      disabled: true,
wangyu authored
281
      bindtype: 'reduce_type',
pangy authored
282
      selected: '',
wangyu authored
283
      values: ["月度", "年度"],
wangyu authored
284 285 286
      placeholder: '请选择扣除方式',
      onChange: 'onPickerSelect'
    },
wangyu authored
287
    studystartdate: {
pangy authored
288
      label: '受教育时间起',
pangy authored
289
      isrequre: true,
wangyu authored
290 291 292 293
      bindtype: 'study_start_date',
      selected: '',
      isblack: 'true',
      values: ["是", "否"],
wangyu authored
294
      placeholder: '请选择时间',
wangyu authored
295 296
      onChange: 'onPickerSelect',
      mode: "date",
297
      fields: "month",
wangyu authored
298
      datelong: 0,
pangy authored
299 300 301 302 303
      end: (new Date()).getFullYear() +'-'+ ((new Date()).getMonth()+1),
      // start: (new Date()).getFullYear() + '-09-01',//'1970-01-01',
      // end: (new Date()).getFullYear() + '-09-01',
      // onTap: 'studyDataTap'
    },
pangy authored
304
    studyEndDate: {
pangy authored
305
      label: '受教育时间止',
306
      // isrequre: true,
pangy authored
307
      bindtype: 'study_end_date',
pangy authored
308
      selected: '',
309
      // isblack: 'true',
pangy authored
310 311 312 313 314
      values: ["是", "否"],
      placeholder: '请选择时间',
      onChange: 'onPickerSelect',
      mode: "date",
      fields: "month",
pangy authored
315 316 317
      // start: (new Date()).getFullYear() + '-09-01',//'1970-01-01',
      // end: (new Date()).getFullYear() + '-09-01',
      // onTap: 'studyDataTap'
wangyu authored
318
    },
pangy authored
319
    studyPeriodDate: {
wangyu authored
320
      label: '教育终止时间',
pangy authored
321
      // isrequre: true,
pangy authored
322
      bindtype: 'study_per_date',
wangyu authored
323 324
      selected: '',
      values: ["是", "否"],
wangyu authored
325 326 327
      placeholder: '请选择时间',
      onChange: 'onPickerSelect',
      mode: "date",
328
      fields: "month",
pangy authored
329 330 331
      // start: (new Date()).getFullYear() + '-07-31',//'1970-01-01',
      // end: (new Date()).getFullYear() + '-07-31',
      // onTap: 'studyDataTap',
wangyu authored
332 333 334 335 336 337 338 339 340 341
      datelong: 0,
    },
    applydate: {
      label: '发证(批准)日期',
      isrequre: true,
      bindtype: 'apply_date',
      selected: '',
      isblack: 'true',
      values: ["是", "否"],
      placeholder: '请选择时间',
wangyu authored
342 343 344
      onChange: 'onPickerSelect',
      mode: "date",
      fields: "day",
wangyu authored
345
      datelong: 0,
wangyu authored
346
    },
wangyu authored
347 348 349 350
    identifytypeData: {
      label: '证书类型',
      bindtype: 'identify_type',
      selected: '',
wangyu authored
351
      isrequre: true,
wangyu authored
352
      isblack: 'true',
pangy authored
353 354
      // values: ["产权证", "不动产权登记证", "出售合同号", "预售合同号"],
      values: ["房屋所有权证", "不动产权证", "房屋买卖合同", "房屋预售合同"],
wangyu authored
355 356 357 358 359 360 361
      placeholder: '请选择证书类型',
      onChange: 'onPickerSelect'
    },
    loantypeData: {
      label: '贷款类型',
      bindtype: 'loan_type',
      selected: '',
wangyu authored
362
      isrequre: true,
wangyu authored
363
      isblack: 'true',
pangy authored
364
      values: ["公积金贷款", "商业贷款","组合贷款"],
wangyu authored
365 366 367 368 369 370 371
      placeholder: '请选择贷款类型',
      onChange: 'onPickerSelect'
    },
    leasetypeData: {
      label: '出租方类型',
      bindtype: 'lease_type',
      selected: '',
wangyu authored
372
      isrequre: true,
wangyu authored
373
      isblack: 'true',
pangy authored
374
      values: ["组织", "个人"],
wangyu authored
375 376 377
      placeholder: '请选择出租方类型',
      onChange: 'onPickerSelect'
    },
wangyu authored
378 379
    workingcityInfo: {
      label: '主要工作城市',
380
      maxWidth: 430,
wangyu authored
381
      mode: 'region',
wangyu authored
382
      isrequre: true,
wangyu authored
383 384 385 386 387 388
      bindtype: 'working_city',
      isblack: 'true',
      address_code: ['', ''],
      address_value: ['', ''],
      selected: '',
      placeholder: '请选择城市',
wangyu authored
389
      requestdata: {},
wangyu authored
390 391
      onChange: 'onPickerSelect'
    },
wangyu authored
392 393 394
    houseLocateInfo: {
      label: '房屋坐落地址',
      mode: 'region',
395
      maxWidth: 430,
pangy authored
396
      // isrequre: true,
wangyu authored
397
      bindtype: 'house_locate',
pangy authored
398
      // isblack: 'true',
wangyu authored
399 400 401
      address_code: ['', '', ''],
      address_value: ['', '', ''],
      selected: '',
wangyu authored
402
      requestdata: {},
wangyu authored
403 404 405
      placeholder: '请选择地址',
      onChange: 'onPickerSelect'
    },
wangyu authored
406 407 408
    rentLocateInfo: {
      label: '租赁房屋坐落地址',
      mode: 'region',
pangy authored
409
      // isrequre: true,
pangy authored
410
      maxWidth: 375,
wangyu authored
411
      bindtype: 'rent_house_locate',
pangy authored
412
      // isblack: 'true',
wangyu authored
413 414 415
      address_code: ['', '', ''],
      address_value: ['', '', ''],
      selected: '',
wangyu authored
416
      requestdata: {},
wangyu authored
417 418 419
      placeholder: '请选择地址',
      onChange: 'onPickerSelect'
    },
wangyu authored
420 421 422 423
    firstpaybackDate: {
      label: '首次还款日期',
      bindtype: 'payback_date',
      selected: '',
wangyu authored
424
      isrequre: true,
wangyu authored
425 426 427 428 429 430
      isblack: 'true',
      values: ["是", "否"],
      placeholder: '请选择日期',
      onChange: 'onPickerSelect',
      mode: "date",
      fields: "day",
wangyu authored
431
      datelong: 0,
wangyu authored
432
    },
pangy authored
433 434 435 436 437 438 439 440 441 442 443 444 445
    firstpaybackDate_2: {
      label: '首次还款日期',
      bindtype: 'payback_date_2',
      selected: '',
      isrequre: true,
      isblack: 'true',
      values: ["是", "否"],
      placeholder: '请选择日期',
      onChange: 'onPickerSelect',
      mode: "date",
      fields: "day",
      datelong: 0,
    },
wangyu authored
446 447 448 449
    leasestartDate: {
      label: '租赁期起',
      bindtype: 'lease_start_date',
      selected: '',
wangyu authored
450
      isrequre: true,
wangyu authored
451 452 453 454 455 456
      isblack: 'true',
      values: ["是", "否"],
      placeholder: '请选择日期',
      onChange: 'onPickerSelect',
      mode: "date",
      fields: "day",
wangyu authored
457
      datelong: 0,
wangyu authored
458 459 460
    },
    leaseendDate: {
      label: '租赁期止',
wangyu authored
461
      bindtype: 'lease_end_date',
wangyu authored
462
      selected: '',
wangyu authored
463
      isrequre: true,
wangyu authored
464 465 466 467 468 469
      isblack: 'true',
      values: ["是", "否"],
      placeholder: '请选择日期',
      onChange: 'onPickerSelect',
      mode: "date",
      fields: "day",
wangyu authored
470
      datelong: 0,
wangyu authored
471 472 473 474 475
    },
    loandatelongData: {
      label: '贷款期限(月数)',
      bindtype: 'loan_datelong',
      selected: '',
wangyu authored
476
      isrequre: true,
wangyu authored
477 478 479 480 481
      isblack: 'true',
      values: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
      placeholder: '请选择贷款期限',
      onChange: 'onPickerSelect'
    },
wangyu authored
482
    schoolCountryData: {
483
      label: '就读国家(地区)',
wangyu authored
484
      bindtype: 'school_country',
485
      isrequre: true,
486
      selected: '',
487
      // isblack: 'true',
488
      values: [],
489
      placeholder: '请选择就读国家(地区)',
490 491
      onChange: 'onPickerSelect',
    },
492 493 494 495
    countryData: {
      label: '国籍',
      bindtype: 'country',
      isrequre: true,
pangy authored
496
      // disabled: true,
497
      selected: '',
498 499 500 501
      // range_key:'name',
      placeholder: '请选择国籍',
      onChange: 'onPickerSelect',
    },
pangy authored
502 503 504 505
    loverCountryData: {
      label: '国籍',
      bindtype: 'lover_country',
      // isrequre: true,
506
      selected: '',
pangy authored
507 508 509 510 511 512 513
      placeholder: '请选择国籍',
      onChange: 'onPickerSelect',
    },
    olderCountryData: {
      label: '被赡养人国籍',
      bindtype: 'older_country',
      isrequre: true,
514
      selected: '',
pangy authored
515 516 517
      placeholder: '请选择国籍',
      onChange: 'onPickerSelect',
    },
pangy authored
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537
    // bankInfo: {
    //   label: '公积金贷款银行',
    //   bindtype: 'bank',
    //   maxWidth: 400,
    //   isrequre: true,
    //   placeholder: '请选择贷款银行',
    //   selected: '',
    //   values: [],
    //   onChange: 'onPickerSelect'
    // },
    // bankInfo_2: {
    //   label: '商业贷款银行',
    //   bindtype: 'bank_2',
    //   maxWidth: 430,
    //   isrequre: true,
    //   placeholder: '请选择贷款银行',
    //   selected: '',
    //   values: [],
    //   onChange: 'onPickerSelect'
    // },
wangyu authored
538
    edu_lable: "school",
wangyu authored
539 540
    oldersupport_lable: "",
    img_path: "/images/upload_img.png"
wangyu authored
541 542 543 544 545
  },

  /**
   * Lifecycle function--Called when page load
   */
wangyu authored
546
  onLoad: function(options) {
547
    this.getCountry()
548
    this.getTaxHostInfo()
pangy authored
549 550 551
    var pages = getCurrentPages()
    var frontPage = pages[pages.length - 2]
    console.log('---------frontPage', frontPage.data)
wangyu authored
552
    console.log("options", options);
pangy authored
553
    const nameKey = options.status
pangy authored
554
    var title = AddTypeNames[nameKey]
pangy authored
555 556 557 558

    this.legal_entity_id = frontPage.data.legal_entity_id
    this.legal_entity = frontPage.data.legal_entity
pangy authored
559
    var reduce_typeData = this.data.reducetypeData
pangy authored
560
    var deduction_amount, house_type=''
wangyu authored
561
    if (options.reducetype == '月度') {
wangyu authored
562
      reduce_typeData.selected = '月度'
pangy authored
563
      //   deduction_amount = Deduce_amounts_month[nameKey] ? Deduce_amounts_month[nameKey] : 0
wangyu authored
564
    } else {
wangyu authored
565
      reduce_typeData.selected = '年度'
pangy authored
566
      //   deduction_amount = Deduce_amounts_year[nameKey] ? Deduce_amounts_year[nameKey] : 0
pangy authored
567
    }
568
    if ("children_education" == options.status) {
569 570 571
      if (options.isedit != 'true'){
        this.getTaxList()
      }
pangy authored
572 573 574 575
      this.data.taxperson_relativeData.values = ['子','女']
      this.setData({
        taxperson_relativeData: this.data.taxperson_relativeData
      })
576
    } else if ("continuing_education" == options.status) {
pangy authored
577
      this.getCertificates()
wangyu authored
578 579
      var studystart_date = this.data.studystartdate
      studystart_date.label = "入学时间起"
pangy authored
580
      var studyend_date = this.data.studyEndDate
wangyu authored
581
      studyend_date.label = "(预计)毕业时间"
pangy authored
582
      studyend_date.isrequre = true
wangyu authored
583 584
      this.setData({
        studystartdate: studystart_date,
pangy authored
585
        studyEndDate: studyend_date
wangyu authored
586
      })
587
    } else if ("medical_fund" == options.status) {
wangyu authored
588 589 590 591 592 593 594 595 596
      var cardtype_data = this.data.cardtypeData
      cardtype_data.label = "病人证照类型"
      var commonbirth_date = this.data.commonbirthDate
      commonbirth_date.label = "病人出生日期"

      this.setData({
        cardtypeData: cardtype_data,
        commonbirthDate: commonbirth_date
      })
pangy authored
597
    } else if ("support_duty" == options.status) {
598
      deduction_amount = parseFloat(frontPage.data.reduce_amount)
pangy authored
599
      this.supporttype = frontPage.data.issinglechildData.selected == '是' ? 'D' : 'S',//是否独生
600
      this.is_single = frontPage.data.issinglechildData.selected == '是' ? 'y' : 'n',//是否独生
pangy authored
601
      this.share_method = frontPage.data.shareMethodData.selected
pangy authored
602 603 604
      this.setData({
        deduction_amount: deduction_amount
      })
pangy authored
605
    } else if (frontPage.data.house_type == "rent" || frontPage.data.house_type == "house_fund_rent") { 
pangy authored
606
      // this.getbanklist()
607 608 609
      if (options.isedit != 'true') {
        this.getTaxList()
      }
pangy authored
610
      house_type = "house_fund_rent"
pangy authored
611
      title = '住房租金'
612 613
      if (options.reducetype == '月度') {
        reduce_typeData.selected = '月度'
pangy authored
614
        // deduction_amount = Deduce_amounts_month["house_fund_rent"]
615
      } else {
pangy authored
616
        // deduction_amount = Deduce_amounts_year["house_fund_rent"]
617 618 619
        reduce_typeData.selected = '年度'
      }
    } else if (frontPage.data.house_type == "house_fund_loan") {
pangy authored
620
      // this.getbanklist()
621 622 623
      if (options.isedit != 'true') {
        this.getTaxList()
      }
pangy authored
624
      house_type = "house_fund_loan"
pangy authored
625
      title = '住房贷款利息'
626 627 628 629 630 631 632
      if (options.reducetype == '月度') {
        reduce_typeData.selected = '月度'
        deduction_amount = Deduce_amounts_month["house_fund_loan"]
      } else {
        deduction_amount = Deduce_amounts_year["house_fund_loan"]
        reduce_typeData.selected = '年度'
      }
pangy authored
633 634 635
      this.setData({
        deduction_amount: deduction_amount
      })
wangyu authored
636
    }
pangy authored
637
pangy authored
638
    this.setData({
pangy authored
639 640
      title: title,
      cur_index: nameKey,
pangy authored
641
      house_type: house_type,
pangy authored
642 643
      reducetypeData: reduce_typeData,
    })
pangy authored
644 645 646
    wx.setNavigationBarTitle({
      title: title,
    })
wangyu authored
647
    this.initOSS()
648
    if (options.datas && options.datas.length > 0 && options.datas !="undefined") {
649 650 651 652 653 654 655
      if (options.isedit == 'true'){
        this.isEdit = true
        this.handlEditData(JSON.parse(options.datas))
      }else{
        this.isEdit = false
        this.handleTransData(JSON.parse(options.datas))
      }
pangy authored
656
    }
657
  },
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688

  getTaxHostInfo: function () {
    var that = this;
    var Authorization = app.globalData.Authorization;
    wx.request({
      url: baseUrl + 'persontax/v1/personal-taxes',
      method: "GET",
      header: {
        'content-type': 'application/json', // 默认值
        "Authorization": Authorization
      },
      data: {
        'all': true
      },
      success: function (res) {
        if (res.statusCode == 200) {
          var data = res.data
          if (data.items && data.items.length > 0) {
            for (var i = 0; i < data.items.length; i++) {
              if (data.items[i].family_ties == "本人") {
                app.globalData.hostInfo = data.items[i]
                break;
              }
            }
          }
        }
      }
    })
  },

pangy authored
689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706
  getTaxList: function () {
    var that = this;
    wx.showLoading({
      title: '加载中',
    })
    var Authorization = app.globalData.Authorization;
    console.log('Authorization', Authorization)
    if (!Authorization || Authorization.length < 10) {
      return
    }
    wx.request({
      url: baseUrl + 'persontax/v1/personal-taxes',
      method: "GET",
      header: {
        'content-type': 'application/json', // 默认值
        "Authorization": Authorization
      },
      data: {
pangy authored
707
        'type': '1'
pangy authored
708 709
      },
      success: function (res) {
pangy authored
710
        console.log('是否有配偶接口数据', res)
pangy authored
711
        if (res.data.items && res.data.items[0]) {
pangy authored
712 713
          var hasLoverData = that.data.hasLoverData
          hasLoverData.selected = '是'
714
          hasLoverData.disabled = true
pangy authored
715
          var data = res.data.items[0], setData = { hasGetLover:true, hasLover: true, hasLoverData: hasLoverData}
pangy authored
716 717 718
          if (data.name && data.name.length) {
            setData.spouse_name = data.name
          }
pangy authored
719
          that.dealCardType(data.id_card_type, 'lovercardtype')
720 721
          that.data.lovercardtypeData.selected = data.id_card_type
          setData.lovercardtypeData = that.data.lovercardtypeData
pangy authored
722 723
          if (data.id_card_no && data.id_card_no.length) {
            setData.spouse_id_card_no = data.id_card_no
724 725 726
            if ('居民身份证' == data.id_card_type) {
              that.dealIdInfo(data.id_card_no, 'spouse_id_card_no_input')
            }
pangy authored
727
          }
728
          that.data.loverbirthDate.selected = data.birth_date_str//format.formatTime_date(data.birth_date)
729 730
          that.data.loverbirthDate.datelong = data.birth_date
          setData.loverbirthDate = that.data.loverbirthDate
pangy authored
731
          that.data.loverCountryData.selected = data.native
pangy authored
732
          // that.data.loverCountryData.disabled = true
pangy authored
733
          setData.loverCountryData = that.data.loverCountryData
pangy authored
734 735 736 737 738 739 740 741 742 743 744 745 746 747
          that.setData(setData)
        }
      },
      fail(res) {
        console.log(res.data)
      },
      complete() {
        wx.hideLoading()
        that.setData({
          load_finish: true
        })
      }
    })
  },
748 749 750 751 752 753 754 755 756 757 758 759 760 761
  // loadCountry: function() {
  //   countryInfo.init(this)
  //   var countrylist = this.data.country
  //   var country_data = this.data.schoolCountryData
  //   for (var i = 0; i < countrylist.length; i++) {
  //     country_data.values.push(countrylist[i].name)
  //   }
  //   console.log("countrydata", country_data)
  //   this.setData({
  //     schoolCountryData: country_data
  //   })
  // },

  //****************获取国籍数据************/
762
  getCountry: function (cb) {
763 764
    var that = this
    wx.showLoading()
765 766 767 768 769 770
    if (that.countrys && that.countrys.length > 0) {
      typeof cb == "function" && cb(that.countrys)
      console.log('----直接取值')
      wx.hideLoading()
      return
    }
771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798
    var Authorization = app.globalData.Authorization;
    wx.request({
      url: baseUrl + 'persontax/v1/nation-list',
      method: "GET",
      header: {
        'content-type': 'application/json', // 默认值
        "Authorization": Authorization
      },
      success: function (res) {
        var countrys = res.data.concat()
        if (countrys.indexOf('中国') > -1) {
          countrys.splice(countrys.indexOf('中国'), 1);
        }
        if (countrys.indexOf('中国台湾') > -1) {
          countrys.splice(countrys.indexOf('中国台湾'), 1);
        }
        if (countrys.indexOf('香港') > -1) {
          countrys.splice(countrys.indexOf('香港'), 1);
        }
        if (countrys.indexOf('澳门') > -1) {
          countrys.splice(countrys.indexOf('澳门'), 1);
        }
        // that.data.countryData.values = countrys
        that.data.schoolCountryData.values = res.data
        that.countrys = countrys
        that.setData({
          schoolCountryData: that.data.schoolCountryData
        })
799
        typeof cb == "function" && cb(countrys)
800 801 802 803
      },
      complete() {
        wx.hideLoading()
      }
804
    })
wangyu authored
805
  },
806 807 808 809 810 811
  handlEditData: function (data) {

    this.edit_id = data.id
    console.log('data===', data)
    switch (this.data.cur_index + '') {
      case 'children_education':
pangy authored
812
        this.dealCardType(data.children_id_card_type, 'childrencardtype')//为防止干扰其他字段,需要先执行
pangy authored
813 814
        var studystartdate = this.data.studystartdate
        var schoolCountryData = this.data.schoolCountryData
815 816
        if (data.education_period.indexOf('学前') > -1){
          studystartdate.disabled = true
pangy authored
817 818 819 820
          schoolCountryData.isrequre = false
          this.setData({
            child_edu_pre: true
          })
821
        }
822
        var setData = {}
pangy authored
823
        this.data.countryData.selected = data.children_nation
824
        setData.countryData = this.data.countryData
pangy authored
825 826 827 828
        if (data.relationship && data.relationship.length) {
          this.data.taxperson_relativeData.selected = data.relationship
          setData.taxperson_relativeData = this.data.taxperson_relativeData
        }
829
        var commonbirthDate = this.data.commonbirthDate
830 831
        commonbirthDate.selected = format.formatTime_date(data.children_birthday)
        commonbirthDate.datelong = data.children_birthday
832 833 834 835
        setData.commonbirthDate = commonbirthDate
        var childrenpercentData = this.data.childrenpercentData
        childrenpercentData.selected = data.percent + '%'
        setData.childrenpercentData = childrenpercentData
836
pangy authored
837
        studystartdate.selected = format.formatTime_month(data.education_start)
838 839
        studystartdate.datelong = data.education_start
        setData.studystartdate = studystartdate
pangy authored
840
        var studyEndDate = this.data.studyEndDate
841
        var studyPeriodDate = this.data.studyPeriodDate
pangy authored
842 843 844 845
        if (data.education_end > 0) {
          studyEndDate.selected = format.formatTime_month(data.education_end)
          studyEndDate.datelong = data.education_end
        }
pangy authored
846 847 848 849
        if (data.education_period_end > 0){
          studyPeriodDate.selected = format.formatTime_month(data.education_period_end)
          studyPeriodDate.datelong = data.education_period_end
        }
850 851 852 853 854 855 856 857 858
        var start = studystartdate.selected, select_year = 0
        if (start.length > 4) {
          select_year = start.substring(0, 4)
        } 
        if (select_year < 2019) {
          start = '2019-01'
        }
        studyEndDate.start = start
        studyPeriodDate.start = start
pangy authored
859
        studyPeriodDate.end = studyEndDate.selected
860
        setData.studyEndDate = studyEndDate
pangy authored
861
        setData.studyPeriodDate = studyPeriodDate
862 863 864
        setData.deduction_amount = data.deduction_amount
        if (data.children_id_card_no && data.children_id_card_no.length) {
          setData.children_id_card_no = data.children_id_card_no
pangy authored
865
          if ('居民身份证' == data.children_id_card_type) {
866 867
            this.dealIdInfo(data.children_id_card_no, 'children_id_card_no_input')
          }
868 869 870 871
        }
        if (data.children_name && data.children_name.length) {
          setData.children_name = data.children_name
        }
pangy authored
872 873 874
        // if (data.student_no && data.student_no.length) {
        //   setData.children_student_no = data.student_no
        // }
875 876 877 878 879 880 881 882
        if (data.education_period && data.education_period.length) {
          var childedudegreeData = this.data.childedudegreeData
          childedudegreeData.selected = data.education_period
          setData.childedudegreeData = childedudegreeData
        }
        if (data.school_country && data.school_country.length) {
          schoolCountryData.selected = data.school_country
        }
pangy authored
883 884
        setData.schoolCountryData = schoolCountryData
885 886 887
        if (data.school_name && data.school_name.length) {
          setData.school_name = data.school_name
        }
888 889 890

        var hasLoverData = this.data.hasLoverData
        hasLoverData.selected = data.has_spouse == 'y' ? '是' : '否'
891
        hasLoverData.disabled = data.has_spouse == 'y' ? true : false
892
        setData.hasLover = data.has_spouse == 'y' ? true : false
pangy authored
893
        setData.hasGetLover = data.has_spouse == 'y' ? true : false
894
        setData.hasLoverData = hasLoverData
895 896 897
        if (data.spouse_name && data.spouse_name.length) {
          setData.spouse_name = data.spouse_name
        }
pangy authored
898
        this.dealCardType(data.spouse_id_card_type, 'lovercardtype')
899 900
        if (data.spouse_id_card_no && data.spouse_id_card_no.length) {
          setData.spouse_id_card_no = data.spouse_id_card_no
pangy authored
901
          if ('居民身份证' == data.spouse_id_card_type) {
902 903
            this.dealIdInfo(data.spouse_id_card_no, 'spouse_id_card_no_input')
          }
904
        }
pangy authored
905 906 907 908 909 910
        var loverbirthDate = this.data.loverbirthDate
        loverbirthDate.selected = format.formatTime_date(data.spouse_birthday)
        loverbirthDate.datelong = data.spouse_birthday
        setData.loverbirthDate = loverbirthDate
        this.data.loverCountryData.selected = data.nation
        setData.loverCountryData = this.data.loverCountryData
911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927
        this.setData(setData)
        break;
      case 'continuing_education':
        var setData = {}
        if (data.education_type && data.education_type.length) {
          if ('title' == data.education_type) {
            setData.edu_lable = 'school'
            var edutypeData = this.data.edutypeData
            edutypeData.selected = "学历(学位)继续教育"
            setData.edutypeData = edutypeData

            if (data.education_period && data.education_period.length) {
              var edulevelData = this.data.edulevelData
              edulevelData.selected = data.education_period
              setData.edulevelData = edulevelData
            }
            var studystartdate = this.data.studystartdate
pangy authored
928
            studystartdate.selected = format.formatTime_month(data.education_start)
929 930
            studystartdate.datelong = data.education_start
            setData.studystartdate = studystartdate
pangy authored
931 932 933 934
            var studyEndDate = this.data.studyEndDate
            studyEndDate.selected = format.formatTime_month(data.education_end)
            studyEndDate.datelong = data.education_end
            setData.studyEndDate = studyEndDate
935 936 937 938 939 940

          } else {
            setData.edu_lable = 'tech'
            var edutypeData = this.data.edutypeData
            edutypeData.selected = "职业资格继续教育"
            var edustyleData = this.data.edustyleData
pangy authored
941
            var certificateDate = this.data.certificateDate
942 943
            if (data.education_type == 'major'){
              edustyleData.selected = "专业技术人员职业资格"
pangy authored
944
              // certificateDate.values = this.major_cers //  网络延迟
945 946
            } else if (data.education_type == 'profession'){
              edustyleData.selected = "技能人员职业资格"
pangy authored
947
              // certificateDate.values = this.profs_cers //  网络延迟
948 949 950 951 952 953 954 955 956
            }
            setData.edutypeData = edutypeData
            setData.edustyleData = edustyleData
            var applydate = this.data.applydate
            applydate.selected = format.formatTime_date(data.approval_date)
            applydate.datelong = data.approval_date
            setData.applydate = applydate
            
            if (data.certification_name && data.certification_name.length) {
pangy authored
957 958
              certificateDate.selected = data.certification_name
              setData.certificateDate = certificateDate
959 960 961 962 963 964 965 966 967 968 969 970
            }
            if (data.certification_no && data.certification_no.length) {
              setData.certification_no = data.certification_no
            }
            if (data.certification_authority && data.certification_authority.length) {
              setData.certification_authority = data.certification_authority
            }
          }
        }
        this.setData(setData)
        break;
      case 'support_duty':
pangy authored
971
        this.dealCardType(data.id_card_type, 'oldercardtype')//为防止干扰其他字段,需要先执行
972 973
        var setData = {}
        var olderbirthDate = this.data.olderbirthDate
974 975
        olderbirthDate.selected = format.formatTime_date(data.birthday)
        olderbirthDate.datelong = data.birthday
976
        setData.olderbirthDate = olderbirthDate
977 978
        this.data.olderCountryData.selected = data.nation
        setData.olderCountryData = this.data.olderCountryData
979 980 981 982 983
        if (data.supported_name && data.supported_name.length) {
          setData.supported_name = data.supported_name
        }
        if (data.id_card_no && data.id_card_no.length) {
          setData.id_card_no = data.id_card_no
984 985 986
          if ('居民身份证' == data.id_card_type) {
            this.dealIdInfo(data.id_card_no, 'older_id_card_no_input')
          }
987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020
        }
        if (data.relationship && data.relationship.length) {
          var older_relativeData = this.data.older_relativeData
          older_relativeData.selected = data.relationship
          setData.older_relativeData = older_relativeData
        }
        this.is_single = data.is_single
        this.supporttype = data.is_single=='y'? 'D': 'S'
        this.share_method = data.share_method
        this.setData(setData)
        break;
        
      // case 'medical_fund':
      //   var setData = {}
      //   var commonbirthDate = this.data.commonbirthDate
      //   commonbirthDate.selected = format.formatTime_date(data.patient_birthday)
      //   commonbirthDate.datelong = data.patient_birthday
      //   setData.commonbirthDate = commonbirthDate
      //   if (data.name && data.name.length) {
      //     setData.name = data.name
      //   }
      //   if (data.id_card_no && data.id_card_no.length) {
      //     setData.id_card_no = data.id_card_no
      //     this.dealIdInfo(data.id_card_no, 'medical_id_card_no_input')
      //   }
      //   if (data.family_ties && data.family_ties.length) {
      //     var taxperson_relativeData = this.data.taxperson_relativeData
      //     taxperson_relativeData.selected = data.family_ties
      //     setData.taxperson_relativeData = taxperson_relativeData
      //   }
      //   this.setData(setData)
      //   break;
      case "house_fund":
        var setData = {}
1021 1022
        var hasLoverData = this.data.hasLoverData
        hasLoverData.selected = data.has_spouse == 'y'?'是':'否'
pangy authored
1023
        hasLoverData.disabled = data.has_spouse == 'y' ? true : false
1024
        setData.hasLover = data.has_spouse=='y'?true:false
pangy authored
1025
        setData.hasGetLover = data.has_spouse == 'y' ? true : false
1026 1027 1028 1029
        setData.hasLoverData = hasLoverData
        if (data.spouse_name && data.spouse_name.length) {
          setData.spouse_name = data.spouse_name
        }
1030
        this.dealCardType(data.id_card_type, 'lovercardtype')
pangy authored
1031 1032
        var loverbirthDate = this.data.loverbirthDate
        loverbirthDate.selected = format.formatTime_date(data.birthday)//(data.spouse_birthday)
1033
        loverbirthDate.datelong = data.birthday
pangy authored
1034 1035 1036
        setData.loverbirthDate = loverbirthDate
        this.data.loverCountryData.selected = data.nation
        setData.loverCountryData = this.data.loverCountryData
1037 1038
        if (data.id_card_no && data.id_card_no.length) {
          setData.spouse_id_card_no = data.id_card_no
1039 1040 1041
          if ('居民身份证' == data.id_card_type) {
            this.dealIdInfo(data.id_card_no, 'spouse_id_card_no_input')
          }
1042
        }
pangy authored
1043
        if (this.data.house_type == 'house_fund_rent'){
1044
          this.dealCardType(data.owner_id_card_type, 'ownercardtype')//为防止干扰其他字段,需要先执行
pangy authored
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060
          var workingcityInfo = this.data.workingcityInfo
          workingcityInfo.requestdata = data.work_city
          workingcityInfo.selected = data.work_city.province + data.work_city.city
          workingcityInfo.address_value = [data.work_city.province, data.work_city.city, data.work_city.district]
          workingcityInfo.address_code = [data.work_city.province_code, data.work_city.city_code, data.work_city.district_code]
          setData.workingcityInfo = workingcityInfo
          this.getCityLevel({
            'province_code': workingcityInfo.address_code[0],
            'province': workingcityInfo.address_value[0],
            'city_code': workingcityInfo.address_code[1],
            'city': workingcityInfo.address_value[1],
            'district_code': workingcityInfo.address_code[2],
            'district': workingcityInfo.address_value[2]
          })
          var leasetype_Data = this.data.leasetypeData
          leasetype_Data.selected = data.owner_type
pangy authored
1061
          this.data.cardtypeData.hidden = data.owner_type == "组织"
pangy authored
1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074
          setData.leasetypeData = leasetype_Data,
          setData.cardtypeData = this.data.cardtypeData
          setData.owner_name = data.owner_name
          setData.owner_credit_no = data.owner_credit_no

          if (data.house_address && data.house_address.province) {
            var rentLocateInfo = this.data.rentLocateInfo
            rentLocateInfo.requestdata = data.house_address
            rentLocateInfo.selected = data.house_address.province + data.house_address.city + data.house_address.district
            rentLocateInfo.address_value = [data.house_address.province, data.house_address.city, data.house_address.district]
            rentLocateInfo.address_code = [data.house_address.province_code, data.house_address.city_code, data.house_address.district_code]
            setData.rentLocateInfo = rentLocateInfo
          }
1075 1076
          setData.house_detail_address = data.house_detail_address
          setData.rent_contract_no = data.rent_contract_no
pangy authored
1077
1078 1079 1080 1081 1082 1083 1084 1085
          var leasestartDate = this.data.leasestartDate
          leasestartDate.selected = format.formatTime_date(data.rent_start)
          leasestartDate.datelong = data.rent_start
          setData.leasestartDate = leasestartDate
          var leaseendDate = this.data.leaseendDate
          leaseendDate.selected = format.formatTime_date(data.rent_end)
          leaseendDate.datelong = data.rent_end
          setData.leaseendDate = leaseendDate
pangy authored
1086 1087 1088
          setData.owner_id_card_no = data.owner_id_card_no

        } else if (this.data.house_type == 'house_fund_loan'){
1089 1090
          this.handleHasLover(data.has_spouse == 'y')
pangy authored
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112
          if (data.house_address && data.house_address.province) {
            var houseLocateInfo = this.data.houseLocateInfo
            houseLocateInfo.requestdata = data.house_address
            houseLocateInfo.selected = data.house_address.province + data.house_address.city + data.house_address.district
            houseLocateInfo.address_value = [data.house_address.province, data.house_address.city, data.house_address.district]
            houseLocateInfo.address_code = [data.house_address.province_code, data.house_address.city_code, data.house_address.district_code]
            setData.houseLocateInfo = houseLocateInfo
          }
          if (data.house_detail_address && data.house_detail_address.length) {
            setData.house_detail_address = data.house_detail_address
          }
          if (data.certification_type && data.certification_type.length) {
            var identifytypeData = this.data.identifytypeData
            identifytypeData.selected = data.certification_type
            setData.identifytypeData = identifytypeData
          }
          if (data.certification_no && data.certification_no.length) {
            setData.certification_no = data.certification_no
          }
          if (data.loan_before_marry && data.loan_before_marry.length) {
            var beforemarryData = this.data.beforemarryData
            beforemarryData.selected = data.loan_before_marry=='y'?'是':'否'
pangy authored
1113
            if (!this.data.hasLover){//健壮(有配偶时不需要设置)
pangy authored
1114 1115
              this.handleBeforemarry(data.loan_before_marry == 'y')
            }
pangy authored
1116 1117 1118 1119 1120 1121 1122
            setData.beforemarryData = beforemarryData
          }
          if (data.loan_by_self && data.loan_by_self.length) {
            var isselfData = this.data.isselfData
            isselfData.selected = data.loan_by_self == 'y' ? '是' : '否'
            setData.isselfData = isselfData
          }
1123
pangy authored
1124 1125 1126 1127 1128 1129 1130 1131 1132
          if (data.loan_type && data.loan_type.length) {
            var loantypeData = this.data.loantypeData
            loantypeData.selected = data.loan_type
            setData.loantypeData = loantypeData
          }
          if (data.loan_contract_no && data.loan_contract_no.length) {
            setData.loan_contract_no = data.loan_contract_no
          }
          if (data.loan_bank && data.loan_bank.length) {
pangy authored
1133 1134 1135
            // var bank_data = this.data.bankInfo
            // bank_data.selected = data.loan_bank
            setData.loan_bank = data.loan_bank
pangy authored
1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147
          }
          var firstpayback_Date = this.data.firstpaybackDate
          firstpayback_Date.selected = format.formatTime_date(data.loan_start)
            firstpayback_Date.datelong = data.loan_start 
          setData.firstpaybackDate = firstpayback_Date
          if (data.loan_months>0){
            setData.loan_months = data.loan_months
          }
          if (data.sec_loan_contract_no && data.sec_loan_contract_no.length) {
            setData.sec_loan_contract_no = data.sec_loan_contract_no
          }
          if (data.sec_loan_bank && data.sec_loan_bank.length) {
pangy authored
1148 1149 1150 1151
            // var bank_data = this.data.bankInfo_2
            // bank_data.selected = data.sec_loan_bank
            // setData.bankInfo_2 = bank_data
            setData.sec_loan_bank = data.sec_loan_bank
pangy authored
1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163
          }
          var firstpaybackDate_2 = this.data.firstpaybackDate_2
          firstpaybackDate_2.selected = format.formatTime_date(data.sec_loan_start)
          firstpaybackDate_2.datelong = data.sec_loan_start
          setData.firstpaybackDate_2 = firstpaybackDate_2
          if (data.sec_loan_months > 0) {
            setData.sec_loan_months = data.sec_loan_months
          }
          if (data.rent_contract_no && data.rent_contract_no.length) {
            setData.rent_contract_no = data.rent_contract_no
          }
        }
1164 1165 1166 1167 1168
        this.setData(setData)
        break;
    }

  },
pangy authored
1169
wangyu authored
1170
  handleTransData: function(data) {
pangy authored
1171
    console.log('data==',data)
pangy authored
1172 1173
    switch (this.data.cur_index + '') {
      case 'children_education':
pangy authored
1174
        this.dealCardType(data.id_card_type, 'childrencardtype')//为防止干扰其他字段,需要先执行
pangy authored
1175
        var setData = {}
1176 1177
        this.data.countryData.selected = data.native
        setData.countryData = this.data.countryData
1178
        var commonbirthDate = this.data.commonbirthDate
1179
        commonbirthDate.selected = data.birth_date_str//format.formatTime_date(data.birth_date)
1180 1181
        commonbirthDate.datelong = data.birth_date
        setData.commonbirthDate = commonbirthDate
pangy authored
1182 1183
        if (data.id_card_no && data.id_card_no.length) {
          setData.children_id_card_no = data.id_card_no
1184 1185 1186
          if ('居民身份证' == data.id_card_type) {
            this.dealIdInfo(data.id_card_no, 'children_id_card_no_input')
          }
pangy authored
1187 1188 1189 1190
        }
        if (data.name && data.name.length) {
          setData.children_name = data.name
        }
pangy authored
1191 1192 1193 1194 1195
        if (data.family_ties && data.family_ties.length) {
          var taxperson_relativeData = this.data.taxperson_relativeData
          taxperson_relativeData.selected = data.family_ties
          setData.taxperson_relativeData = taxperson_relativeData
        }
1196 1197 1198
        this.setData(setData)
        break;
      case 'support_duty':
pangy authored
1199
        this.dealCardType(data.id_card_type, 'oldercardtype')//为防止干扰其他字段,需要先执行
1200
        var setData = {}
1201
        var olderbirthDate = this.data.olderbirthDate
1202
        olderbirthDate.selected = data.birth_date_str//format.formatTime_date(data.birth_date)
1203 1204
        olderbirthDate.datelong = data.birth_date
        setData.olderbirthDate = olderbirthDate
1205 1206
        this.data.olderCountryData.selected = data.native
        setData.olderCountryData = this.data.olderCountryData
pangy authored
1207 1208
        if (data.name && data.name.length) {
          setData.supported_name = data.name
1209 1210 1211
        }
        if (data.id_card_no && data.id_card_no.length) {
          setData.id_card_no = data.id_card_no
1212 1213 1214
          if ('居民身份证' == data.id_card_type) {
            this.dealIdInfo(data.id_card_no, 'older_id_card_no_input')
          }
1215
        }
1216 1217 1218 1219 1220
        if (data.family_ties && data.family_ties.length) {
          var older_relativeData = this.data.older_relativeData
          older_relativeData.selected = data.family_ties
          setData.older_relativeData = older_relativeData
        }
pangy authored
1221
        this.setData(setData)
wangyu authored
1222
        break;
pangy authored
1223 1224
      case 'medical_fund':
        var setData = {}
1225 1226 1227 1228
        var commonbirthDate = this.data.commonbirthDate
        commonbirthDate.selected = format.formatTime_date(data.patient_birthday)
        commonbirthDate.datelong = data.patient_birthday
        setData.commonbirthDate = commonbirthDate
pangy authored
1229 1230 1231 1232 1233
        if (data.name && data.name.length) {
          setData.name = data.name
        }
        if (data.id_card_no && data.id_card_no.length) {
          setData.id_card_no = data.id_card_no
1234 1235 1236
          if ('居民身份证' == data.id_card_type) {
            this.dealIdInfo(data.id_card_no, 'medical_id_card_no_input')
          }
pangy authored
1237 1238 1239 1240 1241 1242 1243 1244
        }
        if (data.family_ties && data.family_ties.length) {
          var taxperson_relativeData = this.data.taxperson_relativeData
          taxperson_relativeData.selected = data.family_ties
          setData.taxperson_relativeData = taxperson_relativeData
        }
        this.setData(setData)
        break;
pangy authored
1245
      
pangy authored
1246 1247 1248 1249 1250 1251 1252
    }

  },



wangyu authored
1253
  initOSS: function() {
wangyu authored
1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269
    var that = this
    var Authorization = getApp().globalData.Authorization;
    //OSS 上传前init
    wx.showLoading()
    wx.request({
      url: baseUrl + "filemeta/v1/inits",
      header: {
        'Authorization': Authorization
      },
      method: 'POST',
      data: {
        "access_type": "web_upload",
        "action ": "put_object",
        "instance_id": "",
        "object_type": "wx_image"
      },
wangyu authored
1270
      success: function(result) {
wangyu authored
1271 1272 1273 1274

        OSSInit = result.data
        console.log(' OSS init 成功', OSSInit)
      },
wangyu authored
1275
      fail: function(res) {
wangyu authored
1276 1277
        console.log('OSS init  失败', res)
      },
wangyu authored
1278
      complete: function() {
wangyu authored
1279 1280 1281
        wx.hideLoading()
      }
    })
wangyu authored
1282 1283 1284 1285 1286
  },

  /**
   * Lifecycle function--Called when page is initially rendered
   */
wangyu authored
1287
  onReady: function() {
wangyu authored
1288 1289 1290

  },
wangyu authored
1291
  onShow: function() {
pangy authored
1292 1293 1294 1295
    var that = this
    var id_error //= this.data.id_error
    wx.getStorage({
      key: 'id_info',
wangyu authored
1296
      success: function(res) {
pangy authored
1297 1298 1299
        console.log('id_info', res.data)
        if (res.data && res.data.length > 0) {
          var id_info = JSON.parse(res.data)
pangy authored
1300
          var birth_day, data={}
pangy authored
1301 1302 1303 1304 1305 1306 1307 1308
          if (id_info.birthday.month > 9 && id_info.birthday.day > 9) {
            birth_day = id_info.birthday.year + '-' + id_info.birthday.month + '-' + id_info.birthday.day;
          } else if (id_info.birthday.month > 9 && id_info.birthday.day < 10) {
            birth_day = id_info.birthday.year + '-' + id_info.birthday.month + '-0' + id_info.birthday.day;
          } else if (id_info.birthday.month < 10 && id_info.birthday.day > 9) {
            birth_day = id_info.birthday.year + '-0' + id_info.birthday.month + '-' + id_info.birthday.day;
          } else if (id_info.birthday.month < 10 && id_info.birthday.day < 10) {
            birth_day = id_info.birthday.year + '-0' + id_info.birthday.month + '-0' + id_info.birthday.day;
wangyu authored
1309
          }
pangy authored
1310
pangy authored
1311 1312 1313
          if (that.idcard_belong == 'children_id_card_no') {
            that.data.commonbirthDate.selected = birth_day
            that.data.commonbirthDate.datelong = (Date.parse(new Date(birth_day)) / 1000)
pangy authored
1314 1315 1316
            data = {
              children_id_card_no: id_info.id_card_number,
              children_name: id_info.name,
pangy authored
1317
              commonbirthDate: that.data.commonbirthDate
pangy authored
1318
            }
pangy authored
1319
            that.dealBrithDate(id_info.birthDay)//根据出生日期 计算 学前受教育时间
1320
            if (format.getAge(birth_day) < 3) {
pangy authored
1321
              that.showToast('子女年龄小于3岁,不可申报')
1322
            }
pangy authored
1323 1324 1325
          } else if (that.idcard_belong == 'spouse_id_card_no') {
            that.data.loverbirthDate.selected = birth_day
            that.data.loverbirthDate.datelong = (Date.parse(new Date(birth_day)) / 1000)
pangy authored
1326 1327 1328
            data = {
              spouse_id_card_no: id_info.id_card_number,
              spouse_name: id_info.name,
pangy authored
1329
              loverbirthDate: that.data.loverbirthDate
pangy authored
1330
            }
pangy authored
1331 1332 1333
          } else if (that.idcard_belong == 'older_id_card_no') {
            that.data.olderbirthDate.selected = birth_day
            that.data.olderbirthDate.datelong = (Date.parse(new Date(birth_day)) / 1000)
1334 1335 1336
            data = {
              id_card_no: id_info.id_card_number,
              supported_name: id_info.name,
pangy authored
1337
              olderbirthDate: that.data.olderbirthDate
1338
            }
1339
            if (format.getAge(birth_day) < 60) {
pangy authored
1340
              that.showToast('被赡养人年龄不足60岁,不可申报')
1341
            }
pangy authored
1342 1343 1344
          } else if (that.idcard_belong == 'medical_id_card_no') {
            that.data.commonbirthDate.selected = birth_day
            that.data.commonbirthDate.datelong = (Date.parse(new Date(birth_day)) / 1000)
1345
            data = {
pangy authored
1346
              id_card_no: id_info.id_card_number,
pangy authored
1347
              commonbirthDate: that.data.commonbirthDate
1348
            }
1349 1350 1351 1352 1353 1354
          } else if (that.idcard_belong == 'owner_id_card_no') {
            console.log('id_info.id_card_number', id_info.id_card_number)
            data = {
              owner_id_card_no: id_info.id_card_number,
              owner_name: id_info.name
            }
pangy authored
1355
          }
pangy authored
1356
          that.setData(data)
pangy authored
1357
          console.log('-cardtypeData--', that.data.cardtypeData)
wangyu authored
1358
pangy authored
1359 1360 1361 1362 1363
        }
      },
    })
    wx.removeStorage({
      key: 'id_info',
wangyu authored
1364
      success: function(res) {
pangy authored
1365 1366 1367
        console.log('remove_idinfo', res)
      },
    })
wangyu authored
1368 1369
  },
pangy authored
1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399
  // getbanklist: function() {
  //   var that = this
  //   var Authorization = app.globalData.Authorization;
  //   var bank_info = that.data.bankInfo
  //   var bank_info_2 = that.data.bankInfo_2
  //   wx.request({
  //     url: baseUrl + 'persontax/v1/bank-list',
  //     method: "GET",
  //     header: {
  //       'content-type': 'application/json', // 默认值
  //       "Authorization": Authorization
  //     },
  //     success: function(res) {
  //       console.log(res)
  //       bank_info.values = res.data.banks//that.handleBankinfo(res.data.items)
  //       bank_info_2.values = res.data.banks//that.handleBankinfo(res.data.items)
  //       that.setData({
  //         bankInfo: bank_info,
  //         bankInfo_2: bank_info_2
  //       })
  //       console.log("bankInfo", that.data.bankInfo)
  //     },
  //     fail(res) {
  //       console.log(res)
  //     },
  //     complete() {
  //       wx.hideLoading()
  //     }
  //   })
  // },
pangy authored
1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413
  getCertificates: function () {
    var that = this
    var Authorization = app.globalData.Authorization;
    var bank_info = that.data.bankInfo
    wx.request({
      url: baseUrl + 'persontax/v1/certification-list' ,
      header: {
        'content-type': 'application/json', // 默认值
        "Authorization": Authorization
      },
      success: function (res) {
        console.log('certification', res)
        that.profs_cers = res.data.profession_certificates
        that.major_cers = res.data.major_certificates
pangy authored
1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424

        var certificateDate = that.data.certificateDate
        if (that.data.edustyleData.selected == "专业技术人员职业资格"){
          certificateDate.values = that.major_cers 
        } else if (that.data.edustyleData.selected == '技能人员职业资格') {
          certificateDate.values = that.profs_cers
        }
        that.setData({
          certificateDate: certificateDate
        })
pangy authored
1425 1426 1427 1428 1429 1430 1431 1432 1433
      },
      fail(res) {
        console.log(res)
      },
      complete() {
        wx.hideLoading()
      }
    })
  },
pangy authored
1434 1435 1436 1437 1438 1439 1440
  // handleBankinfo: function(data) {
  //   var bank_name = []
  //   for (var i = 0; i < data.length; i++) {
  //     bank_name.push(data[i].bank_name)
  //   }
  //   return bank_name
  // },
1441
pangy authored
1442
wangyu authored
1443 1444 1445 1446
  formSubmit: function(e) {
    console.log("formSubmit", e);
    var formdata = e.detail.value
    var newdata = formdata;
pangy authored
1447
    var subUrl = ''
wangyu authored
1448
    switch (this.data.cur_index + '') {
pangy authored
1449
      case 'children_education':
pangy authored
1450
        subUrl = 'persontax/v1/children-educations'
1451 1452 1453 1454
        if (this.data.childrencardtypeData.selected.length < 1) {
          this.showToast('请选择证照类型')
          return
        }
pangy authored
1455
        if (!formdata.children_id_card_no || formdata.children_id_card_no.length < 1) {
wangyu authored
1456
          this.showToast('请填写子女证照号码')
wangyu authored
1457
          return
wangyu authored
1458
        }
pangy authored
1459
        if (this.data.isIdCard_child && !format.isIDCardNum(formdata.children_id_card_no)) {
pangy authored
1460 1461 1462 1463 1464 1465 1466 1467 1468
          this.showToast('子女证照号码有误')
          return
        } 
        if (this.data.childrencardtypeData.selected.indexOf('居住证') > -1 && !reg_18_Number.test(formdata.children_id_card_no)) {
          this.showToast('子女证照号码有误');
          return
        } 
        if (this.data.childrencardtypeData.selected.indexOf('中国护照') > -1 && !reg_9_n_a.test(formdata.children_id_card_no)) {
          this.showToast('子女证照号码有误');
1469 1470
          return
        }
1471 1472
        if (format.getAge(this.data.commonbirthDate.selected) < 3) {
          this.showToast('子女年龄小于3岁,不可申报')
wangyu authored
1473 1474
          return
        }
1475 1476 1477 1478
        if (this.data.commonbirthDate.datelong < app.globalData.hostInfo.birth_date) {
          this.showToast('子女年龄不得大于本人');
          return
        }
1479 1480
        if (!formdata.children_name || formdata.children_name.length < 1) {
          this.showToast('请填写子女姓名')
wangyu authored
1481 1482
          return
        }
1483 1484 1485 1486 1487 1488 1489 1490
        if (this.data.commonbirthDate.selected.length < 1) {
          this.showToast('请选择子女出生日期')
          return
        }
        if (this.data.countryData.selected.length < 1) {
          this.showToast('请选择国籍')
          return
        }
pangy authored
1491 1492 1493 1494
        if (this.data.taxperson_relativeData.selected.length < 1) {
          this.showToast('请选择与纳税人关系')
          return
        }
wangyu authored
1495 1496
        if (this.data.childrenpercentData.selected.length < 1) {
          this.showToast('请选择分配比例')
wangyu authored
1497 1498
          return
        }
pangy authored
1499 1500 1501 1502
        // if (!formdata.children_student_no || formdata.children_student_no.length < 1) {
        //   this.showToast('请填写学籍号')
        //   return
        // }
pangy authored
1503 1504
        if (this.data.childedudegreeData.selected.length < 1) {
          this.showToast('请选择教育阶段')
wangyu authored
1505 1506 1507
          return
        }
        if (this.data.studystartdate.selected.length < 1) {
pangy authored
1508
          this.showToast('请选择受教育起始日期')
wangyu authored
1509 1510
          return
        }
pangy authored
1511
        if (this.data.studyEndDate.selected.length < 1) {
1512 1513
          // this.showToast('请选择受教育时间止')
          // return
1514
        }else{
pangy authored
1515 1516 1517 1518 1519 1520 1521 1522 1523
          var activedDate = (Date.parse(new Date('2019-01-01')) / 1000)
          if (this.data.studyEndDate.datelong < activedDate) {
            this.showToast('受教育时间止不符合要求,无法申报')
            return
          }
          if (this.data.studyPeriodDate.selected.length > 0 && this.data.studyPeriodDate.datelong < activedDate) {
            this.showToast('教育终止时间不符合要求,无法申报')
            return
          }
wangyu authored
1524
        }
1525 1526 1527 1528 1529 1530 1531 1532 1533
        if (!this.data.child_edu_pre){
          if (this.data.schoolCountryData.selected.length < 1) {
            this.showToast('请选择就读国家')
            return
          }
          if (!formdata.school_name || formdata.school_name.length < 1) {
            this.showToast('请填写就读学校')
            return
          }
1534
        }
pangy authored
1535 1536 1537 1538
        if (this.data.hasLoverData.selected.length < 1) {
          this.showToast('请选择是否有配偶')
          return
        }
pangy authored
1539
pangy authored
1540
        if (this.data.hasLover) {
pangy authored
1541 1542 1543
          if (!formdata.spouse_name || formdata.spouse_name.length < 1) {
            this.showToast('请填写配偶姓名')
            return
1544 1545 1546 1547
          } if (this.data.lovercardtypeData.selected.length < 1) {
            this.showToast('请选择配偶证照类型')
            return
          } if (!formdata.spouse_id_card_no || formdata.spouse_id_card_no.length < 1) {
wangyu authored
1548
            this.showToast('请填写配偶证照号码')
pangy authored
1549
            return
pangy authored
1550
          } else if (this.data.isIdCard_lover && !format.isIDCardNum(formdata.spouse_id_card_no)) {
pangy authored
1551
            this.showToast('配偶证照号码有误')
1552
            return
pangy authored
1553 1554 1555 1556 1557 1558 1559 1560 1561 1562
          }
          if (this.data.lovercardtypeData.selected.indexOf('居住证') > -1 && !reg_18_Number.test(formdata.spouse_id_card_no)) {
            this.showToast('配偶证照号码有误');
            return
          }
          if (this.data.lovercardtypeData.selected.indexOf('中国护照') > -1 && !reg_9_n_a.test(formdata.spouse_id_card_no)) {
            this.showToast('配偶证照号码有误');
            return
          }
          if (this.data.loverbirthDate.selected.length < 1) {
pangy authored
1563 1564 1565
            this.showToast('请选择配偶出生日期')
            return
          }
1566 1567 1568 1569
          if (this.data.loverCountryData.selected.length < 1) {
            this.showToast('请选择配偶国籍')
            return
          }
1570
          newdata.spouse_id_card_type = this.data.lovercardtypeData.selected
pangy authored
1571
          newdata.spouse_birthday = this.data.loverbirthDate.datelong
1572
          newdata.nation = this.data.loverCountryData.selected
wangyu authored
1573
        }
1574
        newdata.has_spouse = this.data.hasLover?'y':'n'
wangyu authored
1575
        newdata.relationship = this.data.taxperson_relativeData.selected
1576
        newdata.percent = this.data.childrenpercentData.selected.replace("%","")
1577
        newdata.children_id_card_type = this.data.childrencardtypeData.selected
wangyu authored
1578
        newdata.children_birthday = this.data.commonbirthDate.datelong
pangy authored
1579 1580
        newdata.education_period_end = this.data.studyPeriodDate.datelong
        newdata.education_end = this.data.studyEndDate.datelong
pangy authored
1581
        newdata.education_start = this.data.studystartdate.datelong 
wangyu authored
1582
        newdata.education_period = this.data.childedudegreeData.selected
1583
        newdata.school_country = this.data.schoolCountryData.selected
pangy authored
1584
        newdata.children_nation = this.data.countryData.selected//"中国"
wangyu authored
1585
        break;
pangy authored
1586
      case 'continuing_education':
pangy authored
1587
        subUrl = 'persontax/v1/continuing-educations'
wangyu authored
1588
        if (this.data.edutypeData.selected.length < 1) {
wangyu authored
1589
          this.showToast('请选择教育情况')
wangyu authored
1590
          return
pangy authored
1591 1592
        } else if (this.data.edu_lable == 'school') {
          // newdata.edu_type_lable = '0'
wangyu authored
1593 1594
          if (this.data.edulevelData.selected.length < 1) {
            this.showToast('请选择学历教育阶段')
wangyu authored
1595 1596 1597
            return
          }
          if (this.data.studystartdate.selected.length < 1) {
pangy authored
1598
            this.showToast('请选择入学时间')
wangyu authored
1599 1600
            return
          }
pangy authored
1601
          if (this.data.studyEndDate.selected.length < 1) {
pangy authored
1602
            this.showToast('请选择毕业时间')
wangyu authored
1603
            return
1604 1605
          } else {
            var activedDate = (Date.parse(new Date('2019-01-01')) / 1000)
pangy authored
1606
            if (this.data.studyEndDate.datelong < activedDate) {
pangy authored
1607
              this.showToast('毕业日期不符合要求,无法申报')
1608 1609
              return
            }
wangyu authored
1610
          }
1611
          newdata.education_start = this.data.studystartdate.datelong
pangy authored
1612
          newdata.education_end = this.data.studyEndDate.datelong
wangyu authored
1613
          newdata.education_type = 'title' //学历
wangyu authored
1614
          newdata.education_period = this.data.edulevelData.selected
pangy authored
1615
        } else if (this.data.edu_lable == 'tech') {
wangyu authored
1616 1617 1618 1619
          if (this.data.edustyleData.selected.length < 1) {
            this.showToast('请选择教育类型')
            return
          }
wangyu authored
1620 1621 1622
          if (this.data.applydate.selected.length < 1) {
            this.showToast('请选择发证日期')
            return
1623 1624 1625 1626 1627
          } else {
            // var d = new Date();
            // var curYear = d.getFullYear();
            var selYear = this.data.applydate.selected.substring(0, 4);
            if (selYear < 2019) {
pangy authored
1628
              this.showToast('发证(批准)日期须在2019年度内')
1629 1630
              return
            }
wangyu authored
1631
          }
pangy authored
1632 1633 1634 1635 1636 1637
          // if (!formdata.certification_name || formdata.certification_name.length < 1) {
          //   this.showToast('请填写证书名称')
          //   return
          // }
          if (this.data.certificateDate.selected.length < 1) {
            this.showToast('请选择证书名称')
wangyu authored
1638
            return
pangy authored
1639
          } 
wangyu authored
1640
          if (!formdata.certification_no || formdata.certification_no.length < 1) {
wangyu authored
1641 1642 1643
            this.showToast('请填写证书编号')
            return
          }
pangy authored
1644
          if (!formdata.certification_authority || formdata.certification_authority.length < 1) {
wangyu authored
1645 1646 1647
            this.showToast('请填写发证机关')
            return
          }
wangyu authored
1648
          //新增教育类型(区别教育类别)
pangy authored
1649
          // newdata.edu_type_lable = '1'
wangyu authored
1650
          newdata.approval_date = this.data.applydate.datelong
wangyu authored
1651
          newdata.education_type = this.data.edustyleData.selected == '技能人员职业资格' ? 'profession' : 'major'
pangy authored
1652
          newdata.certification_name = this.data.certificateDate.selected
wangyu authored
1653 1654
        }
        break;
pangy authored
1655
      case 'support_duty':
pangy authored
1656
        subUrl = 'persontax/v1/support-duties'
pangy authored
1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667
        // if (this.data.supporttypeData.selected.length < 1) {
        //   this.showToast('请选择赡养类型')
        //   return
        // }
        // if (!this.data.shareMethodData.hidden) {
        //   if (this.data.shareMethodData.selected.length < 1){
        //     this.showToast('请选择分摊方式')
        //     return
        //   }
        //   newdata.share_method = this.data.shareMethodData.selected
        // }
1668
        if (!formdata.supported_name || formdata.supported_name.length < 1) {
pangy authored
1669
          this.showToast('请填写被赡养人姓名')
wangyu authored
1670 1671
          return
        } else if (this.data.oldercardtypeData.selected.length < 1) {
pangy authored
1672
          this.showToast('请选择被赡养人证照类型')
wangyu authored
1673
          return
1674
        } else if (!formdata.id_card_no || formdata.id_card_no.length < 1) {
1675
          this.showToast('请填写证照号')
wangyu authored
1676
          return
pangy authored
1677
        } else if (this.data.isIdCard_older && !format.isIDCardNum(formdata.id_card_no)) {
pangy authored
1678
          this.showToast('被赡养人身份证格式有误')
1679
          return
wangyu authored
1680
        }
pangy authored
1681 1682 1683 1684 1685 1686 1687 1688
        if (this.data.oldercardtypeData.selected.indexOf('居住证') > -1 && !reg_18_Number.test(formdata.id_card_no)) {
          this.showToast('被赡养人证照号码有误');
          return
        }
        if (this.data.oldercardtypeData.selected.indexOf('中国护照') > -1 && !reg_9_n_a.test(formdata.id_card_no)) {
          this.showToast('被赡养人证照号码有误');
          return
        }
1689 1690 1691 1692
        if (this.data.olderbirthDate.selected.length < 1) {
          this.showToast('请选择出生日期')
          return
        }
1693 1694
        if (format.getAge(this.data.olderbirthDate.selected) < 60) {
          this.showToast('被赡养人年龄不足60岁,不可申报')
pangy authored
1695
          return
wangyu authored
1696
        }
1697 1698 1699 1700
        if (this.data.olderbirthDate.datelong > app.globalData.hostInfo.birth_date) {
          this.showToast('被赡养人年龄应大于本人');
          return
        }
1701 1702 1703 1704
        if (this.data.olderCountryData.selected.length < 1) {
          this.showToast('请选择国籍')
          return
        }
1705 1706 1707 1708
        if (this.data.older_relativeData.selected.length < 1) {
          this.showToast('请选择与纳税人关系')
          return
        }
1709 1710 1711 1712 1713 1714
        // if (!formdata.percentage || formdata.percentage.length < 1 || formdata.percentage > 100) {
        //   this.showToast('请填写合理分摊比例')
        //   return
        // } else {
        //   newdata.percentage = parseFloat(formdata.percentage)
        // }
pangy authored
1715
        newdata.support_type = this.supporttype
1716
        newdata.is_single = this.is_single
pangy authored
1717 1718 1719
        if (this.supporttype == 'S' && this.share_method.length){
          newdata.share_method = this.share_method
        }
wangyu authored
1720
        newdata.birthday = this.data.olderbirthDate.datelong
1721
        newdata.relationship = this.data.older_relativeData.selected
1722 1723
        newdata.id_card_type = this.data.oldercardtypeData.selected
        newdata.nation = this.data.olderCountryData.selected
wangyu authored
1724
        break;
pangy authored
1725
      case 'medical_fund':
pangy authored
1726
        subUrl = 'persontax/v1/medical-funds'
wangyu authored
1727 1728 1729 1730
        if (!formdata.name || formdata.name.length < 1) {
          this.showToast('请填写姓名')
          return
        } else if (this.data.cardtypeData.selected.length < 1) {
wangyu authored
1731
          this.showToast('请选择证照类型')
wangyu authored
1732
          return
pangy authored
1733
        } else if (!formdata.id_card_no || formdata.id_card_no.length < 1) {
wangyu authored
1734
          this.showToast('请填写证照号码')
wangyu authored
1735
          return
1736 1737 1738
        } else if (!format.isIDCardNum(formdata.id_card_no)) {
          this.showToast('身份证格式有误')
          return
wangyu authored
1739 1740 1741
        } else if (this.data.commonbirthDate.selected.length < 1) {
          this.showToast('请选择病人出生日期')
          return
wangyu authored
1742
        } else if (this.data.taxperson_relativeData.selected.length < 1) {
wangyu authored
1743 1744
          this.showToast('请选择与纳税人关系')
          return
pangy authored
1745
        } else if (!formdata.total_amount || formdata.total_amount < 0) {
wangyu authored
1746 1747
          this.showToast('请填写医疗支出总金额')
          return
wangyu authored
1748 1749 1750
        } else if (formdata.total_amount > 60000) {
          this.showToast('大病医疗支出扣除额度不得超过6万')
          return
pangy authored
1751
        } else if (!formdata.amount_by_person || formdata.amount_by_person < 0) {
wangyu authored
1752
          this.showToast('请填写个人负担金额')
wangyu authored
1753
          return
wangyu authored
1754 1755 1756
        }else if (formdata.amount_by_person >60000) {
          this.showToast('个人负担金额不得超过6万')
          return
wangyu authored
1757
        }
pangy authored
1758 1759 1760

        newdata.total_amount = parseFloat(formdata.total_amount)
        newdata.amount_by_person = parseFloat(formdata.amount_by_person)
1761
        newdata.id_card_type = this.data.cardtypeData.selected
pangy authored
1762
        newdata.relationship = this.data.taxperson_relativeData.selected
wangyu authored
1763
        newdata.patient_birthday = this.data.commonbirthDate.datelong
1764
        newdata.patient_nation = "中国"
wangyu authored
1765
        break;
pangy authored
1766
      case 'house_fund':
wangyu authored
1767 1768 1769
        subUrl = 'persontax/v1/house-funds'

        if (this.data.house_type == "house_fund_loan") {
pangy authored
1770 1771
          newdata.type = 'loan'
pangy authored
1772 1773 1774 1775 1776
          // if (this.data.houseLocateInfo.address_value[0].length < 1) {
          //   this.showToast('请选择住房地址')
          //   return
          // } else 
          if (!formdata.house_detail_address || formdata.house_detail_address.length < 1) {
rachel authored
1777 1778 1779
            this.showToast('请填写房屋详细地址')
            return
          }if (this.data.identifytypeData.selected.length < 1) {
wangyu authored
1780 1781
            this.showToast('请选择证书类型')
            return
wangyu authored
1782
          } else if (!formdata.certification_no || formdata.certification_no.length < 1) {
wangyu authored
1783 1784
            this.showToast('请填写证书号码')
            return
wangyu authored
1785 1786 1787 1788 1789 1790
          } else if (this.data.beforemarryData.selected.length < 1) {
            this.showToast('请选择是否首套贷款')
            return
          } else if (this.data.isselfData.selected.length < 1) {
            this.showToast('请选择是否本人借款')
            return
wangyu authored
1791 1792 1793
          } else if (this.data.loantypeData.selected.length < 1) {
            this.showToast('请选择贷款类型')
            return
pangy authored
1794 1795 1796 1797 1798 1799
          } 
          var loanType = this.data.loantypeData.selected 
          if (loanType == "公积金贷款" || loanType == "组合贷款"){
            if (!formdata.loan_contract_no || formdata.loan_contract_no.length < 1) {
              this.showToast('请填写公积金贷款合同编号')
              return
pangy authored
1800
            } else if (!formdata.loan_bank || formdata.loan_bank.length < 1) {
pangy authored
1801 1802 1803 1804 1805 1806
              this.showToast('请选择公积金贷款银行')
              return
            } else if (this.data.firstpaybackDate.selected.length < 1) {
              this.showToast('请选择首次还款日期')
              return
            } else if (!formdata.loan_months || formdata.loan_months.length < 1) {
1807
              this.showToast('请填写公积金贷款期限')
pangy authored
1808 1809
              return
            }
pangy authored
1810
            newdata.loan_bank = formdata.loan_bank
pangy authored
1811 1812 1813 1814 1815 1816 1817
            newdata.loan_start = this.data.firstpaybackDate.datelong
            newdata.loan_months = parseInt(formdata.loan_months)
          } 
          if (loanType == "商业贷款" || loanType == "组合贷款") {
            if (!formdata.sec_loan_contract_no || formdata.sec_loan_contract_no.length < 1) {
              this.showToast('请填写商业贷款合同编号')
              return
pangy authored
1818
            } else if (!formdata.sec_loan_bank || formdata.sec_loan_bank.length < 1) {
pangy authored
1819 1820 1821 1822 1823 1824
              this.showToast('请选择商业贷款银行')
              return
            } else if (this.data.firstpaybackDate_2.selected.length < 1) {
              this.showToast('请选择首次还款日期')
              return
            } else if (!formdata.sec_loan_months || formdata.sec_loan_months.length < 1) {
1825
              this.showToast('请填写商业贷款期限')
pangy authored
1826 1827
              return
            }
pangy authored
1828
            newdata.sec_loan_bank = formdata.sec_loan_bank
pangy authored
1829 1830
            newdata.sec_loan_start = this.data.firstpaybackDate_2.datelong
            newdata.sec_loan_months = parseInt(formdata.sec_loan_months)
wangyu authored
1831
          }
wangyu authored
1832 1833
          newdata.loan_before_marry = this.data.beforemarryData.selected == "是" ? 'y' : 'n'
          newdata.loan_by_self = this.data.isselfData.selected == "是" ? 'y' : 'n'
pangy authored
1834
          newdata.certification_type = this.data.identifytypeData.selected
wangyu authored
1835
wangyu authored
1836
          newdata.loan_type = this.data.loantypeData.selected
pangy authored
1837
          
wangyu authored
1838 1839
          // newdata.loan_datelong = this.data.loandatelongData.selected
          var request_loan_address = this.getLoanAddressRequest()
pangy authored
1840
          newdata.house_address = request_loan_address
wangyu authored
1841
pangy authored
1842
        } else if (this.data.house_type == "house_fund_rent") {
pangy authored
1843 1844 1845
          newdata.type = 'rent'
          console.log('workingcityInfo', this.data.workingcityInfo.address_value)
          if (this.data.workingcityInfo.address_value[0].length < 1) {
wangyu authored
1846
            this.showToast('请选择工作城市')
wangyu authored
1847 1848 1849 1850
            return
          } else if (this.data.leasetypeData.selected.length < 1) {
            this.showToast('请选择出租方类型')
            return
pangy authored
1851
          } else if (!formdata.owner_name || formdata.owner_name.length < 1) {
pangy authored
1852 1853
            // this.showToast('请填写出租方名称')
            // return
pangy authored
1854
          } 
pangy authored
1855
          if (this.data.leasetypeData.selected =='组织'){
pangy authored
1856
            if (!formdata.owner_credit_no || formdata.owner_credit_no.length < 1) {
pangy authored
1857 1858
              // this.showToast('请填写统一社会信用代码')
              // return
pangy authored
1859 1860 1861
            }
            newdata.owner_id_card_no = ''
          } else{
1862
            if (this.data.cardtypeData.selected.length < 1) {
pangy authored
1863 1864
              // this.showToast('请选择证照类型')
              // return
1865
            }
pangy authored
1866
            if (!formdata.owner_id_card_no || formdata.owner_id_card_no.length < 1) {
pangy authored
1867 1868
              // this.showToast('请填写证照号码')
              // return
1869
            } else if (this.data.isIdCard_owner && !format.isIDCardNum(formdata.owner_id_card_no)) {
pangy authored
1870
              this.showToast('证照号码有误')
pangy authored
1871 1872
              return
            } 
pangy authored
1873 1874 1875 1876 1877 1878 1879 1880
            if (this.data.cardtypeData.selected.indexOf('居住证') > -1 && !reg_18_Number.test(formdata.owner_id_card_no)) {
              this.showToast('证照号码有误');
              return
            }
            if (this.data.cardtypeData.selected.indexOf('中国护照') > -1 && !reg_9_n_a.test(formdata.owner_id_card_no)) {
              this.showToast('证照号码有误');
              return
            }
1881
            newdata.owner_id_card_type = this.data.cardtypeData.selected
wangyu authored
1882
          }
pangy authored
1883 1884 1885
          // if (this.data.rentLocateInfo.address_value[0].length < 1) {
          //   this.showToast('请选择房屋地址')
          //   return
pangy authored
1886 1887 1888 1889 1890
          // } else 
          if (!formdata.house_detail_address || formdata.house_detail_address.length < 1) {
            this.showToast('请填写房屋详细地址')
            return
          }
pangy authored
1891 1892 1893 1894 1895
          // else if (!formdata.rent_contract_no || formdata.rent_contract_no.length < 1) {
          //   this.showToast('请填写租赁合同编号')
          //   return
          // } else 
          if (this.data.leasestartDate.selected.length < 1) {
pangy authored
1896
            this.showToast('请选择租赁起始日期')
wangyu authored
1897
            return
1898 1899
          }
          if (this.data.leaseendDate.selected.length < 1) {
pangy authored
1900
            this.showToast('请选择租赁终止日期')
wangyu authored
1901
            return
1902 1903 1904 1905 1906 1907
          } else {
            var activedDate = (Date.parse(new Date('2019-01-01')) / 1000)
            if (this.data.leaseendDate.datelong < activedDate) {
              this.showToast('终止日期不符合要求,无法申报')
              return
            }
wangyu authored
1908
          }
1909
pangy authored
1910
          newdata.owner_type = this.data.leasetypeData.selected
wangyu authored
1911 1912
          newdata.rent_start = this.data.leasestartDate.datelong
          newdata.rent_end = this.data.leaseendDate.datelong
wangyu authored
1913
wangyu authored
1914
          var request_working_address = this.getWorkingAddressRequest()
wangyu authored
1915
          newdata.work_city = request_working_address
wangyu authored
1916
          var request_rent_address = this.getRentAddressRequest()
wangyu authored
1917
          newdata.house_address = request_rent_address
wangyu authored
1918
          console.log('request_working_address', request_working_address)
wangyu authored
1919
        }
pangy authored
1920 1921 1922 1923 1924
        if (this.data.hasLoverData.selected.length < 1) {
          this.showToast('请选择是否有配偶')
          return
        }
        if (this.data.hasLover) {
wangyu authored
1925 1926 1927
          if (!formdata.spouse_name || formdata.spouse_name.length < 1) {
            this.showToast('请填写配偶姓名')
            return
1928 1929 1930 1931
          } 
          if (this.data.lovercardtypeData.selected.length < 1) {
            this.showToast('请选择配偶证照类型')
            return
wangyu authored
1932 1933 1934
          } else if (!formdata.spouse_id_card_no || formdata.spouse_id_card_no.length < 1) {
            this.showToast('请填写配偶证照号码')
            return
pangy authored
1935
          } else if (this.data.isIdCard_lover && !format.isIDCardNum(formdata.spouse_id_card_no)) {
1936 1937
            this.showToast('配偶身份证格式有误')
            return
pangy authored
1938 1939 1940 1941 1942 1943 1944 1945 1946 1947
          } 
          if (this.data.lovercardtypeData.selected.indexOf('居住证') > -1 && !reg_18_Number.test(formdata.spouse_id_card_no)) {
            this.showToast('证照号码有误');
            return
          }
          if (this.data.lovercardtypeData.selected.indexOf('中国护照') > -1 && !reg_9_n_a.test(formdata.spouse_id_card_no)) {
            this.showToast('证照号码有误');
            return
          }
          if (this.data.loverbirthDate.selected.length < 1) {
wangyu authored
1948 1949 1950
            this.showToast('请选择配偶出生日期')
            return
          }
1951 1952 1953 1954
          if (this.data.loverCountryData.selected.length < 1) {
            this.showToast('请选择配偶国籍')
            return
          }
pangy authored
1955
          newdata.id_card_no = newdata.spouse_id_card_no ? newdata.spouse_id_card_no : ''
1956
          newdata.id_card_type = this.data.lovercardtypeData.selected
pangy authored
1957
          newdata.birthday = this.data.loverbirthDate.datelong
1958
          newdata.nation = this.data.loverCountryData.selected
wangyu authored
1959
        }
1960
        newdata.has_spouse = this.data.hasLover ? 'y' : 'n'
wangyu authored
1961 1962 1963
        break;
    }
wangyu authored
1964 1965 1966
    if (this.data.reducetypeData.selected.length < 1) {
      this.showToast('请选择扣除方式')
      return
wangyu authored
1967
    }
pangy authored
1968 1969 1970 1971
    // else if (!formdata.reduce_money || formdata.reduce_money.length < 1) {
    //   this.showToast('请填写扣除金额')
    //   return
    // }
pangy authored
1972
    if (this.data.cur_index != 'medical_fund' && this.data.cur_index != 'continuing_education') {
wangyu authored
1973 1974
      newdata.deduction_type = this.data.reducetypeData.selected == '月度' ? "month" : "year"
      newdata.deduction_amount = this.data.deduction_amount //formdata.reduce_money 
pangy authored
1975
    }
pangy authored
1976 1977
    newdata.legal_entity_id = this.legal_entity_id
    newdata.legal_entity = this.legal_entity
1978 1979 1980
    if (this.isEdit) {
      newdata.id = this.edit_id
    }
pangy authored
1981
    console.log("newdata", newdata);
pangy authored
1982
    this.addDatas(newdata, subUrl)
wangyu authored
1983 1984
  },
wangyu authored
1985
  addDatas: function(newdata, subUrl) {
1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999
    // wx.showModal({
    //   title: '确认要提交申报吗?',
    //   content: '确认后将不能修改',
    //   showCancel: true,
    //   confirmColor: '#357AEB',
    //   cancelColor: '#999',
    //   success: function(res) {
    //     if (res.confirm) {
    //      ///接口
    //     } else if (res.cancel) {}
    //   }
    // })
    var that = this;
    var Authorization = app.globalData.Authorization;
pangy authored
2000
    wx.showLoading()
2001 2002 2003 2004 2005 2006 2007 2008 2009
    wx.request({
      url: baseUrl + subUrl,
      method: "POST",
      header: {
        'content-type': 'application/json',
        "Authorization": Authorization
      },
      data: newdata,
      success(res) {
pangy authored
2010
        wx.hideLoading()
2011 2012 2013
        if (res && res.statusCode < 300) {
          wx.navigateBack({
            delta: 1
wangyu authored
2014
          })
2015 2016 2017
        } else {
          wx.showToast({
            title: res.data.message ? res.data.message : '请求出错',
pangy authored
2018 2019
            icon: 'none',
            duration: 2000
2020 2021
          })
        }
pangy authored
2022
      },
2023
      fail(res){
pangy authored
2024
        wx.hideLoading()
wangyu authored
2025
      }
wangyu authored
2026
    })
wangyu authored
2027
  },
wangyu authored
2028
wangyu authored
2029
  getIdInfo: function(e) {
pangy authored
2030
    this.idcard_belong = e.currentTarget.id
wangyu authored
2031 2032 2033
    if (this.data.isIdCard) {
      wx.navigateTo({
        url: '../../taxperson/idinfo/idinfo',
wangyu authored
2034
        success: function(res) {},
wangyu authored
2035 2036
      })
    }
wangyu authored
2037
  },
2038 2039
  idChange: function (e) {
    console.log('idCardNoChange',e, e.detail.value)
pangy authored
2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055
    switch (e.currentTarget.id) {
      case 'children_id_card_no_input':
        if (!this.data.isIdCard_child) {
          return;
        }
        break;
      case 'older_id_card_no_input':
        if (!this.data.isIdCard_older) {
          return;
        }
        break;
      case 'spouse_id_card_no_input':
        if (!this.data.isIdCard_lover) {
          return;
        }
        break;
2056 2057 2058 2059 2060
      case 'owner_id_card_no_input':
        if (!this.data.isIdCard_owner) {
          return;
        }
        break;
pangy authored
2061
    }
2062 2063 2064 2065
    var idCardNo = e.detail.value
    if (e.detail.value.length == 18) {
      if (!format.isIDCardNum(idCardNo)) {
        wx.showToast({
pangy authored
2066 2067
          title: '身份证格式有误',
          icon:'none'
2068 2069 2070 2071 2072 2073
        })
        return;
      }
      this.dealIdInfo(idCardNo, e.currentTarget.id)
    }
  },
pangy authored
2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091

  idDone: function (e) {
    switch (e.currentTarget.id) {
      case 'children_id_card_no_input':
        if (!this.data.isIdCard_child) {
          return;
        }
        break;
      case 'older_id_card_no_input':
        if (!this.data.isIdCard_older) {
          return;
        }
        break;
      case 'spouse_id_card_no_input':
        if (!this.data.isIdCard_lover) {
          return;
        }
        break;
2092 2093 2094 2095 2096
      case 'owner_id_card_no_input':
        if (!this.data.isIdCard_owner) {
          return;
        }
        break;
pangy authored
2097 2098 2099 2100
    }
    var idCardNo = e.detail.value
    if (!idCardNo.length) {
      wx.showToast({
2101
        title: '请输入证照号码',
pangy authored
2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113
        icon: 'none'
      })
      return;
    }
    if (!format.isIDCardNum(idCardNo)) {
      wx.showToast({
        title: '身份证格式有误',
        icon: 'none'
      })
      return;
    }
  },
pangy authored
2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129
  medicalInput: function (e) {
    console.log('-------', e.detail.value)
    var num = parseFloat(e.detail.value)
    switch (e.currentTarget.id) {
      case 'medical_total_input':
        this.setData({
          total_amount: num.toFixed(2)
        })
        break;
      case 'medical_amount_input':
        this.setData({
          amount_by_person: num.toFixed(2)
        })
        break;
    }
  },
pangy authored
2130
  loan_input: function (e) {
2131
    var value = e.detail.value
pangy authored
2132 2133 2134
    switch (e.currentTarget.id) {
      case 'loan_contract_no':
        this.setData({
2135
          loan_contract_no: value
pangy authored
2136 2137 2138
        })
        break;
      case 'loan_months':
2139 2140 2141 2142 2143 2144
        if (value.length && value <= 0) {
          value = 1
        } else if (value > 240) {
          value = 240
          this.showToast('月数不得大于240')
        }
pangy authored
2145
        this.setData({
2146
          loan_months: value
pangy authored
2147 2148 2149 2150
        })
        break;
      case 'sec_loan_contract_no':
        this.setData({
2151
          sec_loan_contract_no: value
pangy authored
2152 2153 2154
        })
        break;
      case 'sec_loan_months':
2155 2156 2157 2158 2159 2160
        if (value.length && value <= 0) {
          value = 1
        }else if (value>240){
          value = 240
          this.showToast('月数不得大于240')
        }
pangy authored
2161
        this.setData({
2162
          sec_loan_months: value
pangy authored
2163 2164 2165 2166
        })
        break;
    }
  },
pangy authored
2167 2168 2169 2170 2171 2172 2173 2174 2175
  //根据出生日期 计算 学前受教育时间
  dealBrithDate: function (birthDay){
    if (this.data.childedudegreeData.selected == '学前教育阶段') {
      var year = birthDay.substring(0, 4)
      year = parseInt(year) + 3
      var month = birthDay.substring(4, 7)
      this.handleStartDate(year + month, true)  //处理受教育时间起的逻辑
    }
  },
2176 2177 2178 2179
  //根据身份证号码,获取相关信息
  dealIdInfo: function (idCardNum, idcard_belong) {
    var info = format.analyzeIDCard(idCardNum)
    console.log('info', info.age, info.sex, info.birthDay, (Date.parse(new Date(info.birthDay)) / 1000))
pangy authored
2180
    var data = {}
2181 2182 2183 2184 2185 2186
    if (idcard_belong == 'children_id_card_no_input') {
      this.data.commonbirthDate.selected = info.birthDay
      this.data.commonbirthDate.datelong = (Date.parse(new Date(info.birthDay)) / 1000)
      data = {
        commonbirthDate: this.data.commonbirthDate
      }
pangy authored
2187
      this.dealBrithDate(info.birthDay)//根据出生日期 计算 学前受教育时间
2188 2189 2190
      if (info.age<3){
        this.showToast('子女年龄小于3岁,不可申报')
      }
2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208
    } else if (idcard_belong == 'spouse_id_card_no_input') {
      this.data.loverbirthDate.selected = info.birthDay
      this.data.loverbirthDate.datelong = (Date.parse(new Date(info.birthDay)) / 1000)
      data = {
        loverbirthDate: this.data.loverbirthDate
      }
    } else if (idcard_belong == 'medical_id_card_no_input') {
      this.data.commonbirthDate.selected = info.birthDay
      this.data.commonbirthDate.datelong = (Date.parse(new Date(info.birthDay)) / 1000)
      data = {
        commonbirthDate: this.data.commonbirthDate
      }
    } else if (idcard_belong == 'older_id_card_no_input') {
      this.data.olderbirthDate.selected = info.birthDay
      this.data.olderbirthDate.datelong = (Date.parse(new Date(info.birthDay)) / 1000)
      data = {
        olderbirthDate: this.data.olderbirthDate
      }
2209 2210 2211
      if (info.age < 60) {
        this.showToast('被赡养人年龄不足60岁,不可申报')
      }
pangy authored
2212
    } else if (idcard_belong == 'owner_id_card_no_input') {
2213 2214 2215
      // this.data.olderbirthDate.selected = info.birthDay
      // this.data.olderbirthDate.datelong = (Date.parse(new Date(info.birthDay)) / 1000)
      // data = {
pangy authored
2216
      //   owner_id_card_no: idCardNum,
2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228
      // }
    }
    if (info.age) {
      // data.age = info.age
    }
    if (info.sex) {
      // var gender_data = this.data.genderData
      // gender_data.selected = info.sex
      // data.genderData = gender_data
    }
    this.setData(data)
  },
pangy authored
2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239
  // studyDataTap: function (e) {
  //   console.log('studyDataTap',e)
  //   if (e.currentTarget.id == 'study_start_date'){
  //     var study_startdate = this.data.studystartdate
  //     study_startdate.start = '1970-01-01'
  //     study_startdate.end = ''
  //     this.setData({
  //       studystartdate: study_startdate
  //     })
  //   } else if (e.currentTarget.id == 'study_end_date') {
  //     console.log('study_end_date')
pangy authored
2240
  //     var study_enddate = this.data.studyEndDate
pangy authored
2241 2242 2243
  //     study_enddate.start = '1970-01-01'
  //     study_enddate.end = ''
  //     this.setData({
pangy authored
2244
  //       studyEndDate: study_enddate
pangy authored
2245 2246 2247
  //     })
  //   } 
  // },
2248
  handleBeforemarry: function (beforemarry) {
pangy authored
2249
    var hasLover = this.data.hasLover
2250 2251
    var deduction_amount = beforemarry ? (Deduce_amounts_month["house_fund_loan"] / 2) : Deduce_amounts_month["house_fund_loan"]
    this.data.hasLoverData.disabled = beforemarry
pangy authored
2252 2253 2254 2255
    if (beforemarry){
      this.data.hasLoverData.selected =  '是'
      hasLover = true
    }
2256 2257 2258 2259 2260 2261
    this.setData({
      hasLoverData: this.data.hasLoverData,
      hasLover: hasLover,
      deduction_amount: deduction_amount
    })
  },
2262 2263 2264 2265 2266 2267 2268
  handleHasLover: function (hasLover) {
    this.data.beforemarryData.selected = hasLover ? this.data.beforemarryData.selected : '否'
    this.data.beforemarryData.disabled = hasLover ? false : true
    this.setData({
      beforemarryData: this.data.beforemarryData
    })
  },
pangy authored
2269 2270

  dealCardType: function (new_type,witch) {
2271
    console.log('new_type', new_type)
pangy authored
2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288
    var is_idcard, cardtypeData, countryData, birthDate
    switch (witch) {
      case 'childrencardtype':
        countryData = this.data.countryData
        cardtypeData = this.data.childrencardtypeData
        birthDate = this.data.commonbirthDate
        break;
      case 'lovercardtype':
        countryData = this.data.loverCountryData
        cardtypeData = this.data.lovercardtypeData
        birthDate = this.data.loverbirthDate
        break;
      case 'oldercardtype':
        countryData = this.data.olderCountryData
        cardtypeData = this.data.oldercardtypeData
        birthDate = this.data.olderbirthDate
        break;
2289 2290 2291 2292 2293 2294 2295 2296 2297
      case 'ownercardtype':
        cardtypeData = this.data.cardtypeData
        cardtypeData.selected = new_type
        this.setData({
          cardtypeData: cardtypeData,
          isIdCard_owner: ('居民身份证' == new_type),
        })
        return;
        break;
pangy authored
2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321
    }
    
    cardtypeData.selected = new_type
    if ('居民身份证' == new_type) {
      is_idcard = true
      birthDate.disabled = true
    } else {
      is_idcard = false
      birthDate.disabled = false
    }
    if ('居民身份证' == new_type || '中国护照' == new_type) {
      countryData.selected = '中国'
      countryData.disabled = true
    } else if (new_type.indexOf("港澳") != -1) {
      countryData.values = ['中国香港', '中国澳门']
      countryData.selected = ''
      countryData.disabled = false
    } else if (new_type.indexOf("台湾") != -1) {
      countryData.selected = '中国台湾'
      countryData.disabled = true
    } else {
      countryData.selected = ''
      countryData.values = this.countrys ? this.countrys : []
      countryData.disabled = false
2322
    } 
pangy authored
2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348
    switch (witch) {
      case 'childrencardtype':
        this.setData({
          countryData: countryData,
          childrencardtypeData: cardtypeData,
          isIdCard_child: is_idcard,
          commonbirthDate: birthDate
        })
        break;
      case 'lovercardtype':
        this.setData({
          loverCountryData: countryData,
          lovercardtypeData: cardtypeData,
          isIdCard_lover: is_idcard,
          loverbirthDate: birthDate
        })
        break;
      case 'oldercardtype':
        this.setData({
          olderCountryData: countryData,
          oldercardtypeData: cardtypeData,
          olderbirthDate: birthDate,
          isIdCard_older: is_idcard,
        }) 
        break;
    }
2349 2350 2351 2352 2353 2354 2355 2356
    if (countryData.values && countryData.values.length < 1) {
      console.log('-----countrys  还未加载完成 ')
      var that = this, setData = {}
      this.getCountry(function (countrys){
        console.log('-----countrys  加载完成 ', witch)
        switch (witch) {
          case 'childrencardtype':
            that.data.countryData.values = countrys
2357
            setData.countryData = that.data.countryData
2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370
            break;
          case 'lovercardtype':
            that.data.loverCountryData.values = countrys
            setData.loverCountryData = that.data.loverCountryData
            break;
          case 'oldercardtype':
            that.data.olderCountryData.values = countrys
            setData.olderCountryData = that.data.olderCountryData
            break;
        }
        that.setData(setData)
      })
    }
pangy authored
2371 2372
   
  },
2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401
  //-----------------处理受教育时间起的逻辑-----------/
  handleStartDate: function (select_date,disabled) {
    var study_startdate = this.data.studystartdate
    study_startdate.selected = select_date
    study_startdate.disabled = disabled
    var start = select_date, select_year = 0
    if (select_date.length>4) {
      study_startdate.datelong = (Date.parse(new Date(select_date)) / 1000)
      select_year = select_date.substring(0, 4)
    }else{
      study_startdate.datelong = null
    }
    //处理两个终止时间的限制
    if (select_year < 2019) {
      start = '2019-01'
    }
    var studyPeriodDate = this.data.studyPeriodDate
    studyPeriodDate.start = start
    studyPeriodDate.selected = ''
    studyPeriodDate.datelong = null
    var study_enddate = this.data.studyEndDate
    study_enddate.start = start
    study_enddate.selected = ''
    this.setData({
      studystartdate: study_startdate,
      studyPeriodDate: studyPeriodDate,
      studyEndDate: study_enddate
    })
  },
wangyu authored
2402
  onPickerSelect: function(e) {
wangyu authored
2403 2404
    console.log('picker发送选择改变,携带值为', e)
    switch (e.currentTarget.id) {
pangy authored
2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434
      case 'country':
        var countryData = this.data.countryData
        var new_country = countryData.values[e.detail.value]
        if (new_country != countryData.selected) {
          countryData.selected = new_country
          this.setData({
            countryData: countryData
          })
        }
        break;
      case 'lover_country':
        var loverCountryData = this.data.loverCountryData
        var new_country = loverCountryData.values[e.detail.value]
        if (new_country != loverCountryData.selected) {
          loverCountryData.selected = new_country
          this.setData({
            loverCountryData: loverCountryData
          })
        }
        break;
      case 'older_country':
        var olderCountryData = this.data.olderCountryData
        var new_country = olderCountryData.values[e.detail.value]
        if (new_country != olderCountryData.selected) {
          olderCountryData.selected = new_country
          this.setData({
            olderCountryData: olderCountryData
          })
        }
        break;
pangy authored
2435 2436
      case 'hasLover':
        var hasLoverData = this.data.hasLoverData
2437 2438 2439
        if (hasLoverData.selected == hasLoverData.values[e.detail.value]) {
          return
        }
pangy authored
2440 2441 2442 2443 2444 2445
        hasLoverData.selected = hasLoverData.values[e.detail.value]
        var hasLover = e.detail.value == '0'
        this.setData({
          hasLoverData: hasLoverData,
          hasLover: hasLover
        })
2446
        
2447 2448 2449
        if (this.data.cur_index == 'house_fund' && this.data.house_type == 'house_fund_loan') {
          this.handleHasLover(hasLover)
        }
pangy authored
2450
        break;
pangy authored
2451 2452 2453 2454 2455 2456 2457
      // case 'lovercardtype':
      //   var lover_cardtypeData = this.data.lovercardtypeData
      //   lover_cardtypeData.selected = lover_cardtypeData.values[e.detail.value]
      //   this.setData({
      //     lovercardtypeData: lover_cardtypeData
      //   })
      //   break;
wangyu authored
2458
      case 'lovercardtype':
pangy authored
2459
        var lover_cardtypeData = this.data.lovercardtypeData
pangy authored
2460 2461 2462 2463 2464 2465 2466
        var new_type = lover_cardtypeData.values[e.detail.value]
        if (new_type != lover_cardtypeData.selected) {
          this.dealCardType(new_type, 'lovercardtype')
          this.setData({
            spouse_id_card_no: ""
          })
        }
pangy authored
2467
        break;
wangyu authored
2468 2469 2470
      case 'loverbirthday':
        var lover_birthDate = this.data.loverbirthDate
        lover_birthDate.selected = e.detail.value
pangy authored
2471
        lover_birthDate.datelong = (Date.parse(new Date(e.detail.value)) / 1000)
wangyu authored
2472 2473 2474 2475
        this.setData({
          loverbirthDate: lover_birthDate
        })
        break;
2476 2477 2478 2479 2480 2481 2482
      case 'older_relative':
        var older_relativeData = this.data.older_relativeData
        older_relativeData.selected = older_relativeData.values[e.detail.value]
        this.setData({
          older_relativeData: older_relativeData
        })
        break;
wangyu authored
2483 2484 2485 2486 2487 2488 2489
      case 'taxperson_relative':
        var taxperson_relativedata = this.data.taxperson_relativeData
        taxperson_relativedata.selected = taxperson_relativedata.values[e.detail.value]
        this.setData({
          taxperson_relativeData: taxperson_relativedata
        })
        break;
pangy authored
2490 2491 2492 2493 2494 2495 2496
      // case 'childrencardtype':
      //   var children_cardtypedata = this.data.childrencardtypeData
      //   children_cardtypedata.selected = children_cardtypedata.values[e.detail.value]
      //   this.setData({
      //     childrencardtypeData: children_cardtypedata
      //   })
      //   break;
wangyu authored
2497
      case 'childrencardtype':
pangy authored
2498 2499 2500 2501 2502 2503 2504 2505
        var childrencardtypeData = this.data.childrencardtypeData
        var new_type = childrencardtypeData.values[e.detail.value] 
        if (new_type != childrencardtypeData.selected) {
          this.dealCardType(new_type, 'childrencardtype')
          this.setData({
            children_id_card_no: ""
          })
        }
wangyu authored
2506
        break;
wangyu authored
2507 2508 2509
      case 'child_percent':
        var childrenpercent_data = this.data.childrenpercentData
        childrenpercent_data.selected = childrenpercent_data.values[e.detail.value]
pangy authored
2510 2511 2512
        var deduction_amount = 0
        if (e.detail.value == '0') {
          deduction_amount = 500
pangy authored
2513 2514
        } else if (e.detail.value == '1') {
          deduction_amount = 1000
pangy authored
2515 2516 2517
        }else {
          deduction_amount = 1000
        }
wangyu authored
2518
        this.setData({
pangy authored
2519 2520
          childrenpercentData: childrenpercent_data,
          deduction_amount: deduction_amount
wangyu authored
2521 2522 2523
        })
        break;
      break;
wangyu authored
2524 2525
      case 'commonbirthday':
        var children_birthDate = this.data.commonbirthDate
wangyu authored
2526
        children_birthDate.selected = e.detail.value
pangy authored
2527
        this.dealBrithDate(e.detail.value)//根据出生日期 计算 学前受教育时间
pangy authored
2528
        children_birthDate.datelong = (Date.parse(new Date(e.detail.value)) / 1000)
wangyu authored
2529
        this.setData({
wangyu authored
2530
          commonbirthDate: children_birthDate
wangyu authored
2531 2532 2533
        })
        break;
      case 'study_start_date':
pangy authored
2534
        var select_date = e.detail.value
2535
        this.handleStartDate(select_date,false)  //处理受教育时间起的逻辑
wangyu authored
2536
        break;
pangy authored
2537 2538 2539
      case 'study_end_date':
        var study_enddate = this.data.studyEndDate
        study_enddate.selected = e.detail.value
pangy authored
2540
        var datelong = (Date.parse(new Date(e.detail.value)) / 1000)
pangy authored
2541 2542 2543 2544 2545 2546
        study_enddate.datelong = datelong
       
        var studyPeriodDate = this.data.studyPeriodDate
        studyPeriodDate.end = e.detail.value
        studyPeriodDate.selected = ''
        studyPeriodDate.datelong = null
pangy authored
2547
        this.setData({
pangy authored
2548 2549
          studyPeriodDate: studyPeriodDate,
          studyEndDate: study_enddate
pangy authored
2550 2551
        })
        // var activedDate = (Date.parse(new Date('2019-01-01')) / 1000)
pangy authored
2552 2553
        // if (datelong < activedDate){
        //   this.showToast('教育终止时间不符合要求,无法申报')
pangy authored
2554 2555
        // }
        break;
pangy authored
2556 2557 2558
      case 'study_per_date':
        var studyPeriodDate = this.data.studyPeriodDate
        studyPeriodDate.selected = e.detail.value
2559
        var datelong = (Date.parse(new Date(e.detail.value)) / 1000)
pangy authored
2560 2561 2562 2563 2564 2565 2566 2567
        studyPeriodDate.datelong = datelong
        if (datelong > this.data.studyEndDate.datelong) {
          wx.showToast({
            title: '教育终止日应不大于受教育时间止',
            icon:'none'
          })
          return
        }
wangyu authored
2568
        this.setData({
pangy authored
2569
          studyPeriodDate: studyPeriodDate,
wangyu authored
2570
        })
pangy authored
2571
        // var activedDate = (Date.parse(new Date('2019-01-01')) / 1000)
pangy authored
2572 2573
        // if (datelong < activedDate) {
        //   this.showToast('受教育时间止不符合要求,无法申报')
pangy authored
2574
        // }
wangyu authored
2575
        break;
pangy authored
2576
      case 'child_edu_degree':
2577 2578 2579 2580 2581 2582
        var ifPreprimary = (e.detail.value == '0') //学前教育
        if (ifPreprimary){
          if (this.data.commonbirthDate.selected.length < 1) {
            this.showToast('请先完善子女生日信息')
            return
          } else{
pangy authored
2583 2584
            var year = this.data.commonbirthDate.selected.substring(0, 4) 
            year = parseInt(year) + 3
2585 2586 2587 2588 2589 2590
            var month = this.data.commonbirthDate.selected.substring(4, 7)
            this.handleStartDate(year+month, true)  //处理受教育时间起的逻辑
          }
        }else{
          this.handleStartDate('', false) 
        }
pangy authored
2591 2592 2593 2594 2595
        var childedudegreeData = this.data.childedudegreeData
        childedudegreeData.selected = childedudegreeData.values[e.detail.value]
        this.setData({
          childedudegreeData: childedudegreeData
        })
2596 2597 2598 2599 2600 2601
        this.data.schoolCountryData.isrequre = !ifPreprimary
        this.setData({
          schoolCountryData: this.data.schoolCountryData,
          child_edu_pre: ifPreprimary
        })
        
pangy authored
2602
        break;
wangyu authored
2603 2604 2605 2606 2607 2608 2609
        // case 'edu_degree':
        //   var edudegree_data = this.data.edudegreeData
        //   edudegree_data.selected = edudegree_data.values[e.detail.value]
        //   this.setData({
        //     edudegreeData: edudegree_data
        //   })
        //   break;
wangyu authored
2610
      case 'school_country':
2611 2612
        var schoolCountry_data = this.data.schoolCountryData
        schoolCountry_data.selected = schoolCountry_data.values[e.detail.value]
2613
        this.setData({
2614
          schoolCountryData: schoolCountry_data
2615 2616
        })
        break;
pangy authored
2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634
      // case 'support_type':
      //   var support_typeData = this.data.supporttypeData
      //   support_typeData.selected = support_typeData.values[e.detail.value]
      //   var share_methodData = this.data.shareMethodData
      //   share_methodData.hidden = e.detail.value == 0
      //   this.setData({
      //     oldersupport_lable: e.detail.value == 0 ? 'single' : 'together',
      //     supporttypeData: support_typeData,
      //     shareMethodData: share_methodData
      //   })
      //   break;
      // case 'share_method':
      //   var share_methodData = this.data.shareMethodData
      //   share_methodData.selected = share_methodData.values[e.detail.value]
      //   this.setData({
      //     shareMethodData: share_methodData
      //   })
      //   break;
pangy authored
2635 2636 2637 2638 2639 2640 2641
      // case 'oldercardtype':
      //   var older_cardtypeData = this.data.oldercardtypeData
      //   older_cardtypeData.selected = older_cardtypeData.values[e.detail.value]
      //   this.setData({
      //     oldercardtypeData: older_cardtypeData
      //   })
      //   break;
wangyu authored
2642
      case 'oldercardtype':
pangy authored
2643 2644 2645 2646 2647 2648 2649 2650
        var oldercardtypeData = this.data.oldercardtypeData
        var new_type = oldercardtypeData.values[e.detail.value]
        if (new_type != oldercardtypeData.selected) {
          this.dealCardType(new_type, 'oldercardtype')
          this.setData({
            id_card_no: ""
          })
        }
wangyu authored
2651
        break;
wangyu authored
2652 2653 2654
      case 'olderbirthday':
        var older_birthDate = this.data.olderbirthDate
        older_birthDate.selected = e.detail.value
pangy authored
2655
        older_birthDate.datelong = Date.parse(new Date(e.detail.value)) / 1000,
wangyu authored
2656 2657 2658
          this.setData({
            olderbirthDate: older_birthDate
          })
wangyu authored
2659
        break;
wangyu authored
2660 2661
      case 'reduce_type':
        var reduce_typeData = this.data.reducetypeData
pangy authored
2662
        var deduction_amount
2663
        var key = this.data.cur_index
pangy authored
2664 2665
        if (this.data.house_type.length) {
          key = this.data.house_type
2666
        }
pangy authored
2667
        if (e.detail.value == '0') {
2668
          deduction_amount = Deduce_amounts_month[key]
pangy authored
2669
        } else {
2670
          deduction_amount = Deduce_amounts_year[key]
pangy authored
2671
        }
wangyu authored
2672 2673
        reduce_typeData.selected = reduce_typeData.values[e.detail.value]
        this.setData({
pangy authored
2674 2675
          reducetypeData: reduce_typeData,
          deduction_amount: deduction_amount
wangyu authored
2676 2677
        })
        break;
wangyu authored
2678 2679 2680
      case 'edu_type':
        var edutypee_data = this.data.edutypeData
        edutypee_data.selected = edutypee_data.values[e.detail.value]
pangy authored
2681 2682
        var reducetypeData = this.data.reducetypeData
        var deduction_amount
pangy authored
2683 2684 2685 2686 2687 2688 2689 2690 2691
        // if (e.detail.value == '1') {//非学历教育
        //   reducetypeData.selected = '年度'
        //   // reducetypeData.disabled = true 
        //   deduction_amount = Deduce_amounts_year['continuing_education_non']
        // }else {
        //   // reducetypeData.disabled = false 
        //   reducetypeData.selected = '月度'
        //   deduction_amount = Deduce_amounts_month['continuing_education']
        // }
wangyu authored
2692 2693
        this.setData({
          edu_lable: e.detail.value == 0 ? 'school' : 'tech',
pangy authored
2694
          edutypeData: edutypee_data,
pangy authored
2695 2696
          // reducetypeData: reducetypeData,
          // deduction_amount: deduction_amount
wangyu authored
2697 2698
        })
        break;
wangyu authored
2699 2700 2701
      case 'edu_style':
        var edustyle_data = this.data.edustyleData
        edustyle_data.selected = edustyle_data.values[e.detail.value]
pangy authored
2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712
        var certificateDate = this.data.certificateDate
        certificateDate.values = e.detail.value == '0' ? this.profs_cers : this.major_cers
        certificateDate.selected = ''
        this.setData({
          edustyleData: edustyle_data,
          certificateDate: certificateDate
        })
        break;
      case 'certificate':
        var certificateDate = this.data.certificateDate
        certificateDate.selected = certificateDate.values[e.detail.value]
wangyu authored
2713
        this.setData({
pangy authored
2714
          certificateDate: certificateDate
wangyu authored
2715 2716 2717 2718 2719 2720 2721 2722 2723
        })
        break;
      case 'edu_level':
        var edulevel_data = this.data.edulevelData
        edulevel_data.selected = edulevel_data.values[e.detail.value]
        this.setData({
          edulevelData: edulevel_data
        })
        break;
wangyu authored
2724 2725 2726
      case 'apply_date':
        var apply_date = this.data.applydate
        apply_date.selected = e.detail.value
wangyu authored
2727
        apply_date.datelong = Date.parse(new Date(e.detail.value)) / 1000,
wangyu authored
2728 2729 2730 2731
        console.log('apply_date', Date.parse(new Date(e.detail.value)))
        this.setData({
          applydate: apply_date
        })
2732 2733
        var selYear = apply_date.selected.substring(0, 4);
        if (selYear < 2019) {
pangy authored
2734
          this.showToast('发证(批准)日期须在2019年度内')
2735 2736
          return
        }
wangyu authored
2737
        break;
2738 2739 2740 2741 2742 2743 2744 2745 2746
      case 'ownercardtype':
        var cardtypeData = this.data.cardtypeData
        var new_type = cardtypeData.values[e.detail.value]
        if (new_type != cardtypeData.selected) {
          this.dealCardType(new_type, 'ownercardtype')
          this.setData({
            owner_id_card_no: ""
          })
        }
wangyu authored
2747 2748 2749 2750 2751 2752 2753 2754
        break;
      case 'identify_type':
        var identifytype_Data = this.data.identifytypeData
        identifytype_Data.selected = identifytype_Data.values[e.detail.value]
        this.setData({
          identifytypeData: identifytype_Data
        })
        break;
wangyu authored
2755 2756
      case 'before_marry':
        var beforemarry_Data = this.data.beforemarryData
2757 2758 2759
        if (beforemarry_Data.selected == beforemarry_Data.values[e.detail.value]) {
          return
        }
wangyu authored
2760 2761 2762 2763
        beforemarry_Data.selected = beforemarry_Data.values[e.detail.value]
        this.setData({
          beforemarryData: beforemarry_Data
        })
2764
        this.handleBeforemarry('是' ==  beforemarry_Data.selected)
wangyu authored
2765 2766 2767 2768 2769 2770 2771 2772 2773
        break;
      case 'is_self_loan':
        var isself_Data = this.data.isselfData
        isself_Data.selected = isself_Data.values[e.detail.value]
        this.setData({
          isselfData: isself_Data
        })
        break;
wangyu authored
2774 2775 2776 2777 2778 2779 2780 2781 2782 2783
      case 'loan_type':
        var loantype_Data = this.data.loantypeData
        loantype_Data.selected = loantype_Data.values[e.detail.value]
        this.setData({
          loantypeData: loantype_Data
        })
        break;
      case 'payback_date':
        var firstpayback_Date = this.data.firstpaybackDate
        firstpayback_Date.selected = e.detail.value
pangy authored
2784
        firstpayback_Date.datelong = Date.parse(new Date(e.detail.value)) / 1000,
wangyu authored
2785 2786 2787 2788
        this.setData({
          firstpaybackDate: firstpayback_Date
        })
        break;
pangy authored
2789 2790 2791 2792 2793 2794 2795 2796
      case 'payback_date_2':
        var firstpayback_Date = this.data.firstpaybackDate_2
        firstpayback_Date.selected = e.detail.value
        firstpayback_Date.datelong = Date.parse(new Date(e.detail.value)) / 1000,
          this.setData({
            firstpaybackDate_2: firstpayback_Date
          })
        break;
wangyu authored
2797 2798 2799 2800 2801 2802 2803 2804 2805 2806
      case 'loan_datelong':
        var loandatelong_Data = this.data.loandatelongData
        loandatelong_Data.selected = loandatelong_Data.values[e.detail.value]
        this.setData({
          loandatelongData: loandatelong_Data
        })
        break;
      case 'lease_type':
        var leasetype_Data = this.data.leasetypeData
        leasetype_Data.selected = leasetype_Data.values[e.detail.value]
pangy authored
2807
        this.data.cardtypeData.hidden = leasetype_Data.selected == "组织"
wangyu authored
2808
        this.setData({
pangy authored
2809 2810
          leasetypeData: leasetype_Data,
          cardtypeData: this.data.cardtypeData
wangyu authored
2811 2812 2813 2814 2815
        })
        break;
      case 'lease_start_date':
        var leasestart_Date = this.data.leasestartDate
        leasestart_Date.selected = e.detail.value
pangy authored
2816
        leasestart_Date.datelong = Date.parse(new Date(e.detail.value)) / 1000,
wangyu authored
2817 2818 2819 2820 2821 2822 2823
        this.setData({
          leasestartDate: leasestart_Date
        })
        break;
      case 'lease_end_date':
        var leaseend_Date = this.data.leaseendDate
        leaseend_Date.selected = e.detail.value
pangy authored
2824
        leaseend_Date.datelong = Date.parse(new Date(e.detail.value)) / 1000,
wangyu authored
2825 2826 2827
        this.setData({
          leaseendDate: leaseend_Date
        })
2828 2829 2830 2831
        var activedDate = (Date.parse(new Date('2019-01-01')) / 1000)
        if (leaseend_Date.datelong < activedDate) {
          this.showToast('终止日期不符合要求,无法申报')
        }
wangyu authored
2832
        break;
pangy authored
2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846
      // case 'bank':
      //   var bank_data = this.data.bankInfo
      //   bank_data.selected = bank_data.values[e.detail.value]
      //   this.setData({
      //     bankInfo: bank_data
      //   })
      //   break;
      // case 'bank_2':
      //   var bank_data_2 = this.data.bankInfo_2
      //   bank_data_2.selected = bank_data_2.values[e.detail.value]
      //   this.setData({
      //     bankInfo_2: bank_data_2
      //   })
      //   break;
wangyu authored
2847 2848 2849 2850
      case 'house_locate':
        console.log('house_locate', e)
        var house_address = this.data.houseLocateInfo;
        house_address.address_value = e.detail.value
2851 2852 2853 2854 2855 2856
        if (e.detail.value[0] == e.detail.value[1]) {
          house_address.selected = e.detail.value[1] + e.detail.value[2]
        } else {
          house_address.selected = e.detail.value[0] + e.detail.value[1] + e.detail.value[2]

        }
wangyu authored
2857 2858
        house_address.address_value = e.detail.value
        house_address.address_code = e.detail.code
wangyu authored
2859
        this.setData({
wangyu authored
2860
          loanAddress_haschanged: true,
wangyu authored
2861 2862 2863
          houseLocateInfo: house_address
        })
        break;
wangyu authored
2864 2865 2866 2867 2868 2869 2870
      case 'working_city':
        console.log('working_city', e)
        var work_address = this.data.workingcityInfo;
        work_address.address_value = e.detail.value
        if (e.detail.value[0] == e.detail.value[1]) {
          work_address.selected = e.detail.value[1] + e.detail.value[2]
        } else {
wangyu authored
2871
          work_address.selected = e.detail.value[0] + e.detail.value[1]
wangyu authored
2872
        }
wangyu authored
2873 2874
        work_address.address_value = e.detail.value
        work_address.address_code = e.detail.code
pangy authored
2875 2876 2877 2878 2879 2880 2881 2882
        this.getCityLevel({
          'province_code': e.detail.code[0],
          'province': e.detail.value[0],
          'city_code': e.detail.code[1],
          'city': e.detail.value[1],
          'district_code': e.detail.code[2],
          'district': e.detail.value[2]
        })
wangyu authored
2883
        this.setData({
wangyu authored
2884
          workAddress_haschanged: true,
wangyu authored
2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896
          workingcityInfo: work_address
        })
        break;
      case 'rent_house_locate':
        console.log('rent_house_locate', e)
        var rent_address = this.data.rentLocateInfo;
        rent_address.address_value = e.detail.value
        if (e.detail.value[0] == e.detail.value[1]) {
          rent_address.selected = e.detail.value[1] + e.detail.value[2]
        } else {
          rent_address.selected = e.detail.value[0] + e.detail.value[1] + e.detail.value[2]
        }
wangyu authored
2897 2898
        rent_address.address_value = e.detail.value
        rent_address.address_code = e.detail.code
pangy authored
2899 2900 2901 2902 2903 2904 2905 2906
        // this.getCityLevel({
        //   'province_code': e.detail.code[0] ,
        //   'province': e.detail.value[0],
        //   'city_code': e.detail.code[1] ,
        //   'city': e.detail.value[1],
        //   'district_code': e.detail.code[2] ,
        //   'district': e.detail.value[2]
        // })
wangyu authored
2907
        this.setData({
wangyu authored
2908
          rentAddress_haschanged: true,
wangyu authored
2909
          rentLocateInfo: rent_address
wangyu authored
2910 2911 2912 2913 2914 2915 2916 2917
        })
        break;
    }
    // var educate_name = this.data.edu_array[e.detail.value]
    // this.setData({
    //   edu_name: educate_name
    // })
  },
pangy authored
2918 2919 2920 2921 2922 2923 2924 2925 2926
  getCityLevel:function(loc){
    var that = this;
    var Authorization = app.globalData.Authorization;
    wx.request({
      url: baseUrl + 'persontax/v1/house-rent-deductions',
      header: {
        'content-type': 'application/json',
        "Authorization": Authorization
      },
pangy authored
2927
      method:"POST",
pangy authored
2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943
      data: { 'address_codes': loc},
      success(res) {
        if (res && res.statusCode < 300) {
          that.setData({
            deduction_amount: res.data.amount
          })
        } else {
          wx.showToast({
            title: res.data.message ? res.data.message : '请求出错',
            icon: 'none'
          })
        }
      }
    })
  },
wangyu authored
2944
wangyu authored
2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017
  // goupload: function(e) {
  //   console.log(e)
  //   var that = this
  //   wx.chooseImage({
  //     sourceType: ['camera', 'album'],
  //     // sizeType: ['original'],
  //     count: 1,
  //     success: function(res) {
  //       console.log('success', res)
  //       that.setData({
  //         img_path: res.tempFilePaths[0]
  //       })
  //       that.uploadImage(that.data.img_path)
  //     }
  //   })
  // },

  // uploadImage: function(path) {
  //   var that = this
  //   wx.showLoading({
  //     title: '上传图片中...',
  //   })
  //   console.log('key', 'imagepath_' + path.substring(path.length - 10, path.length))
  //   wx.uploadFile({
  //     url: getApp().globalData.OSSUrl,
  //     filePath: path,
  //     name: 'file',
  //     formData: {
  //       'key': 'imagepath_' + path.substring(path.length - 15, path.length),
  //       'OSSAccessKeyId': OSSInit.access_key_id,
  //       'policy': OSSInit.policy,
  //       'signature': OSSInit.signature,
  //       'callback': OSSInit.callback_body,
  //       'x:access_token': OSSInit.callback_token,
  //       'success_action_status': '200',
  //     },
  //     success: function(res) {
  //       console.log('uploadFile', res.data)
  //       if (res.statusCode == 200) {
  //         var data = JSON.parse(res.data)
  //         console.log('上传成功', res)
  //         that.oss_bucket = data.bucket

  //       } else {
  //         var title = '图片上传失败,请重新上传'
  //         if (res.statusCode == 413) {
  //           title = '图片体积过大,请选择较小图片上传'
  //         }
  //         wx.showModal({
  //           title: '上传失败',
  //           content: title,
  //           showCancel: false,
  //           confirmColor: '#4E8FE7'
  //         })
  //       }
  //       wx.hideLoading()
  //     },
  //     fail: function(err) {
  //       console.log('fail', err)
  //       wx.showModal({
  //         title: '上传失败',
  //         content: '图片上传失败,请重新上传',
  //         showCancel: false,
  //         confirmColor: '#4E8FE7'
  //       })
  //       wx.hideLoading()
  //     },
  //     complete(res) {
  //       console.log('complete', res)
  //       wx.hideLoading()
  //     }
  //   })
  // },
wangyu authored
3018
wangyu authored
3019 3020 3021 3022 3023 3024 3025
  getWorkingAddressRequest: function() {
    var that = this
    if (that.data.workAddress_haschanged) {
      return {
        "province_code": that.data.workingcityInfo.address_code[0],
        "province": that.data.workingcityInfo.address_value[0],
        "city_code": that.data.workingcityInfo.address_code[1],
wangyu authored
3026 3027 3028
        "city": that.data.workingcityInfo.address_value[1],
        "district_code": "",
        "district": ""
wangyu authored
3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066
      }
    } else {
      return that.data.workingcityInfo.requestdata
    }
  },

  getRentAddressRequest: function() {
    var that = this
    if (that.data.rentAddress_haschanged) {
      return {
        "province_code": that.data.rentLocateInfo.address_code[0],
        "province": that.data.rentLocateInfo.address_value[0],
        "city_code": that.data.rentLocateInfo.address_code[1],
        "city": that.data.rentLocateInfo.address_value[1],
        "district_code": that.data.rentLocateInfo.address_code[2],
        "district": that.data.rentLocateInfo.address_value[2]
      }
    } else {
      return that.data.rentLocateInfo.requestdata
    }
  },

  getLoanAddressRequest: function() {
    var that = this
    if (that.data.loanAddress_haschanged) {
      return {
        "province_code": that.data.houseLocateInfo.address_code[0],
        "province": that.data.houseLocateInfo.address_value[0],
        "city_code": that.data.houseLocateInfo.address_code[1],
        "city": that.data.houseLocateInfo.address_value[1],
        "district_code": that.data.houseLocateInfo.address_code[2],
        "district": that.data.houseLocateInfo.address_value[2]
      }
    } else {
      return that.data.houseLocateInfo.requestdata
    }
  },
wangyu authored
3067 3068 3069 3070
  showToast: function(data) {
    if (data && data.length > 0) {
      wx.showToast({
        title: data,
3071 3072
        icon: "none",
        duration: 2000
wangyu authored
3073 3074 3075 3076
      })
    }
  },
wangyu authored
3077 3078 3079
  /**
   * Lifecycle function--Called when page hide
   */
wangyu authored
3080
  onHide: function() {
wangyu authored
3081 3082 3083 3084 3085 3086

  },

  /**
   * Lifecycle function--Called when page unload
   */
wangyu authored
3087
  onUnload: function() {
wangyu authored
3088 3089 3090 3091 3092 3093

  },

  /**
   * Page event handler function--Called when user drop down
   */
wangyu authored
3094
  onPullDownRefresh: function() {
wangyu authored
3095 3096 3097 3098 3099 3100

  },

  /**
   * Called when page reach bottom
   */
wangyu authored
3101
  onReachBottom: function() {
wangyu authored
3102 3103 3104 3105 3106 3107

  },

  /**
   * Called when user click on the top right corner to share
   */
wangyu authored
3108
  onShareAppMessage: function() {
wangyu authored
3109 3110

  }
wangyu authored
3111
wangyu authored
3112
})