You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2542 lines
80 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

const {
getProjectByArea,
API_BASE_URL,
IMG_BASE_URL,
WU_TU_PIAN_URL,
getElectricPlanAll,
findAllPlan,
saveOrEditCustomerEntry,
entryDetail,
getAddressLonLat,
createQrcode,
resetMobileVsAuthPc,getFormSet,getTenantDetail,getCapital,getCompany,isByIdCode,getPartnerSet,getAllDictionarySelect,getPressureLevel
} = require('../../../api/api')
const utilAddWatermark = require('../../../utils/addWatermark')
const utilAddWatermark2 = require('../../../utils/addWatermark2')
const utilGetLocation = require('../../../utils/getLocation')
const utils = require('../../../utils/util')
const { routeLink } = require("../../../utils/route.js");
Page({
data: {
customId: '',
tenantType: 1,
API_BASE_URL: API_BASE_URL,
IMG_BASE_URL: IMG_BASE_URL,
capture: ['camera'], //拍摄模式
standardSolutionsList: [{
type: "", //方案类型
name: "", //方案名称
id: "", //方案ID
code: "", //方案编号
drawing: "", //参考图纸
}], //标准方案初始数量
combinedSolutionsList: [{
type: "", //方案类型
name: "", //方案名称
id: "", //方案ID
code: "", //方案编号
pickerIndex: 0, //方案类型选择下标
drawing: "", //参考图纸
addType: 1, //显示新增方案按钮
}], //组合方案初始数量
data: {
name: ""
},
photo: {
idCardFrontFileList: [], //身份证正面
idCardBackFileList: [], //身份证反面
bankCard: [], //银行卡照片
residenceBooklet: [], //户口本复印件
houseOwnership: [], //房产证
regnoUrl: [], //营业执照
bpCardFront: [], // 共签人身份证正面
bpCardBack: [], // 共签人身份证反面
bpFile: [], // 共签人子女证明材料
creditCertificate: [], //信誉凭证
//房屋照片
roofPhotoOne:'',//房屋正面
roofPhotoTwo:'',//东南角
roofPhotoThree:'',//西南角
roofPhotoFour:'',//正南侧
roofPhotoFacade:'',//生活气息照1
roofPhotoInterior:'',//生活气息照2
roofPhotoFive:'',//补充1
roofPhotoSix:'',//补充2
houseSupplementOne:'',//房屋补充1
houseSupplementTwo:'',//房屋补充2
//细节照片
roofPhotoSeven:'',//障碍物照片
dimensionsPhotoThickness:'',//楼顶厚度/围墙
detailSupplementOne:'',//细节补充1
detailSupplementTwo:'',//细节补充2
// 无人机拍摄
phoneOne: [], //俯拍图
phoneTwo: [], //角度南
phoneThree: [], //补充1
phoneFour: [], //补充2
// 手机拍摄
phoneFive: [], //东北
phoneSix: [], //东南
phoneSeven: [], //南侧
phoneEight: [], //西南
phoneNine: [], //补充1
phoneTen: [], //补充2
phoneVideo: [], //屋顶视频
phoneHouse: [], //房产证
//踏勘记录表
surveyPhoneOne: [], //踏勘记录表1
surveyPhoneTwo: [], //踏勘记录表2
filingPhone: [], //备案文件
//外观照片
outwardHousePhone: [], //房屋外观照片
inwardHousePhone: [], //房屋内部照片
roofHousePhone: [], //楼顶厚度照片
designPaper: "", //设计图纸
zjpbImg: [], //组件排布图
zjzxImg: [], // 组件走线图
zjcsImg: [], //支架侧视图
zjhsImg: [], //支架后视图
nbqwzImg: [], //逆变器位置
pdxwzImg: [], //配电箱位置
},
roofType: "", //屋顶类型
schemeType: 1, //默认为标准方案
shootType: 1, //默认为无人机拍摄
azimuth: 1, //方位角默认为正南
gender: 1, //默认为男
repaymentMethod: 1, //划转方式默认为二类卡
projectId: '',
isEdit: '0',
insuranceList: ["控制投放及续保", "控制投放", "其他"],
filingList: ['农户备案', '项目公司备案'],
customerType: '个人',
customerTypeList: [{
name: '个人',
value: 1
},{
name: '单位',
value: 2
}],
formSetObj: {},
isComplement: false, //默认不需要填写共签人信息
traderId: '',
capitalList: [],
capitalName: '',
capitalId: '',
companyId: '',
companyList: [],
companyName: '',
isExist: 0,
bpRelationList: [], //共签人与业主关系
productList: [{
projectId: '',
projectName: '',
projectCode: '',
payCycle: '',
roofType: ''
}], //产品信息
},
onLoad(e) {
if(e.navTitle){
wx.setNavigationBarTitle({
title: e.navTitle,
})
}
const projectId = e.projectId; //有projectId说明从列表进去,可能是修改或者是暂存过
const type = e.type
const surveyType = e.surveyType || ''
if (projectId) {
this.setData({
projectId,
entryId:e.projectId
})
}
if(wx.getStorageSync('capitalId')){
this.getFormSet(wx.getStorageSync('capitalId'))
this.getPartnerSet(wx.getStorageSync('capitalId'))
this.getDictionaryList(wx.getStorageSync('capitalId'))
}
this.setData({
type,
surveyType,
traderId: wx.getStorageSync('traderId'),
capitalId: wx.getStorageSync('capitalId')
})
this.getCapitalList()
this.getElectricPlanAll()
this.findAllPlan()
},
onReady() {
const query = wx.createSelectorQuery()
query.select('#Canvas')
.fields({
node: true,
size: true
})
.exec((res) => {
const canvas = res[0].node
this.setData({
canvas,
})
})
},
//去除输入内容中的空格
  checkInputSpace: function(e) {
    let name = e.currentTarget.dataset.name;
    let value = e.detail.value.replace(/\s+/g, '');
    this.setData({
      [name]:value
    });
  },
/**
*
* 获取电站详情
*
* @param {*} e
*/
entryDetail(e) {
let that = this
wx.showLoading({
title: "加载中"
})
entryDetail({
userId: wx.getStorageSync('userId'),
entryId: e.projectId
}).then((res) => {
this.getFormSet(res.management) //根据资方显示字段
this.getPartnerSet(res.management) //根据资方显示字段
wx.hideLoading()
var componentNum = 0;
if(res.management == '04'){//华融资方
this.setData({
componentList: [{
id: "",
num: "", //数量
model: "", //名称
addType: 1,
}], //组件初始数量
converterList: [{
id: "",
num: "", //数量
model: "", //名称
addType: 1,
}], //逆变器初始数量
cagesList: [{
id: "",
num: "", //数量
model: "", //名称
addType: 1,
}], //并网箱初始数量
supportList: [{
id: "",
num: "", //数量
model: "", //名称
addType: 1,
}], //支架初始数量
})
}else{
// 组件,逆变器,并网箱
if (res.componentList.length > 0) {
var componentList = [];
var converterList = [];
var cagesList = [];
var supportList = [];
for (let i = 0; i < res.componentList.length; i++) {
const element = res.componentList[i];
var OB = {
id: "",
num: "", //数量
model: "", //名称
addType: 0,
}
if (element.item_type == 3) {
OB.id = element.item_id;
OB.num = element.num;
OB.model = element.model;
componentNum = element.num * element.model + componentNum
componentList.push(OB)
} else if (element.item_type == 1) {
OB.id = element.item_id;
OB.num = element.num;
OB.model = element.model;
converterList.push(OB)
} else if (element.item_type == 2) {
OB.id = element.item_id;
OB.num = element.num;
OB.model = element.model;
cagesList.push(OB)
} else if (element.item_type == 4) {
OB.id = element.item_id;
OB.num = element.num;
OB.model = element.model;
supportList.push(OB)
}
}
//维持默认数组第一addType为1,用以显示新增按钮
if (componentList.length > 0) {
componentList[0].addType = 1;
this.setData({
componentList: componentList
})
} else {
this.setData({
componentList: [{
id: "",
num: "", //数量
model: "", //名称
addType: 1,
}], //组件初始数量
})
}
if (converterList.length > 0) {
converterList[0].addType = 1;
this.setData({
converterList: converterList
})
} else {
this.setData({
converterList: [{
id: "",
num: "", //数量
model: "", //名称
addType: 1,
}], //逆变器初始数量
})
}
if (cagesList.length > 0) {
cagesList[0].addType = 1;
this.setData({
cagesList: cagesList
})
} else {
this.setData({
cagesList: [{
id: "",
num: "", //数量
model: "", //名称
addType: 1,
}], //并网箱初始数量
})
}
if (supportList.length > 0) {
supportList[0].addType = 1;
this.setData({
supportList: supportList
})
} else {
this.setData({
supportList: [{
id: "",
num: "", //数量
model: "", //名称
addType: 1,
}], //支架初始数量
})
}
} else {
this.setData({
componentList: [{
id: "",
num: "", //数量
model: "", //名称
addType: 1,
}], //组件初始数量
converterList: [{
id: "",
num: "", //数量
model: "", //名称
addType: 1,
}], //逆变器初始数量
cagesList: [{
id: "",
num: "", //数量
model: "", //名称
addType: 1,
}], //并网箱初始数量
supportList: [{
id: "",
num: "", //数量
model: "", //名称
addType: 1,
}], //支架初始数量
})
}
}
this.setData({
componentNum: componentNum,
})
this.setData({
id: res.id, //修改数据的时候传此ID
customId: res.tenant_id?res.tenant_id:'',
projectId: res.project_id,
projectCode: res.projectCode,
projectName: res.projectName,
capitalId: res.zfId, //资方
capitalName: res.zfName,//资方
name: res.tenant_name,
phone: res.mobile,
idCard: res.id_code,
provinceName: res.province,
cityName: res.city,
areaName: res.area,
address: res.address,
longitude: res.longitude,
latitude: res.latitude,
roofType: res.roof_type,
shootType: res.shoot_type ? res.shoot_type : 1,
azimuth: res.azimuth ? res.azimuth : 1,
directionDeg: res.angle,
repaymentMethod: res.repayment_method ? res.repayment_method : 1,
deg: res.distance,
height: res.building_height,
remark: res.remarks,
schemeType: res.scheme_type ? res.scheme_type : 1,
solutionRemark: res.scheme_remarks,
'photo.designPaper': res.design_drawings ? res.design_drawings : "", //设计图纸
payCycle: res.pay_cycle,
companyName: res.project_company_name,
companyId: res.project_company_id,
age: res.age,
gender: res.gender == "MALE" ? "1" : "2",
customerType: res.tenant_type=='1'?'个人':'单位',
insuranceFlag: res.insurance_flag, // 保险购买情况:1.控制投放及续保 2.控制投放 3.其他
filingType: res.filing_type, // 备案类型:1.农户备案 2.项目公司备案
leaseDate: res.lease_date, //预计投放日
bpName: res.bp_name, //共签人名称
bpRelation: res.bp_relation, //共签人与业主关系
bpIdCard: res.bp_id_card, //共签人证件号码,不能与租户身份证号码相同
bpMobile: res.bp_mobile, //共签人手机号
bpAge: utils.getAgeByPid(res.bp_id_card),
bankName: res.bank_name, //卡账号名称
bankCode: res.bank_code, //卡账号
tssBankNum: res.tss_bank_num, //卡开户行
tssBankNumName: res.tss_bank_num_name, //卡开户行名称
estimateCapacity:res.estimate_capacity,//预估组件
tenantType: res.tenant_type, //租户分类: 1.个人 2.单位
corp: res.corp,//负责人姓名
regnoUrl: res.regnoUrl,//营业执照
regno: res.regno,//统一社会信用代码
provinceName: res.province,
cityName: res.city,
areaName: res.area,
exigenceName: res.exigence_name, //紧急联系人
exigencePhone: res.exigence_phone, //紧急联系人电话
birthdayDate: res.birthday_date, //出生日期
icValidityBegin: res.ic_validity_begin, //开始日期
icValidityEnd: res.ic_validity_end, //结束日期
windPressure: res.wind_pressure, //风压
snowPressure: res.snow_pressure, //雪压
pressureLevel: res.pressure_level, //风雪压等级
})
//华融资方-- 多产品处理
if(this.data.capitalId == '04'){
this.setData({
productList: res.projectList
})
}
this.getProjectList()
this.getCompanyList();
this.getDictionaryList(res.zfId)
if (res.insurance_flag == 1) {
this.setData({
insurance: "控制投放及续保"
})
} else if (res.insurance_flag == 2) {
this.setData({
insurance: "控制投放"
})
} else if (res.insurance_flag == 3) {
this.setData({
insurance: "其他"
})
}
if (res.filing_type == 1) { //如果是农户备案。只能选择二类卡
this.setData({
filingName: "农户备案",
repaymentMethod: 1
})
} else if (res.filing_type == 2) {
this.setData({
filingName: "项目公司备案"
})
}
//当业主年龄大于65岁时共签人信息必填,并且是开启overageFlag是否开启超龄1.开启 2.关闭
this.getPartnerSet(res.management,()=>{
if (res.overageFlag=='1' && res.age >= this.data.partnerSetObj.needSignerAge) {
this.setData({
isComplement: true
})
}else{
this.setData({
isComplement: false
})
}
})
if (res.longitude && res.latitude) {
this.setData({
longitudeAndLongitude: res.longitude + "," + res.latitude
})
}
if (res.scheme_type == 1) {
for (let i = 0; i < that.data.planList.length; i++) {
const element = that.data.planList[i];
if (res.scheme_type_id && (res.scheme_type_id == element.id)) {
this.setData({
standardSolutionsListIndex: i,
})
}
}
this.setData({
[`standardSolutionsList[0].id`]: res.scheme_id ? res.scheme_id : '',
[`standardSolutionsList[0].type`]: res.scheme_type_name ? res.scheme_type_name : '',
[`standardSolutionsList[0].typeId`]: res.scheme_type_id ? res.scheme_type_id : '',
[`standardSolutionsList[0].name`]: res.scheme_name ? res.scheme_name : "",
})
} else if (res.scheme_type == 2) {
if (res.composePlanList.length > 0) {
var combinedSolutionsList = []
for (let i = 0; i < res.composePlanList.length; i++) {
var combinedSolutionsListOB = {}
const element = res.composePlanList[i];
if (i == 0) {
combinedSolutionsListOB.addType = 1;
}
combinedSolutionsListOB.code = element.code;
combinedSolutionsListOB.id = element.planId;
combinedSolutionsListOB.name = element.name;
combinedSolutionsListOB.type = element.planType;
combinedSolutionsListOB.planTypeId = element.planTypeId;
for (let i = 0; i < that.data.planList.length; i++) {
const planTypeObj = that.data.planList[i];
if (planTypeObj.allPlan.length > 0) {
for (let j = 0; j < planTypeObj.allPlan.length; j++) {
const plan = planTypeObj.allPlan[j];
if (plan.id == element.planId) {
combinedSolutionsListOB.pickerIndex = i
}
}
}
}
combinedSolutionsList.push(combinedSolutionsListOB)
}
this.setData({
combinedSolutionsList: combinedSolutionsList
})
}
}
// 添加图片
if (res.shoot_type == 1) {
if (res.roof_photo_one) {
this.setData({
[`photo.phoneOne[0].name`]: res.roof_photo_one,
[`photo.phoneOne[0].url`]: this.data.IMG_BASE_URL + res.roof_photo_one,
})
}
if (res.roof_photo_two) {
this.setData({
[`photo.phoneTwo[0].name`]: res.roof_photo_two,
[`photo.phoneTwo[0].url`]: this.data.IMG_BASE_URL + res.roof_photo_two,
})
}
if (res.roof_photo_three) {
this.setData({
[`photo.phoneThree[0].name`]: res.roof_photo_three,
[`photo.phoneThree[0].url`]: this.data.IMG_BASE_URL + res.roof_photo_three,
})
}
if (res.roof_photo_four) {
this.setData({
[`photo.phoneFour[0].name`]: res.roof_photo_four,
[`photo.phoneFour[0].url`]: this.data.IMG_BASE_URL + res.roof_photo_four,
})
}
if (res.roof_value) {
this.setData({
[`photo.phoneVideo[0].name`]: res.roof_value,
[`photo.phoneVideo[0].url`]: this.data.IMG_BASE_URL + res.roof_value,
})
}
} else if (res.shoot_type == 2) {
if (res.roof_photo_one) {
this.setData({
[`photo.phoneSix[0].name`]: res.roof_photo_one,
[`photo.phoneSix[0].url`]: this.data.IMG_BASE_URL + res.roof_photo_one,
})
}
if (res.roof_photo_two) {
this.setData({
[`photo.phoneSeven[0].name`]: res.roof_photo_two,
[`photo.phoneSeven[0].url`]: this.data.IMG_BASE_URL + res.roof_photo_two,
})
}
if (res.roof_photo_three) {
this.setData({
[`photo.phoneEight[0].name`]: res.roof_photo_three,
[`photo.phoneEight[0].url`]: this.data.IMG_BASE_URL + res.roof_photo_three,
})
}
if (res.roof_photo_four) {
this.setData({
[`photo.phoneNine[0].name`]: res.roof_photo_four,
[`photo.phoneNine[0].url`]: this.data.IMG_BASE_URL + res.roof_photo_four,
})
}
if (res.roof_photo_five) {
this.setData({
[`photo.phoneTen[0].name`]: res.roof_photo_five,
[`photo.phoneTen[0].url`]: this.data.IMG_BASE_URL + res.roof_photo_five,
})
}
if (res.roof_value) {
this.setData({
[`photo.phoneVideo[0].name`]: res.roof_value,
[`photo.phoneVideo[0].url`]: this.data.IMG_BASE_URL + res.roof_value,
})
}
}
if (res.id_card_back) {
this.setData({
[`photo.idCardBackFileList[0].name`]: res.id_card_back,
[`photo.idCardBackFileList[0].url`]: this.data.IMG_BASE_URL + res.id_card_back,
})
}
if (res.id_card_front) {
this.setData({
[`photo.idCardFrontFileList[0].name`]: res.id_card_front,
[`photo.idCardFrontFileList[0].url`]: this.data.IMG_BASE_URL + res.id_card_front,
})
}
if (res.house_ownership) {
this.setData({
[`photo.phoneHouse[0].name`]: res.house_ownership,
[`photo.phoneHouse[0].url`]: this.data.IMG_BASE_URL + res.house_ownership,
})
}
if (res.survey_record) {
this.setData({
[`photo.surveyPhoneOne[0].name`]: res.survey_record,
[`photo.surveyPhoneOne[0].url`]: this.data.IMG_BASE_URL + res.survey_record,
})
}
if (res.survey_record2) {
this.setData({
[`photo.surveyPhoneTwo[0].name`]: res.survey_record2,
[`photo.surveyPhoneTwo[0].url`]: this.data.IMG_BASE_URL + res.survey_record2,
})
}
if (res.roof_photo_interior) {
this.setData({
[`photo.inwardHousePhone[0].name`]: res.roof_photo_interior,
[`photo.inwardHousePhone[0].url`]: this.data.IMG_BASE_URL + res.roof_photo_interior,
})
}
if (res.dimensions_photo_thickness) {
this.setData({
[`photo.roofHousePhone[0].name`]: res.dimensions_photo_thickness,
[`photo.roofHousePhone[0].url`]: this.data.IMG_BASE_URL + res.dimensions_photo_thickness,
})
}
if (res.filing_document_photo) {
this.setData({
[`photo.filingPhone[0].name`]: res.filing_document_photo,
[`photo.filingPhone[0].url`]: this.data.IMG_BASE_URL + res.filing_document_photo,
})
}
//户口本
if (res.residence_booklet) {
this.setData({
[`photo.residenceBooklet`]:res.residence_booklet ? res.residence_booklet.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [],
})
}
//房产证明
if (res.house_ownership) {
this.setData({
[`photo.houseOwnership`]:res.house_ownership ? res.house_ownership.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [],
})
}
//信誉凭证
if (res.credit_certificate) {
this.setData({
[`photo.creditCertificate`]:res.credit_certificate ? res.credit_certificate.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [],
})
}
if (res.bank_card) {
this.setData({
[`photo.bankCard[0].name`]: res.bank_card,
[`photo.bankCard[0].url`]: this.data.IMG_BASE_URL + res.bank_card,
})
}
if (res.zjpb_img) {
this.setData({
[`photo.zjpbImg[0].name`]: res.zjpb_img,
[`photo.zjpbImg[0].url`]: this.data.IMG_BASE_URL + res.zjpb_img,
})
}
if (res.zjzx_img) {
this.setData({
[`photo.zjzxImg[0].name`]: res.zjzx_img,
[`photo.zjzxImg[0].url`]: this.data.IMG_BASE_URL + res.zjzx_img,
})
}
if (res.zjcs_img) {
this.setData({
[`photo.zjcsImg[0].name`]: res.zjcs_img,
[`photo.zjcsImg[0].url`]: this.data.IMG_BASE_URL + res.zjcs_img,
})
}
if (res.zjhs_img) {
this.setData({
[`photo.zjhsImg[0].name`]: res.zjhs_img,
[`photo.zjhsImg[0].url`]: this.data.IMG_BASE_URL + res.zjhs_img,
})
}
if (res.nbqwz_img) {
this.setData({
[`photo.nbqwzImg[0].name`]: res.nbqwz_img,
[`photo.nbqwzImg[0].url`]: this.data.IMG_BASE_URL + res.nbqwz_img,
})
}
if (res.pdxwz_img) {
this.setData({
[`photo.pdxwzImg[0].name`]: res.pdxwz_img,
[`photo.pdxwzImg[0].url`]: this.data.IMG_BASE_URL + res.pdxwz_img,
})
}
if (res.bp_card_back) {
this.setData({
[`photo.bpCardBack[0].name`]: res.bp_card_back,
[`photo.bpCardBack[0].url`]: this.data.IMG_BASE_URL + res.bp_card_back,
})
}
if (res.bp_card_front) {
this.setData({
[`photo.bpCardFront[0].name`]: res.bp_card_front,
[`photo.bpCardFront[0].url`]: this.data.IMG_BASE_URL + res.bp_card_front,
})
}
//共签人子女证明材料
if (res.bp_file) {
this.setData({
[`photo.bpFile`]:res.bp_file ? res.bp_file.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [],
})
}
if (res.regnoUrl) {
this.setData({
[`photo.regnoUrl[0].name`]: res.regnoUrl,
[`photo.regnoUrl[0].url`]: this.data.IMG_BASE_URL + res.regnoUrl,
})
}
this.setData({
//房屋照片
[`photo.roofPhotoOne`]:res.roof_photo_one ? res.roof_photo_one : '',//房屋正面
[`photo.roofPhotoTwo`]:res.roof_photo_two ? res.roof_photo_two : '',//东南角
[`photo.roofPhotoThree`]:res.roof_photo_three ? res.roof_photo_three : '',//西南角
[`photo.roofPhotoFour`]:res.roof_photo_four ? res.roof_photo_four : '',//正南侧
[`photo.roofPhotoFacade`]:res.roof_photo_facade ? res.roof_photo_facade : '',//生活气息照1
[`photo.roofPhotoInterior`]:res.roof_photo_interior ? res.roof_photo_interior : '',//生活气息照2
[`photo.roofPhotoFive`]:res.roof_photo_five ? res.roof_photo_five : '',//补充1
[`photo.roofPhotoSix`]:res.roof_photo_six ? res.roof_photo_six : '',//补充2
[`photo.houseSupplementOne`]:res.house_supplement_one ? res.house_supplement_one : '',//房屋补充1
[`photo.houseSupplementTwo`]:res.house_supplement_two ? res.house_supplement_two : '',//房屋补充2
//细节照片
[`photo.roofPhotoSeven`]:res.roof_photo_seven ? res.roof_photo_seven : '',//障碍物照片
[`photo.dimensionsPhotoThickness`]:res.dimensions_photo_thickness ? res.dimensions_photo_thickness : '',//楼顶厚度/围墙
[`photo.detailSupplementOne`]:res.detail_supplement_one ? res.detail_supplement_one : '',//细节补充1
[`photo.detailSupplementTwo`]:res.detail_supplement_two ? res.detail_supplement_two : '',//细节补充2
});
})
},
/**
*
* 根据地址获取产品信息
*
* @param {*} e
*/
getProjectList(e) {
this.setData({
projectList: []
})
getProjectByArea({
province: this.data.provinceName,
city: this.data.cityName,
area: this.data.areaName,
userId: wx.getStorageSync('userId'),
type: 1,
filType: this.data.tenantType, //租户类型 1个人 2单位
projectId: this.data.capitalId, //资方
filingType: this.data.filingType?this.data.filingType:'', //备案类型1.农户2项目公司
}).then((res) => {
if(res.data){
this.setData({
projectList: res.data.map(itm=>itm.columns)
})
}
})
},
/**
*
* 获取投资方
*
* @param {*} e
*/
getCapitalList(e) {
getCapital({
traderId: wx.getStorageSync('traderId'),
}).then((res) => {
this.setData({
capitalList: res.data
})
})
},
/**
*
* 获取所属项目公司
*
* @param {*} e
*/
getCompanyList() {
getCompany({
projectId: this.data.projectId,
province: this.data.provinceName,
city: this.data.cityName,
area: this.data.areaName,
traderId: wx.getStorageSync('traderId'),
partner: this.data.capitalId, //资方
filingType: this.data.filingType?this.data.filingType:'', //备案类型
}).then((res) => {
if(res.code == 200){
if(res.data){
this.setData({
companyList: res.data.map(item=> item.columns)
})
}
}
})
},
/* 获取风雪压等级*/
getPressure(province,city,area) {
getPressureLevel({
province: this.data.provinceName,
city: this.data.cityName,
area: this.data.areaName,
}).then((res) => {
if(res.code == 200){
if(res.data){
this.setData({
windPressure: res.data.columns.wind_pressure, //风压
snowPressure: res.data.columns.snow_pressure, //雪压
pressureLevel: res.data.columns.pressure_level, //风雪压等级
})
}
}
})
},
bindByIdCode(e){
this.getIsByIdCode(e.detail.value)
},
/**
*
* 根据身份证号判断客户是否已存在
*
* @param {*} e
*/
getIsByIdCode(idCode) {
isByIdCode({
userId: wx.getStorageSync('userId'),
idCode: idCode
}).then((res) => {
if(res.code == 200){
this.setData({
phone: res.data.mobile,
isExist: res.data.status, //是否已存在,0不存在1已存在业务人员是当前用户2已存在业务人员不是当前用户
})
}
})
},
/**
*
* 获取自定义字段
*
* @param {*} e
*/
getFormSet(partner) {
getFormSet({
stage: '01', //01表示客户管理
partner: partner,
}).then((res) => {
this.setData({
formSetObj: res.data.columns
})
})
},
/**
*
* 获取资方共签人
*
* @param {*} e
*/
/*** 获取资方共签人 */
getPartnerSet(partner, callback) {
getPartnerSet({
partnerId: partner,
}).then((res) => {
this.setData({
partnerSetObj: res.data
})
if(callback) callback()
})
},
/*** 获取共签人关系 */
// getDictionaryList(partner, callback) {
// getDictionaryList({
// code: 'bp_relation',//哪个字段要传哪个字段的名称
// capitalId: partner,
// }).then((res) => {
// if(res.data){
// this.setData({
// bpRelationList: res.data.map(item=>item.columns)
// })
// }
// if(callback) callback()
// })
// },
/*选择共签人与业主关系*/
bindRelationList(e){
this.setData({
bpRelation: this.data.bpRelationList[e.detail.value].dict_value,
})
},
/**
*
* 获取组件、逆变器、并网箱列表
*
* @param {*} e
*/
getElectricPlanAll(e) {
getElectricPlanAll({
partnerId: this.data.capitalId,//资方
}).then((res) => {
var componentApiList = [];
var converterApiList = [];
var cagesApiList = [];
var supportApiList = [];
for (let i = 0; i < res.zjs.length; i++) {
const element = res.zjs[i].columns;
componentApiList.push(element)
}
for (let j = 0; j < res.inverters.length; j++) {
const element = res.inverters[j].columns;
converterApiList.push(element)
}
for (let k = 0; k < res.boxs.length; k++) {
const element = res.boxs[k].columns;
cagesApiList.push(element)
}
for (let m = 0; m < res.zhij.length; m++) {
const element = res.zhij[m].columns;
supportApiList.push(element)
}
this.setData({
componentApiList: componentApiList, //组件
converterApiList: converterApiList, //逆变器
cagesApiList: cagesApiList, //并网箱
supportApiList: supportApiList, //支架
})
})
},
/**
*
* 获取方案类型和方案名称
*
* @param {*} e
*/
findAllPlan(e) {
let that = this
findAllPlan({
}).then((res) => {
for (let i = 0; i < res.length; i++) {
if (res[i].allPlan) {
res[i].allPlan = JSON.parse(res[i].allPlan)
for (let j = 0; j < res[i].allPlan.length; j++) {
var element = res[i].allPlan[j].columns;
res[i].allPlan[j] = element
}
}
}
that.setData({
planList: res,
})
if (that.data.projectId) {
that.entryDetail({
projectId: that.data.projectId
})
that.setData({
isEdit: '1'
})
} else {
this.setData({
componentList: [{
id: "",
num: "", //数量
model: "", //名称
addType: 1,
}], //组件初始数量
converterList: [{
id: "",
num: "", //数量
model: "", //名称
addType: 1,
}], //逆变器初始数量
cagesList: [{
id: "",
num: "", //数量
model: "", //名称
addType: 1,
}], //并网箱初始数量
supportList: [{
id: "",
num: "", //数量
model: "", //名称
addType: 1,
}], //支架初始数量
componentNum: 0, //设置安装容量
})
}
})
},
/**
*
* 暂存提交数据
*
* @param {*} e
*/
submitFrom(e) {
var type = e.currentTarget.dataset.type
if (this.data.surveyType == 1 && type == 1) {
type = 3
}
// console.log(9898, this.data.capitalId, this.data.icValidityEnd, utils.isDate(this.data.icValidityEnd))
if (this.data.capitalId=='') {
wx.showToast({
title: '请选择投资方',
icon: 'none'
})
return
}
if (!this.data.name && this.data.customerType =='个人') {
wx.showToast({
title: '请输入姓名',
icon: 'none'
})
return
}
if (!this.data.name && this.data.customerType =='单位') {
wx.showToast({
title: '请输入单位名称',
icon: 'none'
})
return
}
if (!this.data.idCard && this.data.customerType =='个人') {
wx.showToast({
title: '请输入身份证号',
icon: 'none'
})
return
}
if(this.data.idCard && utils.idCard(this.data.idCard)){
wx.showToast({
title: '身份证号格式不正确',
icon: 'none'
})
return
}
if(this.data.birthdayDate && !utils.isDate(this.data.birthdayDate)){
wx.showToast({
title: '出生日期格式不正确',
icon: 'none'
})
return
}
if(this.data.icValidityBegin && !utils.isDate(this.data.icValidityBegin)){
wx.showToast({
title: '身份证生效日期格式不正确',
icon: 'none'
})
return
}
if(this.data.icValidityEnd && !utils.isDate(this.data.icValidityEnd)){
wx.showToast({
title: '身份证到期日期格式不正确',
icon: 'none'
})
return
}
if(this.data.phone && utils.validatePhoneNumber(this.data.phone)){
wx.showToast({
title: '手机号格式不正确',
icon: 'none'
})
return
}
if(this.data.exigencePhone && utils.validatePhoneNumber(this.data.exigencePhone)){
wx.showToast({
title: '紧急联系人手机号格式不正确',
icon: 'none'
})
return
}
// if(this.data.bankCode && utils.validateBankNum(this.data.bankCode)){
// wx.showToast({
// title: '银行卡格式不正确',
// icon: 'none'
// })
// return
// }
if(this.data.isComplement && this.data.customerType =='个人'){
if(this.data.bpIdCard && utils.idCard(this.data.bpIdCard)){
wx.showToast({
title: '共签人身份证号格式不正确',
icon: 'none'
})
return
}
if(this.data.bpAge<18 || this.data.bpAge>=this.data.partnerSetObj.signerConditionAge){
wx.showModal({
showCancel: false,
content: '共签人年龄必须在18-'+this.data.partnerSetObj.signerConditionAge+'周岁之间!',
complete: (res) => {
}
})
return
}
if(this.data.bpMobile && utils.validatePhoneNumber(this.data.bpMobile)){
wx.showToast({
title: '共签人手机号格式不正确',
icon: 'none'
})
return
}
}
if(this.data.isExist =='0'){
this.saveSubmit(type)
}else if(this.data.isExist =='1'){
wx.showModal({
confirmText: '继续提交',
content: '当前客户已录入建站信息,是否继续录入?',
complete: (res) => {
if (res.cancel) {}
if (res.confirm){
this.saveSubmit(type)
}
}
})
}else if(this.data.isExist =='2'){
wx.showModal({
showCancel: false,
confirmText: '取消',
content: '该客户已绑定其他业务员,您不能重复创建客户信息!',
complete: (res) => {}
})
return
}
},
saveSubmit(type){
wx.showLoading({
title: '提交中',
mask: true
})
var composePlanList = []; // 标准方案或组合方案
if (this.data.schemeType == 2) { //组合
this.data.combinedSolutionsList.forEach(element => {
var composePlanListOB = {}
if (element.planTypeId) {
composePlanListOB.code = element.code;
composePlanListOB.name = element.name;
composePlanListOB.planType = element.type;
composePlanListOB.planId = element.id;
composePlanListOB.planTypeId = element.planTypeId;
composePlanList.push(composePlanListOB)
}
});
}
var itemList = []; //组件 逆变器 并网箱 1:组件 2:逆变器 3:并网箱 4:组件
this.data.componentList.forEach(element => { //组件
if (element.id) {
var component = {}
component.itemType = 3;
component.itemId = element.id;
component.num = element.num
itemList.push(component)
}
});
this.data.converterList.forEach(element => { //逆变器
if (element.id) {
var component = {}
component.itemType = 1;
component.itemId = element.id;
component.num = element.num;
itemList.push(component)
}
});
this.data.cagesList.forEach(element => { //并网箱
if (element.id) {
var component = {}
component.itemType = 2;
component.itemId = element.id;
component.num = element.num;
itemList.push(component)
}
});
this.data.supportList.forEach(element => { //支架
if (element.id) {
var support = {}
support.itemType = 4;
support.itemId = element.id;
support.num = element.num;
itemList.push(support)
}
});
//华融资方-- 多产品处理
if(this.data.capitalId == '04'){
let productIds = this.data.productList.map(item=>item.projectId);
this.setData({
projectId: productIds.join(',')
})
}
/**
*
* 接口数据
*
*/
var userId = wx.getStorageSync('userId')
var CustomerEntry = {
type: type, //0:暂存 1:提交 3:初勘
composePlanLists: composePlanList.length > 0 ? composePlanList : [],
itemList: itemList.length > 0 ? itemList : [],
projectId: this.data.projectId, //项目ID
projectCode: this.data.projectCode, //产品编号
projectName: this.data.projectName, //产品名称
tenantName: this.data.name, //业主姓名
mobile: this.data.phone ? this.data.phone : "", //联系方式
gender: this.data.gender == 1 ? "MALE" : "FEMALE", //性别
age: this.data.age ? this.data.age : "", //年龄
tenantId: this.data.customId ? this.data.customId : "", //客户ID
filingType: this.data.filingType ? this.data.filingType : "", //备案类型 1.农户备案 2.项目公司备案
insuranceFlag: this.data.insuranceFlag ? this.data.insuranceFlag : "", // 保险购买情况:1.控制投放及续保 2.控制投放 3.其他
leaseDate: this.data.leaseDate ? this.data.leaseDate : "", //预计投放日
bpCardFront: this.data.photo.bpCardFront.length > 0 ? this.data.photo.bpCardFront[0].name : '', //共签人身份证正面
bpCardBack: this.data.photo.bpCardBack.length > 0 ? this.data.photo.bpCardBack[0].name : '', //共签人身份证反面
bpFile: this.data.photo.bpFile.length > 0 ? this.data.photo.bpFile.map(itm=>itm.name).join(",") : "", //共签人子女证明材料
bpName: this.data.bpName ? this.data.bpName : "", //共签人名称
bpRelation: this.data.bpRelation ? this.data.bpRelation : "", //共签人与业主关系
bpIdCard: this.data.bpIdCard ? this.data.bpIdCard : "", //共签人证件号码,不能与租户身份证号码相同
bpMobile: this.data.bpMobile ? this.data.bpMobile : "", //共签人手机号
// bankName: this.data.bankName ? this.data.bankName : "", //账号名称
bankName: this.data.name ? this.data.name : "", //账号名称
bankCode: this.data.bankCode ? this.data.bankCode : "", //账号
tssBankNum: this.data.tssBankNum ? this.data.tssBankNum : "", //开户行
tssBankNumName:this.data.tssBankNumName ? this.data.tssBankNumName : "", //开户行名称
residenceBooklet: this.data.photo.residenceBooklet.length > 0 ? this.data.photo.residenceBooklet.map(itm=>itm.name).join(",") : "", //户口本复印件
bankCard: this.data.photo.bankCard.length > 0 ? this.data.photo.bankCard[0].name : '', //银行卡照片
estimateCapacity: this.data.estimateCapacity ? this.data.estimateCapacity : '', //预估组件
creditCertificate: this.data.photo.creditCertificate.length > 0 ? this.data.photo.creditCertificate.map(itm=>itm.name).join(",") : "", //信誉凭证
exigenceName: this.data.exigenceName ? this.data.exigenceName : "", //紧急联系人
exigencePhone: this.data.exigencePhone ? this.data.exigencePhone : "", //紧急联系人电话
province: this.data.provinceName ? this.data.provinceName : "", //省
city: this.data.cityName ? this.data.cityName : "", //市
area: this.data.areaName ? this.data.areaName : "", //区
idCode: this.data.idCard ? this.data.idCard : "", //身份证号
birthdayDate: this.data.birthdayDate ? this.data.birthdayDate : "", //出生日期
icValidityBegin: this.data.icValidityBegin ? this.data.icValidityBegin : "", //身份证生效日
icValidityEnd: this.data.icValidityEnd ? this.data.icValidityEnd : "", //身份证到期日
address: this.data.address ? this.data.address.trim() : "", //详细地址
longitude: this.data.longitude ? this.data.longitude : "", //经度
latitude: this.data.latitude ? this.data.latitude : "", //纬度
corp: this.data.corp ? this.data.corp : "", //负责人姓名
regno: this.data.regno ? this.data.regno : "", //统一社会信用代码
regnoUrl: this.data.photo.regnoUrl.length > 0 ? this.data.photo.regnoUrl[0].name : '', //营业执照
tenantType: this.data.tenantType ? this.data.tenantType : "1", //租户分类
idCardFront: this.data.photo.idCardFrontFileList.length > 0 ? this.data.photo.idCardFrontFileList[0].name : '', //身份证正面
idCardBack: this.data.photo.idCardBackFileList.length > 0 ? this.data.photo.idCardBackFileList[0].name : '', //身份证反面
roofType: this.data.roofType, //屋顶类型
shootType: this.data.shootType, //拍摄方式
roofPhotoFive: this.data.shootType == 1 ? "" : this.data.photo.phoneTen.length > 0 ? this.data.photo.phoneTen[0].name : "", //房屋照片
roofValue: this.data.photo.phoneVideo.length > 0 ? this.data.photo.phoneVideo[0].name : "", //屋顶视频
houseOwnership: this.data.photo.houseOwnership.length > 0 ? this.data.photo.houseOwnership.map(itm=>itm.name).join(",") : "", //房产证照片
surveyRecord: this.data.photo.surveyPhoneOne.length > 0 ? this.data.photo.surveyPhoneOne[0].name : "", //踏勘记录表1
surveyRecord2: this.data.photo.surveyPhoneTwo.length > 0 ? this.data.photo.surveyPhoneTwo[0].name : "", //踏勘记录表2
filingDocumentPhoto: this.data.photo.filingPhone.length > 0 ? this.data.photo.filingPhone[0].name : "", //备案文件
distance: this.data.deg ? this.data.deg : "", //并网距离
azimuth: this.data.azimuth, //方位角
angle: this.data.azimuth != 1 ? this.data.directionDeg : "", //方位角角度
buildingHeight: this.data.height ? this.data.height : "", //建筑高度
repaymentMethod: this.data.repaymentMethod, //划转方式
remarks: this.data.remark ? this.data.remark : "", //备注
designDrawings: this.data.photo.designPaper ? this.data.photo.designPaper : "", //设计图纸,
zjpbImg: this.data.photo.zjpbImg.length > 0 ? this.data.photo.zjpbImg[0].name : "", //组件排布图
zjzxImg: this.data.photo.zjzxImg.length > 0 ? this.data.photo.zjzxImg[0].name : "", //组件走线图
zjcsImg: this.data.photo.zjcsImg.length > 0 ? this.data.photo.zjcsImg[0].name : "", //支架侧视图
zjhsImg: this.data.photo.zjhsImg.length > 0 ? this.data.photo.zjhsImg[0].name : "", //支架后视图
nbqwzImg: this.data.photo.nbqwzImg.length > 0 ? this.data.photo.nbqwzImg[0].name : "", //逆变器位置
pdxwzImg: this.data.photo.pdxwzImg.length > 0 ? this.data.photo.pdxwzImg[0].name : "", //配电箱位置
schemeType: this.data.schemeType, //设计方案
schemeTypeId: this.data.schemeType == 1 ? this.data.standardSolutionsList[0].typeId ? this.data.standardSolutionsList[0].typeId : "" : "", //当设计方案为标准方案时,传参
schemeTypeName: this.data.schemeType == 1 ? this.data.standardSolutionsList[0].type ? this.data.standardSolutionsList[0].type : "" : "",
schemeId: this.data.schemeType == 1 ? this.data.standardSolutionsList[0].id ? this.data.standardSolutionsList[0].id : "" : "",
schemeName: this.data.schemeType == 1 ? this.data.standardSolutionsList[0].name ? this.data.standardSolutionsList[0].name : "" : "",
schemeRemarks: this.data.solutionRemark ? this.data.solutionRemark : "", //方案备注
//房屋照片
roofPhotoOne: this.data.photo.roofPhotoOne,//房屋正面
roofPhotoTwo: this.data.photo.roofPhotoTwo,//东南角
roofPhotoThree: this.data.photo.roofPhotoThree,//西南角
roofPhotoFour: this.data.photo.roofPhotoFour,//正南侧
roofPhotoFacade: this.data.photo.roofPhotoFacade, //生活气息照1;
roofPhotoInterior: this.data.photo.roofPhotoInterior, //生活气息照2;
roofPhotoFive: this.data.photo.roofPhotoFive, //补充1
roofPhotoSix: this.data.photo.roofPhotoSix, //补充2
houseSupplementOne: this.data.photo.houseSupplementOne, //房屋补充1
houseSupplementTwo: this.data.photo.houseSupplementTwo, //房屋补充2
//细节照片
roofPhotoSeven: this.data.photo.roofPhotoSeven, //障碍物照片
dimensionsPhotoThickness: this.data.photo.dimensionsPhotoThickness, //楼顶厚度/围墙
detailSupplementOne: this.data.photo.detailSupplementOne, //细节补充1
detailSupplementTwo: this.data.photo.detailSupplementTwo, //细节补充2
zfId: this.data.capitalId, //资方
company: this.data.companyId,
//华融--多产品
projectList: this.data.productList,
windPressure: this.data.windPressure?this.data.windPressure:'', //风压
snowPressure: this.data.snowPressure?this.data.snowPressure:'', //雪压
pressureLevel: this.data.pressureLevel?this.data.pressureLevel:'', //风雪压等级
}
if (this.data.id) {
CustomerEntry.id = this.data.id
}
var data = {
userId: userId,
CustomerEntry: CustomerEntry,
}
// wx.hideLoading()
// console.log("暂存", data)
// return
if(type == '1'){
if ((this.data.partnerSetObj.overageFlag=='1' && this.data.age> this.data.partnerSetObj.failCreateAge) && this.data.customerType =='个人') {
wx.showToast({
title: '客户年龄超建站要求年龄,不允许提交',
icon: 'none',
duration: 2000
})
return
}
if(this.data.capitalId == '04'){
for(let i in this.data.productList){
if(this.data.productList[i].projectId == ''){
wx.showToast({
title: '产品名称不能为空',
icon: 'none'
})
return
}else if(this.data.productList[i].roofType == ''){
wx.showToast({
title: '屋顶类型不能为空',
icon: 'none'
})
return
}
}
}
}
saveOrEditCustomerEntry(data).then((res) => {
wx.hideLoading()
if (res.code == 200) {
wx.showToast({
title: type == '1' ? res.msg : "操作成功",
icon: 'none',
success: function () {
setTimeout(function () {
//延时返回上一页面
wx.navigateBack()
}, 1000) //延迟时间
}
})
} else if(res.code == 800) {
//发起变更手机号
let that = this;
wx.showModal({
content: res.errMsg,
success (rep) {
if (rep.confirm) {
console.log('用户点击确定')
wx.showLoading({
title: '提交中',
mask: true
});
resetMobileVsAuthPc({
entryId:that.data.entryId,//电站id
idCode:CustomerEntry.idCode,//身份证号
mobile:CustomerEntry.mobile,//手机号
userId:wx.getStorageSync('userId'),
}).then(ret=>{
wx.hideLoading()
if(ret.code == 200){
saveOrEditCustomerEntry(data).then((resq) => {
if (resq.code == 200) {
wx.showToast({
title: type == '1' ? resq.msg : "操作成功",
icon: 'none',
success: function () {
setTimeout(function () {
//延时返回上一页面
wx.navigateBack()
}, 1000) //延迟时间
}
})
}else{
// wx.showToast({
// title: resq.errMsg,
// icon: 'none'
// })
wx.showModal({
title: '',
content: resq.errMsg,
showCancel: false,
complete: (res) => {
if (res.cancel) {}
if (res.confirm) {}
}
})
}
});
}else{
wx.showModal({
title: '',
content: ret.errMsg,
showCancel: false,
complete: (res) => {
if (res.cancel) {}
if (res.confirm) {}
}
})
// wx.showToast({
// title: ret.errMsg,
// icon: 'none'
// });
}
});
} else if (rep.cancel) {
console.log('用户点击取消')
}
}
});
} else {
wx.showModal({
title: '',
content: res.errMsg,
showCancel: false,
complete: (res) => {
if (res.cancel) {}
if (res.confirm) {}
}
})
// wx.showToast({
// title: res.errMsg,
// icon: 'none'
// })
}
})
},
/**
*
* 取消
*
*/
cancel(e) {
wx.showModal({
title: '提示',
content: '确定取消?',
complete: (res) => {
if (res.cancel) {}
if (res.confirm) {
wx.navigateBack()
}
}
})
},
/**
*
* 上传图片
*
* @param {*} e
*/
afteruploadPhotoRead(e) {
const type = e.currentTarget.dataset.type
const name = e.currentTarget.dataset.name
// 手机拍摄和无人机拍摄照片添加水印
if (type == 2 || type == 3 || type == 4 || type == 5 || type == 7 || type == 8 || type == 9 || type == 10 || type == 11) {
if (!this.data.name) {
wx.showToast({
title: '请输入业主姓名',
icon: 'none'
})
return
}
this.data.data.name = this.data.name
this.getLocation(e)
return
}
//身份证明水印
if(type == '身份证明水印'){
const tempFilePath = e.detail.file.url;//图片路径
const photoName = e.currentTarget.dataset.name; //图片名称
utilAddWatermark2.addWatermark(tempFilePath,this.data).then((src) => {
this.data.photo[photoName].push(src)
this.setData({
[`photo.${photoName}`]: this.data.photo[photoName]
})
});
return;
}
if (Array.isArray(e.detail.file)) { //多张
var count = 0;
this.afteruploadPhotoReadS(e, count)
return
}
const {
file
} = e.detail;
const img = file.url;
wx.showLoading({
title: '上传中',
})
var that = this
wx.uploadFile({
url: that.data.API_BASE_URL + 'common/weChat/uploadImage',
filePath: file.url,
name: 'file',
complete: function (res) {
console.log("上传图片", res)
wx.hideLoading()
if (res.statusCode == 200) {
wx.showToast({
title: '选择成功',
icon: 'none',
})
var item = {
url: "",
name: "",
}
item.url = img;
item.name = res.data;
that.data.photo[name].push(item)
that.setData({
[`photo.${name}`]: that.data.photo[name]
})
console.log("上传图片", that.data.photo[name])
} else {
wx.showToast({
title: '选择失败',
icon: 'error'
})
}
}
})
},
/** 上传多张图片递归 **/
afteruploadPhotoReadS(e, count) {
let ob = {
name: '',
url: '',
}
const name = e.currentTarget.dataset.name
wx.showLoading({
title: '加载第' + (count + 1) + '张照片中',
mask: true,
})
const element = e.detail.file[count];
var that = this;
wx.uploadFile({
url: that.data.API_BASE_URL + 'common/weChat/uploadImage',
filePath: element.url,
name: 'file',
success(res) {
wx.hideLoading()
if (res.statusCode == 200) {
count = count + 1;
ob.name = res.data
ob.url = element.url
that.data.photo[name].push(ob);
that.setData({
[`photo.${name}`]: that.data.photo[name]
})
if (count == e.detail.file.length) {
wx.showToast({
title: '选择成功',
icon: 'none'
})
} else {
that.afteruploadPhotoReadS(e, count)
}
} else {
wx.showToast({
title: '选择失败',
icon: 'error'
})
}
}
})
},
/** 上传身份证正面OCR识别 **/
afteruploadPhotoReadPositive(e) {
const {
file
} = e.detail;
const img = file.url;
wx.showLoading({
title: '上传中',
})
var that = this
wx.uploadFile({
url: that.data.API_BASE_URL + 'common/weChat/uploadImageIden',
filePath: file.url,
name: 'file',
complete: function (res) {
wx.hideLoading()
if (res.statusCode == 200) {
const data = JSON.parse(res.data)
const OCRdata = JSON.parse(data.info)
// console.log(66,OCRdata)
if (OCRdata.code) {
wx.showToast({
title: OCRdata.errMsg,
icon: 'none',
})
return
}
wx.showToast({
title: '上传成功',
icon: 'none',
})
var item = {
url: "",
name: "",
}
// 渲染各自图片
switch (e.currentTarget.dataset.name) {
case "idCardFrontFileList": //身份证正面
if (OCRdata.data) { //OCR识别成功
if (OCRdata.data.face) {
if (OCRdata.data.face.data) {
if (OCRdata.data.face.data.name && e.currentTarget.dataset.type !=='fzr') {
that.setData({
name: OCRdata.data.face.data.name,
bankName: OCRdata.data.face.data.name,
})
}
if (OCRdata.data.face.data.name && e.currentTarget.dataset.type ==='fzr') {
that.setData({
corp: OCRdata.data.face.data.name,
})
}
if (OCRdata.data.face.data.idNumber) {
that.setData({
idCard: OCRdata.data.face.data.idNumber
})
if(that.data.customerType == '个人'){
that.getIsByIdCode(OCRdata.data.face.data.idNumber);
}
}
if (OCRdata.data.face.data.sex) {
if (OCRdata.data.face.data.sex == "男") {
that.setData({
gender: 1
})
} else if (OCRdata.data.face.data.sex == "女") {
that.setData({
gender: 2
})
}
}
if (OCRdata.data.face.data.birthDate) { //计算年龄
const date = new Date();
let birthDate = OCRdata.data.face.data.birthDate; //出生日期
birthDate = birthDate.replace('年', '-')
birthDate = birthDate.replace('月', '-')
birthDate = birthDate.replace('日', '')
// const year = OCRdata.data.face.data.birthDate; //出生日期
const age = utils.getAgeByPid(OCRdata.data.face.data.idNumber)
that.setData({
age: age,
birthdayDate: birthDate
})
//当业主年龄大于65岁时需填写共签人信息
if (that.data.partnerSetObj.overageFlag=='1' && age >= that.data.partnerSetObj.needSignerAge) {
// if (age >= 65) {
that.setData({
isComplement: true
})
}else{
that.setData({
isComplement: false
})
}
}
}
}else{
wx.showToast({
title: '请上传身份证正面',
icon: 'none'
})
return
}
}
//身份证明水印
// utilAddWatermark2.addWatermark(img,that.data).then((src) => {
// item = src;
// that.data.photo.idCardFrontFileList.push(item)
// that.setData({
// 'photo.idCardFrontFileList': that.data.photo.idCardFrontFileList
// })
// });
item.url = img;
item.name = data.path;
that.data.photo.idCardFrontFileList.push(item)
that.setData({
'photo.idCardFrontFileList': that.data.photo.idCardFrontFileList
})
break;
case "idCardBackFileList": //身份证反面
if (OCRdata.data) {
if (OCRdata.data.back) {
if (OCRdata.data.back.data) {
if (OCRdata.data.back.data.validPeriod) {
let icValidityBegin = OCRdata.data.back.data.validPeriod.substring(0,10)
icValidityBegin = icValidityBegin.replaceAll('.','-')
let icValidityEnd = OCRdata.data.back.data.validPeriod.substring(11,21)
if(icValidityEnd == '长期'){
icValidityEnd = '9999-12-31'
}else{
icValidityEnd = icValidityEnd.replaceAll('.', '-')
}
that.setData({
icValidityBegin: icValidityBegin,
icValidityEnd: icValidityEnd,
})
}
}
}else{
wx.showToast({
title: '请上传身份证反面',
icon: 'none'
})
return
}
}
item.url = img;
item.name = data.path;
that.data.photo.idCardBackFileList.push(item)
that.setData({
'photo.idCardBackFileList': that.data.photo.idCardBackFileList
})
break;
case "bpCardFront": //共签人身份证正面
if (OCRdata.data) {
if (OCRdata.data.face) {
if (OCRdata.data.face.data) {
if (OCRdata.data.face.data.name) {
that.setData({
bpName: OCRdata.data.face.data.name,
})
}
if (OCRdata.data.face.data.idNumber) {
that.setData({
bpIdCard: OCRdata.data.face.data.idNumber,
bpAge: utils.getAgeByPid(OCRdata.data.face.data.idNumber)
})
}
}
}
}
//身份证明水印
// utilAddWatermark2.addWatermark(img,that.data).then((src) => {
// item = src;
// that.data.photo.bpCardFront.push(item)
// that.setData({
// 'photo.bpCardFront': that.data.photo.bpCardFront
// })
// });
item.url = img;
item.name = data.path;
that.data.photo.bpCardFront.push(item)
that.setData({
'photo.bpCardFront': that.data.photo.bpCardFront
})
break;
}
} else {
wx.showToast({
title: '上传失败',
icon: 'error'
})
}
}
})
},
/** 上传银行卡OCR识别 **/
afteruploadPhotoReadCard(e) {
const {
file
} = e.detail;
const img = file.url;
wx.showLoading({
title: '上传中',
})
var that = this
wx.uploadFile({
url: that.data.API_BASE_URL + 'common/updateImgBankCard',
filePath: file.url,
name: 'file',
complete: function (res) {
wx.hideLoading()
if (res.statusCode == 200) {
const data = JSON.parse(res.data)
const OCRdata = JSON.parse(data.info)
// console.log(66,OCRdata)
if (OCRdata.code) {
wx.showToast({
title: OCRdata.errMsg,
icon: 'none',
duration: 2000
})
// return
}
// wx.showToast({
// title: '上传成功',
// icon: 'none',
// })
var item = {
url: "",
name: "",
}
if (OCRdata.data) { //OCR识别成功
if (OCRdata.data) {
if (OCRdata.data.cardNumber) {
that.setData({
bankCode: OCRdata.data.cardNumber,
})
}
}
}
item.url = img;
item.name = data.path;
that.data.photo.bankCard.push(item)
that.setData({
'photo.bankCard': that.data.photo.bankCard
})
} else {
wx.showToast({
title: '上传失败',
icon: 'error'
})
}
}
})
},
/** 删除图片 **/
deleteImg(e) {
const name = e.currentTarget.dataset.name
const index = (name != 'surveyFiles' && name != 'designDrawings') ? e.detail.index : e.currentTarget.dataset.index //删除图片的下标
this.data.photo[name].splice(index, 1);
this.setData({
[`photo.${name}`]: this.data.photo[name]
})
},
/**
*
* 上传pdf或图片
*
* @param {*} e
*/
upload(e) {
var that = this;
wx.chooseMessageFile({
count: 1,
type: 'all',
success(res) {
//获取文件后缀
let suffix = res.tempFiles[0].path.substring(res.tempFiles[0].path.lastIndexOf('.') + 1)
if (suffix.search(/jpg|png|jpeg|pdf/) == -1) {
wx.showToast({
title: '只能上传pdf文件或图片',
icon: 'none'
})
return
} else {
wx.showLoading({
title: '选择中',
})
wx.uploadFile({
url: that.data.API_BASE_URL + 'common/weChat/uploadImage',
filePath: res.tempFiles[0].path,
name: 'file',
complete: function (res) {
wx.hideLoading()
if (res.statusCode == 200) {
wx.showToast({
title: '选择成功',
icon: 'none'
})
that.setData({
'photo.designPaper': res.data
})
} else {
wx.showToast({
title: '选择失败',
icon: 'none'
})
}
}
})
}
}
})
},
/**
*
* 选择产品编号
*
* @param {*} ee
*/
bindprojectList(e) {
this.setData({
projectCode: this.data.projectList[e.detail.value].code,
projectName: this.data.projectList[e.detail.value].name,
projectId: this.data.projectList[e.detail.value].id,
// filingType: this.data.projectList[e.detail.value].filing_type,//备案类型:1.农户备案 2.项目公司备案
companyList: [],
companyName: '',
companyId: '',
payCycle: this.data.projectList[e.detail.value].pay_cycle
})
// this.getFormSet(this.data.projectList[e.detail.value].management)
if (this.data.projectList[e.detail.value].filing_type == 1) {
this.setData({
filingName: "农户备案",
filingType: 1,
repaymentMethod: 1,
})
} else if (this.data.projectList[e.detail.value].filing_type == 2) {
this.setData({
filingName: "项目公司备案",
filingType: 2,
repaymentMethod: 0,
})
}
this.getCompanyList(); //获取项目公司
},
/*选择客户类型*/
bindCustomerTypeList(e){
this.setData({
customId: '',
customerType: this.data.customerTypeList[e.detail.value].name,
tenantType: this.data.customerTypeList[e.detail.value].value,
tenantName: '',
name: '', //业主姓名
mobile: "", //联系方式
phone: '',
gender: "", //性别
age: "", //年龄
insuranceFlag: "", // 保险购买情况:1.控制投放及续保 2.控制投放 3.其他
leaseDate: "", //预计投放日
bankName: "", //账号名称
bankCode: "", //账号
tssBankNum: "", //开户行
tssBankNumName: "", //开户行名称
province: "", //省
city: "", //市
area: "", //区
provinceName: '',
cityName: '',
areaName: '',
idCode: "", //身份证卡号
birthdayDate: "", //出生日期
icValidityBegin: "", //身份证生效日
icValidityEnd: "", //身份证到期日
idCard: '',
address: "", //详细地址
corp: "", //负责人姓名
regno: "", //统一社会信用代码
regnoUrl: '', //营业执照
exigenceName: '', //紧急联系人
exigencePhone: '', //紧急联系人电话
[`photo.idCardFrontFileList`]: [], //身份证正面
[`photo.idCardBackFileList`]: [], //身份证反面
[`photo.bankCard`]: [], //银行卡照片
[`photo.residenceBooklet`]: [], //户口本复印件
[`photo.regnoUrl`]: [], //营业执照
[`photo.creditCertificate`]: [], //信誉凭证
projectId: '',
projectName: '',
projectCode: '',
companyName: '',
payCycle: '',
filingName: '',
})
this.getProjectList()
//华融资方
if(this.data.capitalId == '04'){
this.clearDataHR()
}
},
/*选择资方*/
bindCapitalList(e){
this.setData({
capitalId: this.data.capitalList[e.detail.value].id,
capitalName: this.data.capitalList[e.detail.value].name,
})
this.getFormSet(this.data.capitalList[e.detail.value].id)
this.getPartnerSet(this.data.capitalList[e.detail.value].id)
// this.getProjectList()
},
/*选择所属项目公司*/
bindCompany(e){
this.setData({
companyId: this.data.companyList[e.detail.value].id,
companyName: this.data.companyList[e.detail.value].name
})
},
/**
*
* 选择性别
*
* @param {*} e
*/
radioChangeSex(e) {
this.setData({
gender: e.detail.value
})
},
/**
*
* 打开省市区弹框
*
* @param {*} e
*/
bindRegionChange(e) {
this.setData({
showRegion: true
})
},
/**
*
* 打开开户行弹框
*
* @param {*} e
*/
bindBankLinkChange(e) {
this.setData({
showBankLink: true
})
},
/**
*
* 选择的地址
*
* @param {*} e
*/
chooseRegion(e) {
this.setData({
provinceName: e.detail.provinceName,
cityName: e.detail.cityName,
areaName: e.detail.areaName,
address: "",
projectId: '',
projectCode: '',
projectName: '',
payCycle: '',
filingName: '',
companyId: '',
companyName: '',
companyList:[]
})
this.getProjectList()
this.getCompanyList()
this.getPressure(e.detail.provinceName, e.detail.cityName, e.detail.areaName) //获取风雪压等级
//华融资方
if(this.data.capitalId == '04'){
this.clearDataHR()
}
},
/**
*
* 选择的开户行
*
* @param {*} e
*/
chooseBankLink(e) {
this.setData({
tssBankNum: e.detail.id,
tssBankNumName: e.detail.name,
})
},
/**
*
* 输入年龄
*
* @param {*} e
*/
inputAge(e) {
if (this.data.partnerSetObj.overageFlag=='1' && e.detail.value >= this.data.partnerSetObj.needSignerAge) {
// if (e.detail.value >= 65) {
this.setData({
isComplement: true
})
} else {
this.setData({
isComplement: false
})
}
this.setData({
age: e.detail.value
})
},
/**
*
*
* 获取用户当前地理位置后为照片添加水印
*
* @param {*} e
*/
getLocation(e) {
utilGetLocation.getLocationAddress().then((res) => {
res.res.data = res.res.data.slice(res.res.data.lastIndexOf('省') + 1)
this.setData({
customerAddress: res.res.data,
canvasLongitude: res.resLocation.longitude,
canvasLatitude: res.resLocation.latitude,
})
//获取小程序二维码
let lonLat = res.resLocation.longitude + ',' + res.resLocation.latitude;
createQrcode({
content:lonLat
}).then(ret=>{
let codeImg ="data:image/png;base64," + ret;
this.setData({
imageCodeImg:codeImg
});
// console.log("codeImg",codeImg);
this.chooseImages(e)
});
// this.chooseImages(e)
})
},
/**
*
* 获取当前位置信息 位置信息转经纬度
*
* @param {*} e
*/
getNowLocationDetails: utils.debounce(function (e) {
var that = this
if (that.data.region[0] && that.data.address) {
that.getAddressLonLat()
}
}),
getAddressLonLat() {
var that = this
wx.showLoading({
title: '加载中',
})
getAddressLonLat({
address: that.data.region[0] + that.data.region[1] + that.data.region[2] + that.data.address
}).then((res) => {
wx.hideLoading()
if (res.code == 200) {
if (res.data) {
var data = res.data.split(",")
that.setData({
longitude: data[0],
latitude: data[1],
longitudeAndLongitude: data[0] + "," + data[1]
})
}
} else {
wx.showToast({
title: '获取经纬度失败',
icon: 'none'
})
}
})
},
/** 选择图片为图片添加水印 **/
async chooseImages(e) {
const photoName = e.currentTarget.dataset.name; //图片名称
const tempFilePath = e.detail.file.url //图片路径
const canvasWidth = wx.getSystemInfoSync().screenWidth;
// 获取图片信息
await wx.getImageInfo({
src: tempFilePath,
}).then(async res => {
let watermarkScale = res.width / canvasWidth;
this.setData({
canvasHeight: Math.round(res.height / watermarkScale),
canvasWidth: canvasWidth,
})
await utilAddWatermark.addWatermark(tempFilePath, photoName, this.data).then((res) => {
this.data.photo[photoName].push(res)
this.setData({
[`photo.${photoName}`]: this.data.photo[photoName]
})
})
})
},
/**
*
*
* 打开pdf文件或者大图查看图片
*
*
* @param {*} res
*/
openDocument(res) {
let path = res.currentTarget.dataset.path
if (path) {
let suffix = path.substring(path.lastIndexOf('.') + 1) //获取文件后缀
if (suffix == 'pdf') {
wx.showLoading({
title: '加载中',
})
wx.downloadFile({
url: IMG_BASE_URL + path,
complete: function (res) {
wx.hideLoading()
const filePath = res.tempFilePath
wx.openDocument({
filePath: filePath,
showMenu: true,
success: function (res) {}
})
}
})
} else {
wx.previewImage({
urls: [IMG_BASE_URL + path] // 需要预览的图片http链接列表
})
}
}
},
/**
*
*/
estimateCapacityInput(e){
return this.checkInputText(e.detail.value);
},
//检查输入文本限制只能为数字并且数字最多带2位小数
checkInputText: function (text) {
var reg = /^(\.*)(\d+)(\.?)(\d{0,2}).*$/g; if (reg.test(text)) { //正则匹配通过,提取有效文本
text = text.replace(reg, '$2$3$4');
} else { //正则匹配不通过,直接清空
text = '';
} return text; //返回符合要求的文本为数字且最多有带2位小数
},
//选择客户
changeCustom(e){
let customerType = e.currentTarget.dataset.type
let tenantType = '1'
if(customerType =='个人'){
tenantType = '1'
}else{
tenantType = '2'
}
routeLink("/home/pages/customList/customList?tenantType=" + tenantType);
},
/*校验地址是否为空*/
checkAddress(){
if(!this.data.provinceName || !this.data.cityName || !this.data.areaName){
wx.showToast({
title: '请先选择安装地址',
icon: 'none'
});
}
},
/*华融--校验地址是否为空*/
checkAddressHR(){
if(!this.data.provinceName || !this.data.cityName || !this.data.areaName){
wx.showToast({
title: '请先选择安装地址',
icon: 'none'
});
}else if(!this.data.filingName){
wx.showToast({
title: '请先选择备案类型',
icon: 'none'
});
}
},
/*校验产品是否为空*/
checkProduct(){
if(!this.data.projectId){
wx.showToast({
title: '请先选择产品',
icon: 'none'
});
}
},
//根据customId获取详情
getCustomDetail(){
getTenantDetail({
id:this.data.customId,
}).then(res=>{
if(res.code==200){
if(res.data.tenantType =='1'){//个人
this.setData({
name: res.data.tenantName,
gender: res.data.gender == "MALE" ? "1" : "2",
age: utils.getAgeByPid(res.data.idCode),
idCard: res.data.idCode,
birthdayDate: res.data.birthdayDate1,
icValidityBegin: res.data.icValidityBegin1,
icValidityEnd: res.data.icValidityEnd1,
phone: res.data.mobile,
provinceName: res.data.province,
cityName: res.data.city,
areaName: res.data.area,
address: res.data.address,
[`photo.idCardBackFileList[0].name`]: res.data.idCardBack,
[`photo.idCardBackFileList[0].url`]: this.data.IMG_BASE_URL + res.data.idCardBack,
[`photo.idCardFrontFileList[0].name`]: res.data.idCardFront,
[`photo.idCardFrontFileList[0].url`]: this.data.IMG_BASE_URL + res.data.idCardFront,
})
if (this.data.partnerSetObj.overageFlag=='1' && utils.getAgeByPid(res.data.idCode) >= this.data.partnerSetObj.needSignerAge) {
// if (utils.getAgeByPid(res.data.idCode) >= 65) {
this.setData({
isComplement: true
})
}else{
this.setData({
isComplement: false
})
}
// this.getIsByIdCode(res.data.idCode)
}else{
this.setData({
name: res.data.tenantName,
corp: res.data.corp,
idCard: res.data.idCode,
phone: res.data.mobile,
regno: res.data.regno,
provinceName: res.data.province,
cityName: res.data.city,
areaName: res.data.area,
address: res.data.address,
[`photo.regnoUrl[0].name`]: res.data.regnoUrl,
[`photo.regnoUrl[0].url`]: this.data.IMG_BASE_URL + res.data.regnoUrl,
[`photo.idCardBackFileList[0].name`]: res.data.idCardBack,
[`photo.idCardBackFileList[0].url`]: this.data.IMG_BASE_URL + res.data.idCardBack,
[`photo.idCardFrontFileList[0].name`]: res.data.idCardFront,
[`photo.idCardFrontFileList[0].url`]: this.data.IMG_BASE_URL + res.data.idCardFront
})
}
this.setData({
projectId: '',
projectCode: '',
projectName: '',
payCycle: '',
filingName: '',
companyName: '',
companyList:[]
})
this.getProjectList()
this.getCompanyList()
}else{
wx.showToast({
title: res.msg,
icon:'none'
})
}
});
},
/*** 获取字典 */
getDictionaryList(partner, callback) {
getAllDictionarySelect({
capitalId: partner,
}).then((res) => {
if(res.data){
this.setData({
roofTypeList: res.data.roof_type.map(item=>item.columns), //屋顶类型
bpRelationList: res.data.bp_relation.map(item=>item.columns), //共签人关系
})
}
if(callback) callback(res.data)
})
},
//华融资方--添加产品
/**
*
* 选择产品编号
*
* @param {*} ee
*/
bindprojectListHR(e) {
let productList = this.data.productList
let index = e.currentTarget.dataset.index
this.setData({
[`productList[${index}].projectCode`]: this.data.projectList[e.detail.value].code,
[`productList[${index}].projectName`]: this.data.projectList[e.detail.value].name,
[`productList[${index}].projectId`]: this.data.projectList[e.detail.value].id,
[`productList[${index}].payCycle`]: this.data.projectList[e.detail.value].pay_cycle
})
},
addProd(e){
let prodList = this.data.productList
prodList.push({
projectId: '',
projectName: '',
projectCode: '',
paycycle: '',
roofType: ''
})
this.setData({
productList: prodList
})
},
//删除产品
delProd(e){
let index = e.currentTarget.dataset.index
let prodList = this.data.productList
prodList.splice(index,1)
this.setData({
productList: prodList
})
},
//华融--选择备案类型
bindfilingList(e) {
this.setData({
filingName: this.data.filingList[e.detail.value],
filingType: parseInt(e.detail.value) + 1
})
this.setData({
companyList: [],
companyName: '',
companyId: '',
})
//清空产品信息
this.clearDataHR()
this.getCompanyList()
this.getProjectList()
},
//屋顶类型下拉选择
changeRoofType(e) {
let dval = e.detail.value
let index = e.currentTarget.dataset.index
this.setData({
[`productList[${index}].roofType`]: this.data.roofTypeList[dval].dict_value,
})
},
//清空相关数据
clearDataHR(){
this.setData({
productList: [{
projectId: '',
projectName: '',
projectCode: '',
payCycle: '',
roofType: ''
}]
})
}
})