Page({
  data: {
    currentIndex: 0,
    showBj:true,
    src1: '../../images/mz/5.png',
    src2: '../../images/mz/1.png',
    src3: '../../images/mz/6.png',
    src4: '../../images/mz/2.png',
    src5: '../../images/mz/7.png',
    src6: '../../images/mz/3.png',
    src7: '../../images/mz/8.png',
    src8: '../../images/mz/4.png',
    sexArr: [{
        value: '男',
        name: '男'
      },
      {
        value: '女',
        name: '女',
      }
    ],
    mzArr: ["汉族", "壮族", "满族", "回族", "苗族", "维吾尔族", "土家族", "彝族", "蒙古族", "藏族", "布依族", "侗族", "瑶族", "朝鲜族", "白族", "哈尼族",
      "哈萨克族", "黎族", "傣族", "畲族", "傈僳族", "仡佬族", "东乡族", "高山族", "拉祜族", "水族", "佤族", "纳西族", "羌族", "土族", "仫佬族", "锡伯族",
      "柯尔克孜族", "达斡尔族", "景颇族", "毛南族", "撒拉族", "布朗族", "塔吉克族", "阿昌族", "普米族", "鄂温克族", "怒族", "京族", "基诺族", "德昂族", "保安族",
      "俄罗斯族", "裕固族", "乌孜别克族", "门巴族", "鄂伦春族", "独龙族", "塔塔尔族", "赫哲族", "珞巴族"
    ],
    nameArr: [{
      name: "张三zhangsa"
    }],
    // tab1
    oldSex: ['男', '女'],
    oldMarry: [
      "未婚", "离婚", "离异", "丧偶"
    ],
    healthAyy: [{
      name: "健康",
      disabled: false,
      checked: false
    }, {
      name: "残疾",
      disabled: false,
      checked: false
    }, {
      name: "患重特大疾病",
      disabled: false,
      checked: false
    }, {
      name: "老年人慢性病",
      disabled: false,
      checked: false
    }],
    disabilityAyy: [
      "视力残疾", "听力残疾", "言语残疾", "肢体残疾", "智力残疾", "精神残疾", "多重残疾"
    ],
    sickType: [
      "重大器官类疾病", "心脑血管类疾病", "神经与代谢类疾病", "肢体与病毒类疾病", "恶性肿瘤"
    ],
    disableLeval: ["一级", "二级", "三级", "四级"],
    ableStatus: ["完全自理", "半失能(部分自理)", "完全失能"],
    moneyStatus: ["建档立卡贫困户", "一般家庭", "低保", "特困供养人员"],
    moneyFromAyy: ["家庭经营性收入", "工资性收入", "转移性收入", "财产性收入", "其它"],
    payMoney: ["5000元以下", "5000-10000元", "10000元以上"],
    familyHelpArr: [
      "低保", "建档立卡贫困户", "医疗救助", "临时救助", "老年人福利津贴", "残疾人两项补贴（或一项补贴)", "其他救助"
    ],
    loneArr: ["是", "否"],
    liveStatus: [{
      name: "无人陪伴居住",
      disabled: false,
      checked: false
    }, {
      name: "配偶",
      disabled: false,
      checked: false
    }, {
      name: "近亲属",
      disabled: false,
      checked: false
    }, {
      name: "未成年孙子女",
      disabled: false,
      checked: false
    }, {
      name: "其他情形",
      disabled: false,
      checked: false
    }],
    oftenMan: [{
      name: "无人照料",
      disabled: false,
      checked: false
    }, {
      name: "近亲属",
      disabled: false,
      checked: false
    }, {
      name: "配偶",
      disabled: false,
      checked: false
    }, {
      name: "邻里互助",
      disabled: false,
      checked: false
    }, {
      name: "购买养老服务",
      disabled: false,
      checked: false
    }, {
      name: "其他人员",
      disabled: false,
      checked: false
    }],
    lookafterSex: ["男", "女"],
    loveRequire: ["生活照料", "生产帮助", "精神慰藉", "医疗保健", "权益维护", "安全监护", "文化娱乐", "紧急救助", "其它"],
    oldType: [{
      name: "农村留守老年人",
      disable: false,
      checked: false
    }, {
      name: "分散供养特困老年人",
      disable: false,
      checked: false
    }, {
      name: "计划生育特殊家庭老人",
      disable: false,
      checked: false
    }, {
      name: "空巢老年人",
      disable: false,
      checked: false
    }, {
      name: "独居老年人",
      disable: false,
      checked: false
    }, {
      name: "重残老年人",
      disable: false,
      checked: false
    }, {
      name: "高龄老年人",
      disable: false,
      checked: false
    }],
    // tab2
    childNums: [
      '0个', '1个', '2个', '3个', '3个以上'
    ],
    //  tab3
    othersyrArr: ['是', '否'],
    othersyrSexArr: ['男', '女'],
    othersyrRelation: [
      "近亲属", "孙子女", "兄弟姐妹", "其他"
    ],
    othersyrIsout: ['是', '否'],
    region: ['', '', ''],
    customItem: '其它',
    othersyrIsMarry: ['是', '否'],
    othersyrTfTimes: [
      '0次', '1次', '2次及以上'
    ],
    // tab4
    visitWays: [{
      name: '电话问候'
    }, {
      name: '上门巡防'
    }, {
      name: '其它'
    }],
    visitTimes: [{
      name: '每天'
    }, {
      name: '每周'
    }, {
      name: '每月'
    }, {
      name: '每季'
    }, {
      name: '其它'
    }],
    // syrIndex:
  },
  // 左侧点击
  turn(e) {
    let index = e.currentTarget.dataset.index
    this.setData({
      currentIndex: index
    })
  },
  sure(){
    this.setData({
      showBj:false
    })
  },
  // 删除上方名字
  deleteName(e) {
    let index = e.currentTarget.dataset.index
    let arr = this.data.nameArr;
    arr.splice(index, 1)
    this.setData({
      nameArr: arr,
    })
  },
  tab1Change1: function (e) {
    if (e.detail.value == null || e.detail.value == '') {
      this.setData({
        oldName: true
      })
    } else {
      this.setData({
        oldName: false
      })
    }
  },
  // 性别单选
  tab1Change2(e) {
    console.log('radio发生change事件，携带value值为：', e.detail.value)
    const items = this.data.oldSex
    for (let i = 0, len = items.length; i < len; ++i) {
      items[i].checked = items[i].value === e.detail.value
    }
    this.setData({
      oldSex: items
    })
  },
  // 民族选择
  tab1Change3: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      mzIndex: e.detail.value
    })
  },
  // 身份证号
  tab1Change4: function (e) {
    if (e.detail.value == null || e.detail.value == '') {
      this.setData({
        oldCard: true
      })
    } else {
      this.setData({
        oldCard: false
      })
    }
  },
  // 联系电话
  tab1Change5: function (e) {
    if (e.detail.value == null || e.detail.value == '') {
      this.setData({
        oldPhone: true
      })
    } else {
      this.setData({
        oldPhone: false
      })
    }
  },
  // 健康状况
  tab1Change9: function (e) {
    console.log(this.data.healthAyy)
    console.log(e.detail.value)
    if (e.detail.value.length == 0) {
      this.setData({
        oldHealth1: true
      })
    } else {
      this.setData({
        oldHealth1: false
      })
    }
    let index = e.detail.value.indexOf('健康')
    let revise1 = "healthAyy[1].disabled";
    let revise2 = "healthAyy[2].disabled";
    let revise3 = "healthAyy[3].disabled";
    let rev1 = "healthAyy[1].checked";
    let rev2 = "healthAyy[2].checked";
    let rev3 = "healthAyy[3].checked";
    if (index >= 0) {
      this.setData({
        [revise1]: true,
        [revise2]: true,
        [revise3]: true,
        [rev1]: false,
        [rev2]: false,
        [rev3]: false
      })
    } else {
      this.setData({
        [revise1]: false,
        [revise2]: false,
        [revise3]: false
      })
    }
    let index1 = e.detail.value.indexOf('残疾')
    if (index1 >= 0) {
      this.setData({
        oldHealth2: true
      })
    } else {
      this.setData({
        oldHealth2: false,
        oldDisableType: false,
        issickTypeNull: false
      })
    }
    let index2 = e.detail.value.indexOf('患重特大疾病')
    if (index2 >= 0) {
      this.setData({
        isSick: true
      })
    } else {
      this.setData({
        isSick: false,
        oldDisableType: false,
        issickTypeNull: false
      })
    }
  },
  tab1Change10: function (e) {
    if (e.detail.value == null || e.detail.value == '') {
      this.setData({
        oldDisableType: true
      })
    } else {
      this.setData({
        oldDisableType: false
      })
    }
  },
  tab1Change10_1: function (e) {
    if (e.detail.value.length == 0) {
      this.setData({
        issickTypeNull: true
      })
    } else {
      this.setData({
        issickTypeNull: false
      })
    }
  },
  // 残疾等级
  tab2Change11: function (e) {
    this.setData({
      levalIndex: e.detail.value
    })
  },
  tab2Change12: function (e) {
    console.log(e.detail.value)
    this.setData({
      ableIndex: e.detail.value
    })
    if(e.detail.value==2){
      this.setData({oldType: this.data.oldType.concat({
        name: "失能老人",
        disable: true,
        checked: true
      })})
    }
  },
  tab2Change13: function (e) {
    this.setData({
      moneyIndex: e.detail.value
    })
  },
  tab1Change14: function (e) {
    // moneyOtherQt
    if (e.detail.value.length == 0) {
      this.setData({
        moneyFromOther: true
      })
    } else {
      this.setData({
        moneyFromOther: false
      })
    }
    let index = e.detail.value.indexOf('其它')
    if (index >= 0) {
      this.setData({
        moneyOtherQt: true
      })
    } else {
      this.setData({
        moneyOtherQt: false,
        moneyOtherQtnull: false
      })
    }

  },
  tab1Change14_1: function (e) {
    if (e.detail.value == null || e.detail.value == '') {
      this.setData({
        moneyOtherQtnull: true
      })
    } else {
      this.setData({
        moneyOtherQtnull: false
      })
    }
  },
  tab2Change15: function (e) {
    this.setData({
      payIndex: e.detail.value
    })
  },
  tab1Change16: function (e) {
    if (e.detail.value.length == 0) {
      this.setData({
        familyHelp: true
      })
    } else {
      this.setData({
        familyHelp: false
      })
    }
    let index = e.detail.value.indexOf('其他救助')
    if (index >= 0) {
      this.setData({
        familyHelpQt: true
      })
    } else {
      this.setData({
        familyHelpQt: false,
        otherhelpQtnull: false
      })
    }
  },
  tab1Change16_1: function (e) {
    if (e.detail.value == null || e.detail.value == '') {
      this.setData({
        otherhelpQtnull: true
      })
    } else {
      this.setData({
        otherhelpQtnull: false
      })
    }
  },
  tab1Change18: function (e) {
    if (e.detail.value.length == 0) {
      this.setData({
        isliveNull: true
      })
    } else {
      this.setData({
        isliveNull: false
      })
    }
    let index = e.detail.value.indexOf('无人陪伴居住')
    let index1 = e.detail.value.indexOf('其他情形')
    let revise1 = "liveStatus[1].disable";
    let revise2 = "liveStatus[2].disable";
    let revise3 = "liveStatus[3].disable";
    let revise4 = "liveStatus[4].disable";
    let rev1 = "liveStatus[1].checked";
    let rev2 = "liveStatus[2].checked";
    let rev3 = "liveStatus[3].checked";
    let rev4 = "liveStatus[4].checked";
    if (index >= 0) {
      this.setData({
        [revise1]: true,
        [revise2]: true,
        [revise3]: true,
        [revise4]: true,
        [rev1]: false,
        [rev2]: false,
        [rev3]: false,
        [rev4]: false
      })
    } else {
      this.setData({
        [revise1]: false,
        [revise2]: false,
        [revise3]: false,
        [revise4]: false
      })
    }
    if (index1 >= 0) {
      this.setData({
        isliveQt: true
      })
    } else {
      this.setData({
        isliveQt: false,
        isliveQtNull: false
      })
    }
  },
  tab1Change18_1: function (e) {
    if (e.detail.value == null || e.detail.value == '') {
      this.setData({
        isliveQtNull: true
      })
    } else {
      this.setData({
        isliveQtNull: false
      })
    }
  },
  tab1Change19: function (e) {
    console.log(e.detail.value)
    if (e.detail.value.length == 0) {
      this.setData({
        isoftenManNull: true
      })
    } else {
      this.setData({
        isoftenManNull: false

      })
    }
    let index = e.detail.value.indexOf('无人照料')
    let index1 = e.detail.value.indexOf('其他人员')
    let revise1 = "oftenMan[1].disabled";
    let revise2 = "oftenMan[2].disabled";
    let revise3 = "oftenMan[3].disabled";
    let revise4 = "oftenMan[4].disabled";
    let revise5 = "oftenMan[5].disabled";
    let rev1 = "oftenMan[1].checked";
    let rev2 = "oftenMan[2].checked";
    let rev3 = "oftenMan[3].checked";
    let rev4 = "oftenMan[4].checked";
    let rev5 = "oftenMan[5].checked";
    if (index >= 0) {
      this.setData({
        // ofenmanDetail: false,
        [revise1]: true,
        [revise2]: true,
        [revise3]: true,
        [revise4]: true,
        [revise5]: true,
        [rev1]: false,
        [rev2]: false,
        [rev3]: false,
        [rev4]: false,
        [rev5]: false
      })
    } else {
      this.setData({
        // ofenmanDetail: true,
        [revise1]: false,
        [revise2]: false,
        [revise3]: false,
        [revise4]: false,
        [revise5]: false
      })
    }
    if (index < 0 && e.detail.value.length != 0) {
      this.setData({
        ofenmanDetail: true
      })
    } else {
      this.setData({
        ofenmanDetail: false
      })
    }
    if (index1 >= 0) {
      this.setData({
        isoftenManQt: true
      })
    } else {
      this.setData({
        isoftenManQt: false,
        isoftenReaNull: false
      })
    }
  },
  tab1Change20: function (e) {
    if (e.detail.value == null || e.detail.value == '') {
      this.setData({
        isoftenReaNull: true
      })
    } else {
      this.setData({
        isoftenReaNull: false
      })
    }
  },
  tab1Change21: function (e) {
    if (e.detail.value == null || e.detail.value == '') {
      this.setData({
        lookAfterName: true
      })
    } else {
      this.setData({
        lookAfterName: false
      })
    }
  },
  tab1Change23: function (e) {
    if (e.detail.value == '' || e.detail.value == null) {
      this.setData({
        islookPhoneNull: true
      })
    } else {
      this.setData({
        islookPhoneNull: false
      })
    }
  },
  tab1Change24: function (e) {
    if (e.detail.value == '' || e.detail.value == null) {
      this.setData({
        isloveNull: true
      })
    } else {
      this.setData({
        isloveNull: false
      })
    }
    let index = e.detail.value.indexOf('其它')
    if (index >= 0) {
      this.setData({
        isloveQt: true
      })
    } else {
      this.setData({
        isloveQt: false,
        isloveQtNull: false
      })
    }
  },
  tab1change25: function (e) {
    if (e.detail.value == '' || e.detail.value == null) {
      this.setData({
        isloveQtNull: true
      })
    } else {
      this.setData({
        isloveQtNull: false,
      })
    }
  },
  tab1Change26: function (e) {
    console.log(e)
    if (e.detail.value == '' || e.detail.value == null) {
      this.setData({
        isoldtypeNull: true
      })
    } else {
      this.setData({
        isoldtypeNull: false,
      })
    }
    let index1 = e.detail.value.indexOf('农村留守老年人')
    let index2 = e.detail.value.indexOf('分散供养特困老年人')
    let index3 = e.detail.value.indexOf('计划生育特殊家庭老人')
    let index4 = e.detail.value.indexOf('空巢老年人')
    let revise1 = "oldType[0].disable";
    let revise2 = "oldType[1].disable";
    let revise3 = "oldType[2].disable";
    let revise4 = "oldType[3].disable";
    let rev1 = "oldType[0].checked";
    let rev2 = "oldType[1].checked";
    let rev3 = "oldType[2].checked";
    let rev4 = "oldType[3].checked";
    if (index1 >= 0) {
      this.setData({
        [revise2]: true,
        [revise3]: true,
        [revise4]: true
      })
      return false;
    } else {
      this.setData({
        [revise2]: false,
        [revise3]: false,
        [revise4]: false
      })
    }
    if (index2 >= 0) {
      this.setData({
        [revise1]: true,
        [revise3]: true,
        [revise4]: true
      })
      return false;
    } else {
      this.setData({
        [revise1]: false,
        [revise3]: false,
        [revise4]: false
      })
    }
    if (index3 >= 0) {
      this.setData({
        [revise1]: true,
        [revise2]: true,
        [revise4]: true
      })
      return false;
    } else {
      this.setData({
        [revise1]: false,
        [revise2]: false,
        [revise4]: false
      })
    }
    if (index4 >= 0) {
      this.setData({
        [revise1]: true,
        [revise2]: true,
        [revise3]: true
      })
      return false;
    } else {
      this.setData({
        [revise1]: false,
        [revise2]: false,
        [revise3]: false
      })
    }

  },
  // 子女个数
  tab2Change1: function (e) {
    console.log(typeof (e.detail.value))
    this.setData({
      childIndex: e.detail.value
    })
    if (e.detail.value != 4) {
      this.setData({
        childforTimes: Number(e.detail.value)
      })
    } else {
      this.setData({
        childforTimes: 3
      })
    }
  },
  // tab3是否有赡养人状态改变
  tab3Change1: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      syrIndex: e.detail.value
    })
    if (e.detail.value == 0) {
      this.setData({
        isHaveOther: true
      })
    } else {
      this.setData({
        isHaveOther: false
      })
    }
  },
  // 其他赡养人姓名
  tab3Change2: function (e) {
    console.log(e.detail.value)
    if (e.detail.value == null || e.detail.value == '') {
      this.setData({
        isothersyrName: true
      })
    } else {
      this.setData({
        isothersyrName: false
      })
    }
  },
  // 其他赡养人电话
  tab3Change4: function (e) {
    console.log(e.detail.value)
    if (e.detail.value == null || e.detail.value == '') {
      this.setData({
        isothersyrPhone: true
      })
    } else {
      this.setData({
        isothersyrPhone: false
      })
    }
  },
  // 与被赡养人关系状态改变
  tab3Change5: function (e) {
    this.setData({
      othersyrRelationIndex: e.detail.value
    })
    if (e.detail.value == 3) {
      this.setData({
        syrRelationQT: true
      })
    } else {
      this.setData({
        syrRelationQT: false
      })
    }
  },
  // 输选择其他时入与被赡养人其他关系
  tab3Change6: function (e) {
    if (e.detail.value == null || e.detail.value == '') {
      this.setData({
        isothersyRelation: true
      })
    } else {
      this.setData({
        isothersyRelation: false
      })
    }
  },
  // 是否外出状态改变
  tab3Change7: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      othersyrIsoutIndex: e.detail.value
    })
    if (e.detail.value == 0) {
      this.setData({
        showothersyrOut: true
      })
    } else {
      this.setData({
        showothersyrOut: false
      })
    }
  },
  // 外出原因
  tab3Change8: function (e) {
    if (e.detail.value == null || e.detail.value == '') {
      this.setData({
        isOutReason: true
      })
    } else {
      this.setData({
        isOutReason: false
      })
    }
  },
  // 外出地点改变
  tab3Change9: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      region: e.detail.value
    })
  },
  //最后一次离家时间
  tab3Change10: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      date: e.detail.value
    })
  },
  //是否有配偶
  tab3Change11: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      othersyrIsMarryIndex: e.detail.value
    })
    if (e.detail.value == 0) {
      this.setData({
        isMarry: true
      })
    } else {
      this.setData({
        isMarry: false
      })
    }
  },
  // 配偶姓名
  tab3Change12: function (e) {
    if (e.detail.value == null || e.detail.value == '') {
      this.setData({
        isMarryName: true
      })
    } else {
      this.setData({
        isMarryName: false
      })
    }
  },
  // 配偶电话
  tab3Change13: function (e) {
    if (e.detail.value == null || e.detail.value == '') {
      this.setData({
        isMarryPhone: true
      })
    } else {
      this.setData({
        isMarryPhone: false
      })
    }
  },
  //平均一年探望次数
  tab3Change14: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      othersyrTfTimesIndex: e.detail.value
    })
  },
  // tab4巡访方式状态改变
  tab4Change1(e) {
    let index = e.detail.value.indexOf('其它')
    if (e.detail.value.length == 0) {
      this.setData({
        isnull1: true
      })
    } else {
      this.setData({
        isnull1: false
      })
    }
    if (index >= 0) {
      this.setData({
        isVisitways: true
      })
    } else {
      this.setData({
        isVisitways: false,
        isVisitwaysnull: false
      })
    }
    const items = this.data.visitWays
    for (let i = 0, len = items.length; i < len; ++i) {
      items[i].checked = items[i].value === e.detail.value
    }
    this.setData({
      visitWays: items
    })
  },
  tab4Change2(e) {
    if (e.detail.value == null || e.detail.value == '') {
      this.setData({
        isVisitwaysnull: true
      })
    }else{
      this.setData({
        isVisitwaysnull: false
      })
    }
  },
  // tab4巡访频次状态改变
  tab4Change3(e) {
    console.log(e.detail.value)
    if (e.detail.value.length == 0) {
      this.setData({
        isnull2: true
      })
    } else {
      this.setData({
        isnull2: false
      })
    }
    if (e.detail.value == '其它') {
      this.setData({
        isVisittimes: true
      })
    } else {
      this.setData({
        isVisittimes: false,
        isVisittimesnull:false
      })
    }
    const items = this.data.visitTimes
    for (let i = 0, len = items.length; i < len; ++i) {
      items[i].checked = items[i].value === e.detail.value
    }
    this.setData({
      visitTimes: items
    })
  },
  tab4change4(e){
    if (e.detail.value == null || e.detail.value == '') {
      this.setData({
        isVisittimesnull: true
      })
    }else{
      this.setData({
        isVisittimesnull: false
      })
    }
  },
  formSubmit(e) {
    console.log('form发生了submit事件，携带数据为：', e.detail.value)
  },
  chooseAdress() {
    this.setData({
      adressShow: true
    })
  }

})