lookandupdate.js 11.0 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
// pages/main/addtionalreduce/childreneducate/childreneducate.js
var app = getApp();
var baseUrl = app.globalData.baseUrl;
var format = require('../../../../utils/util.js');
Page({

  /**
   * Page initial data
   */
  data: {
    cur_status: "",
    legal_entity_id: "",
    legal_entity: "",
    declareStatus: {
      "to_declare": "待申报",
      "declaring": "申报中",
      "success": "审核成功",
      "failed": "审核失败"
    },
    additiontitle: {
      "children_education": "子女教育",
      "continuing_education": "继续教育",
      "support_duty": "赡养老人",
      "medical_fund": "大病医疗",
      "house_fund": "住房"
    },
    title: '',
    imgpath: '',
    new_data: null,
    modal_images: {
      "children_education": "/images/childedu_declare.png",
      "continuing_education": "/images/continueedu_declare.png",
      "support_duty": "/images/support_older_declare.png",
      "medical_fund": "/images/health_declare.png",
      "house_fund": "/images/house_declare.png"
    },
    showModal_img: false,
    showModal_reducetype: false,
    showModal_addtype: false,
    url_arr: {
      "children_education": "persontax/v1/children-educations/",
      "continuing_education": "persontax/v1/continuing-educations/",
      "support_duty": "persontax/v1/support-duties/",
      "medical_fund": "persontax/v1/medical-funds/",
      "house_fund": "persontax/v1/house-funds/"
    },
    reducetype: {
      "month": "月度",
      "year": "年度"
    },
    additionInfo: [],
    reducetypeData: ["月度", "年度"],
    modalData: {},
    children_modalData: {
      title: "请选择子女进行申报",
      datas: [],
      lefttext: "添加新子女并申报",
      righttext: "确定为该子女申报",
    },
    support_older_modalData: {
      title: "请选择父母或祖父母进行申报",
      datas: [],
      lefttext: "添加被赡养人并申报",
      righttext: "确定为该被赡养人申报",
    },
    medical_modalData: {
      title: "请选择本人、配偶或子女进行大病支出申报",
      datas: [],
      lefttext: "添加家庭成员并申报",
      righttext: "确定为该选择的人申报",
    },
    selected_reduceindex: 0,
    selected_addindex: 0
  },

  /**
   * Lifecycle function--Called when page load
   */
  onLoad: function(options) {
    var that = this
    console.log("options", options);
    this.setData({
      cur_status: options.status,
      legal_entity_id: options.legal_entity_id,
      legal_entity: options.legal_entity
    })
    wx.setNavigationBarTitle({
      "title": that.data.additiontitle[options.status],
    })
  },

  /**
   * Lifecycle function--Called when page is initially rendered
   */
  onReady: function() {

  },

  /**
   * Lifecycle function--Called when page show
   */
  onShow: function() {
    var that = this
    this.getAdditionInfo()
    this.getTaxList()
  },

  getAdditionInfo() {
    var that = this;
    var Authorization = getApp().globalData.Authorization;
    wx.request({
      url: baseUrl + that.data.url_arr[that.data.cur_status] + that.data.legal_entity_id,
      header: {
        'content-type': 'application/json',
        "Authorization": Authorization
      },
      success: function(res) {
        if (res && res.data) {
          console.log("res", res)
          that.handleAddition(res.data)
        }
      }
    })
  },

  handleAddition: function(data) {
    var newdata = data.items
    for (var i = 0; i < newdata.length; i++) {
      if (newdata[i].education_start && newdata[i].education_start > 0) {
        newdata[i].education_start = format.formatTime_date(newdata[i].education_start)
      }
      if (newdata[i].education_end && newdata[i].education_end > 0) {
        newdata[i].education_end = format.formatTime_date(newdata[i].education_end)
      }
    }
    this.setData({
      additionInfo: newdata
    })
  },

  goaddSupporter: function() {
    wx.navigateTo({
      url: '../adddupporters/adddupporters?id=' + this.data.additionInfo[0].id,
    })
  },

  // lookimg: function() { //查看材料

  //   if (this.data.imgpath && this.data.imgpath.length > 0) {
  //     wx.previewImage({
  //       urls: [this.data.imgpath],
  //     })
  //   } else {
  //     wx.showToast({
  //       title: '暂无可查看资料',
  //     })
  //   }
  // },

  showdetail: function(e) {
    if (this.data.additionInfo && this.data.additionInfo.length > 0) {
      console.log("showdetail", JSON.stringify(this.data.additionInfo[e.currentTarget.id]))
      wx.navigateTo({
        url: '../additiondetail/additiondetail?datas=' +
          JSON.stringify(this.data.additionInfo[e.currentTarget.id]) + "&status=" + this.data.cur_status,
      })
    }
  },

  godelete: function(e) { //删除
    var that = this;
    var Authorization = getApp().globalData.Authorization;
    wx.request({
      url: baseUrl + 'persontax/v1/op/delete',
      data: {
        item_type: that.data.cur_status,
        id: that.data.legal_entity_id
      },
      header: {
        'content-type': 'application/json',
        "Authorization": Authorization
      },
      method: "POST",
      success: function(res) {
        if (res && res.data) {
          console.log("res", res)

        }
      }
    })
  },

  goedit: function(e) { //编辑
    console.log("goedit", e)
    if (this.data.additionInfo && this.data.additionInfo.length > 0) {
      wx.navigateTo({
        url: '../addextrainfo/addextrainfo?datas=' + '' + '&status=' + this.data.cur_status + '&reducetype=' + this.data.reducetypeData[this.data.selected_reduceindex] + '&isedit=true',
      })
    }
  },

  goadd: function(e) { //添加
    console.log("goadd", e)
    var that = this
    var modalinfo, senddata
    if (this.data.cur_status == 'continuing_education' || this.data.cur_status == 'house_fund') {
      wx.navigateTo({
        url: '../addextrainfo/addextrainfo?datas=' + '' + '&status=' + this.data.cur_status + '&reducetype=' + this.data.reducetypeData[this.data.selected_reduceindex],
      })
    } else {
      if (this.data.cur_status == 'children_education') { //modalData
        modalinfo = this.data.children_modalData
      } else if (this.data.cur_status == 'support_duty') {
        modalinfo = this.data.support_older_modalData
      } else if (this.data.cur_status == 'medical_fund') {
        modalinfo = this.data.medical_modalData
      }
      senddata = JSON.stringify(modalinfo.datas[e.currentTarget.id])
      console.log("modalinfo", modalinfo)
      if (modalinfo.datas.length > 0) {
        this.showAddtionmodal(modalinfo)
      } else {
        wx.navigateTo({
          url: '../addextrainfo/addextrainfo?status=' + this.data.cur_status + '&datas=' + senddata + '&reducetype=' + this.data.reducetypeData[this.data.selected_reduceindex],
        })
      }
    }
  },

  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: {
        'all': true
      },
      success: function(res) {
        console.log('succ', res)
        if (res.statusCode == 200) {
          that.handleData(res.data);
        }
      },
      fail(res) {
        console.log(res.data)
      },
      complete() {
        wx.hideLoading()
        that.setData({
          load_finish: true
        })
      }
    })
  },

  handleData: function(data) {

    if (data.items && data.items.length > 0) {
      var childRelativelist = []
      var medicalRelativelist = []
      var olderRelativelist = []
      var childmodal = this.data.children_modalData
      var oldermodal = this.data.support_older_modalData
      var medicalmodal = this.data.medical_modalData
      for (var i = 0; i < data.items.length; i++) {
        if (data.items[i].family_ties == '子' || data.items[i].family_ties == '女') {
          childRelativelist.push(data.items[i])
        } else if (data.items[i].family_ties != '祖父母' && data.items[i].family_ties != '外祖父母') {
          medicalRelativelist.push(data.items[i])
        } else if (data.items[i].family_ties == '祖父母' || data.items[i].family_ties == '外祖父母') {
          olderRelativelist.push(data.items[i])
        }
      }
      childmodal.datas = childRelativelist
      oldermodal.datas = olderRelativelist
      medicalmodal.datas = medicalRelativelist
      this.setData({
        children_modalData: childmodal,
        support_older_modalData: oldermodal,
        medical_modalData: medicalmodal
      })
    }
  },

  showModalImg: function(e) {
    console.log("showModalImg", e)
    this.setData({
      showModal_img: true,
    })
  },

  closeModalImg: function(e) {
    console.log("closeModalImg", e)
    this.setData({
      showModal_img: false
    })
  },

  // 扣除类型
  showModalReducetype: function(e) {
    console.log("reducetype", e)
    this.setData({
      showModal_reducetype: true,
    })
  },

  showAddtionmodal: function(modalinfo) {
    this.setData({
      modalData: modalinfo,
      showModal_addtype: true,
    })
  },

  reduce_modalLeft: function() { //modal取消(扣除类型)
    this.setData({
      showModal_reducetype: false
    })
  },

  reduce_modalRight: function() { //modal确认(扣除类型)
    this.setData({
      showModal_reducetype: false
    })
  },

  modalLeft: function() { //modal取消(添加)
    this.setData({
      showModal_addtype: false
    })
    wx.navigateTo({
      url: '../addextrainfo/addextrainfo?status=' + this.data.cur_status + '&datas=' + "" + '&reducetype=' + this.data.reducetypeData[this.data.selected_reduceindex],
    })
  },

  modalRight: function(e) { //modal确认(添加)
    console.log("modalConfirm", e)
    this.setData({
      showModal_addtype: false
    })
    var senddata = JSON.stringify(this.data.modalData.datas[this.data.selected_addindex])
    console.log("senddata", senddata)
    wx.navigateTo({
      url: '../addextrainfo/addextrainfo?status=' + this.data.cur_status + '&datas=' + senddata + '&reducetype=' + this.data.reducetypeData[this.data.selected_reduceindex],
    })

  },

  goselect: function(e) {
    console.log("goselect", e)
    if (this.data.showModal_reducetype) {
      this.setData({
        selected_reduceindex: e.currentTarget.id
      })
    }
    if (this.data.showModal_addtype) {
      this.setData({
        selected_addindex: e.currentTarget.id
      })
    }
  },

  /**
   * Lifecycle function--Called when page hide
   */
  onHide: function() {

  },

  /**
   * Lifecycle function--Called when page unload
   */
  onUnload: function() {

  },

  /**
   * Page event handler function--Called when user drop down
   */
  onPullDownRefresh: function() {

  },

  /**
   * Called when page reach bottom
   */
  onReachBottom: function() {

  },

  /**
   * Called when user click on the top right corner to share
   */
  onShareAppMessage: function() {

  }
})