|
|
// pages/EntryInformation/EntryInformation.js
|
|
|
const app = getApp();
|
|
|
Page({
|
|
|
data: {
|
|
|
sexArray: ['女', '男'],
|
|
|
card_Array: ['身份证', '护照', '出生证', '军官证', '港澳通行证'],
|
|
|
birth_date: '',
|
|
|
addsess_current: 0,
|
|
|
label_list: [],
|
|
|
list: {
|
|
|
name: '',
|
|
|
sex: '',
|
|
|
family_role: '',
|
|
|
money: '',
|
|
|
mobile: '',
|
|
|
birthday: '',
|
|
|
work: '',
|
|
|
work_address: '',
|
|
|
address: '',
|
|
|
mid: 0,
|
|
|
user_status: '',
|
|
|
status_num: '',
|
|
|
text: '',
|
|
|
},
|
|
|
label_ids: [],
|
|
|
familyid: 0, //家庭ID
|
|
|
hasimg: '',
|
|
|
DefId: ''
|
|
|
},
|
|
|
|
|
|
// 打电话
|
|
|
makePhoneCall() {
|
|
|
let that = this;
|
|
|
var list = that.data.list
|
|
|
var phoneNumber = list.mobile
|
|
|
wx.makePhoneCall({
|
|
|
phoneNumber: phoneNumber
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//设置查询的关键词
|
|
|
setKeyWord(e) {
|
|
|
let that = this;
|
|
|
that.setData({
|
|
|
KeyWord: e.detail.value
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//名字
|
|
|
setName(e) {
|
|
|
var list = this.data.list;
|
|
|
list.name = e.detail.value;
|
|
|
this.setData({
|
|
|
list: list
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//选择性别
|
|
|
selectSex(e) {
|
|
|
var list = this.data.list;
|
|
|
var sexArray = this.data.sexArray
|
|
|
list.sex = e.detail.value;
|
|
|
this.setData({
|
|
|
sex_index: e.detail.value,
|
|
|
list: list
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//选择家庭角色
|
|
|
familyRole(e) {
|
|
|
let list = this.data.list;
|
|
|
list.family_role = e.detail.value;
|
|
|
this.setData({
|
|
|
list: list
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//选择年收入
|
|
|
income(e) {
|
|
|
let list = this.data.list;
|
|
|
list.money = e.detail.value;
|
|
|
this.setData({
|
|
|
list: list
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//手机号
|
|
|
setMobile(e) {
|
|
|
let list = this.data.list;
|
|
|
list.mobile = e.detail.value;
|
|
|
this.setData({
|
|
|
list: list
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//出生日期
|
|
|
birthDate(e) {
|
|
|
var list = this.data.list;
|
|
|
list.birthday = e.detail.value;
|
|
|
this.setData({
|
|
|
birth_date: e.detail.value,
|
|
|
list: list
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//选择家庭角色
|
|
|
setWork(e) {
|
|
|
let list = this.data.list;
|
|
|
list.work = e.detail.value;
|
|
|
this.setData({
|
|
|
list: list
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//选择家庭角色
|
|
|
setworkAddress(e) {
|
|
|
let list = this.data.list;
|
|
|
list.work_address = e.detail.value;
|
|
|
this.setData({
|
|
|
list: list
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//设置家庭地址
|
|
|
setSddress(e) {
|
|
|
let list = this.data.list;
|
|
|
list.address = e.detail.value;
|
|
|
var address = list.address
|
|
|
if (this.data.familyid == 0) {
|
|
|
wx.setStorageSync('address', address)
|
|
|
}
|
|
|
this.setData({
|
|
|
list: list
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//通讯切换
|
|
|
addressCharge(e) {
|
|
|
var that = this;
|
|
|
var list = this.data.list
|
|
|
list.mid = e.target.dataset.current
|
|
|
if (this.data.addsess_current === e.target.dataset.current) {
|
|
|
return false;
|
|
|
} else {
|
|
|
that.setData({
|
|
|
addsess_current: e.target.dataset.current,
|
|
|
list: list
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
|
|
|
//选择证件类型
|
|
|
selectIdCard(e) {
|
|
|
let list = this.data.list;
|
|
|
var card_Array = this.data.card_Array
|
|
|
list.user_status = parseInt(e.detail.value) + 1;
|
|
|
this.setData({
|
|
|
card_index: e.detail.value,
|
|
|
list: list
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//选择家庭角色
|
|
|
setIdNum(e) {
|
|
|
let list = this.data.list;
|
|
|
list.status_num = e.detail.value;
|
|
|
this.setData({
|
|
|
list: list
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//用户描述
|
|
|
descript(e) {
|
|
|
let list = this.data.list;
|
|
|
list.text = e.detail.value;
|
|
|
this.setData({
|
|
|
list: list
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//添加成员标签
|
|
|
labelInfo() {
|
|
|
let that = this;
|
|
|
let url = 'counselor/DefAdd';
|
|
|
let params = {}
|
|
|
app.post(url, params).then((res) => {
|
|
|
if (res.data.code == 200) {
|
|
|
var list = this.data.list
|
|
|
that.setData({
|
|
|
label_list: res.data.data
|
|
|
})
|
|
|
}
|
|
|
}).catch((errMsg) => {
|
|
|
console.log(errMsg)
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//选择用户标签
|
|
|
selectLabel(e) {
|
|
|
var mindex = e.currentTarget.dataset.mindex
|
|
|
var sindex = e.currentTarget.dataset.sindex
|
|
|
var list = this.data.list
|
|
|
var id = e.currentTarget.dataset.id
|
|
|
var status = e.currentTarget.dataset.status
|
|
|
var label_list = this.data.label_list
|
|
|
var label_ids = this.data.label_ids;
|
|
|
|
|
|
//去重
|
|
|
const add = label_ids.every((label_ids) => {
|
|
|
return label_ids != id
|
|
|
})
|
|
|
// if (add) {
|
|
|
if (!(label_list[mindex].data[sindex].status)) {
|
|
|
label_ids.push(id)
|
|
|
} else {
|
|
|
for (var i = 0; i < label_ids.length; i++) {
|
|
|
// if (!(label_list[mindex].data[sindex].status)) {
|
|
|
if (label_list[mindex].data[sindex].id == label_ids[i]) {
|
|
|
label_ids.splice(i, 1);
|
|
|
console.log(11, label_ids)
|
|
|
}
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
|
// }
|
|
|
label_list[mindex].data[sindex].status = !(label_list[mindex].data[sindex].status)
|
|
|
this.setData({
|
|
|
label_list: label_list,
|
|
|
label_ids: label_ids
|
|
|
});
|
|
|
},
|
|
|
|
|
|
// 选择上传的图片
|
|
|
chooseImg() { //这里是选取图片的方法
|
|
|
var that = this;
|
|
|
wx.chooseImage({
|
|
|
count: 1,
|
|
|
success: (res) => {
|
|
|
var tempFilePaths = res.tempFilePaths
|
|
|
let url = '/users/upload'
|
|
|
let strtime = +new Date()
|
|
|
let params = {
|
|
|
picurl: tempFilePaths[0],
|
|
|
strtime: strtime,
|
|
|
token: app.strTime(strtime)
|
|
|
}
|
|
|
wx.uploadFile({
|
|
|
url: 'https://insurance.w.broteam.cn/pubilc/upload', //仅为示例,非真实的接口地址
|
|
|
filePath: tempFilePaths[0],
|
|
|
name: 'picurl',
|
|
|
formData: {
|
|
|
'strtime': strtime,
|
|
|
'token': app.strTime(strtime)
|
|
|
},
|
|
|
success: function(res) {
|
|
|
var data = JSON.parse(res.data);
|
|
|
var picurl = data.data.picurl;
|
|
|
picurl = picurl.indexOf('http') != '-1' ? picurl : "http://" + picurl
|
|
|
var list = that.data.list
|
|
|
list.picurl = picurl
|
|
|
that.setData({
|
|
|
hasimg: picurl,
|
|
|
list: list
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//成员信息的修改,新增
|
|
|
listVerify(e) {
|
|
|
let that = this;
|
|
|
var warn = "";
|
|
|
var flag = true;
|
|
|
var state = that.data.state
|
|
|
var list = this.data.list;
|
|
|
var sex_index = (this.data.sex_index)
|
|
|
var picurl = list.picurl
|
|
|
if (picurl == undefined) {
|
|
|
picurl = ''
|
|
|
}
|
|
|
|
|
|
|
|
|
// else if (list.mobile == '') {
|
|
|
// warn = '请填写您的手机号'
|
|
|
// } else if (!(/^[1][3,4,5,7,8][0-9]{9}$/.test(list.mobile))) {
|
|
|
// warn = "手机号格式不正确";
|
|
|
// }
|
|
|
|
|
|
if (list.name == "") {
|
|
|
warn = "请填写您的姓名";
|
|
|
} else if (sex_index == undefined) {
|
|
|
warn = "请填写您的性别";
|
|
|
} else if (list.family_role == '') {
|
|
|
warn = '请填写您的家庭角色'
|
|
|
} else if (list.birthday == '') {
|
|
|
warn = "请填选择您的出生日期"
|
|
|
} else {
|
|
|
flag = false; //若必要信息都填写,则不用弹框.正常调用接口
|
|
|
let paramlist = {
|
|
|
name: list.name,
|
|
|
sex: sex_index,
|
|
|
family_role: list.family_role,
|
|
|
money: list.money,
|
|
|
mobile: list.mobile,
|
|
|
birthday: list.birthday,
|
|
|
work: list.work,
|
|
|
work_address: list.work_address,
|
|
|
address: list.address,
|
|
|
mid: list.mid,
|
|
|
user_status: list.user_status,
|
|
|
status_num: list.status_num,
|
|
|
picurl: picurl,
|
|
|
text: list.text,
|
|
|
label_ids: this.data.label_ids,
|
|
|
family_id: that.data.familyid,
|
|
|
DefId: that.data.DefId,
|
|
|
UserId: app.globalData.UserId
|
|
|
}
|
|
|
let url = 'counselor/deflistdo'
|
|
|
app.post(url, paramlist).then((res) => {
|
|
|
console.log(res)
|
|
|
if (res.data.code == 200) {
|
|
|
wx.showToast({
|
|
|
title: '录入成功',
|
|
|
})
|
|
|
wx.setStorageSync('familyid', res.data.data.family_id)
|
|
|
setTimeout(() => {
|
|
|
if (this.data.familyid == 0) {
|
|
|
// wx.redirectTo({
|
|
|
// url: '/pages/index/CustomerManagement/CustomerManagement',
|
|
|
// })
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/index/addNewFamily/addNewFamily',
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
wx.navigateBack()
|
|
|
}
|
|
|
|
|
|
}, 1500)
|
|
|
// wx.navigateTo({
|
|
|
// url: '/pages/index/addNewFamily/addNewFamily?familyid=' + res.data.data.family_id,
|
|
|
// })
|
|
|
}
|
|
|
}).catch((errMsg) => {
|
|
|
console.log(errMsg)
|
|
|
})
|
|
|
}
|
|
|
if (flag == true) {
|
|
|
wx.showToast({
|
|
|
title: warn,
|
|
|
icon: 'none',
|
|
|
duration: 2000
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
|
|
|
|
|
|
//获取成员详细信息
|
|
|
getUserInfo() {
|
|
|
let that = this;
|
|
|
let url = 'counselor/deflist';
|
|
|
let params = {
|
|
|
DefId: that.data.DefId
|
|
|
}
|
|
|
app.post(url, params).then((res) => {
|
|
|
if (res.data.code == 200) {
|
|
|
var list = res.data.data.list
|
|
|
if (res.data.data.list.picurl != '') {
|
|
|
this.setData({
|
|
|
hasimg: true
|
|
|
})
|
|
|
}
|
|
|
var label_ids = this.data.label_ids
|
|
|
var label_list = res.data.data.label_list
|
|
|
for (var i = 0; i < label_list.length; i++) {
|
|
|
for (var j = 0; j < label_list[i].data.length; j++) {
|
|
|
if (label_list[i].data[j].status == 1) {
|
|
|
label_ids.push(label_list[i].data[j].id)
|
|
|
label_list[i].data[j].status = true
|
|
|
} else {
|
|
|
label_list[i].data[j].status = false
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
var list = res.data.data.list;
|
|
|
list.sex = res.data.data.list.sex;
|
|
|
that.setData({
|
|
|
list: list,
|
|
|
label_list: label_list,
|
|
|
sex_index: res.data.data.list.sex,
|
|
|
card_index: parseInt(res.data.data.list.user_status) - 1,
|
|
|
addsess_current: res.data.data.list.mid,
|
|
|
label_ids: label_ids
|
|
|
})
|
|
|
}
|
|
|
}).catch((errMsg) => {
|
|
|
console.log(errMsg)
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//获取家庭地址
|
|
|
getAddress() {
|
|
|
let that = this;
|
|
|
let url = 'counselor/addUserAds';
|
|
|
app.post(url, {
|
|
|
family_id: this.data.familyid
|
|
|
}).then((res) => {
|
|
|
if (res.data.code == 200) {
|
|
|
var list = that.data.list
|
|
|
list.address = res.data.data.address
|
|
|
list.mobile=res.data.data.mobile
|
|
|
that.setData({
|
|
|
list: list
|
|
|
})
|
|
|
}
|
|
|
}).catch((errMsg) => {
|
|
|
console.log(errMsg)
|
|
|
})
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function(options) {
|
|
|
this.labelInfo()
|
|
|
this.setData({
|
|
|
familyid: options.familyid
|
|
|
})
|
|
|
if (options.DefId == undefined) {
|
|
|
this.setData({
|
|
|
DefId: ''
|
|
|
})
|
|
|
} else {
|
|
|
this.setData({
|
|
|
DefId: options.DefId
|
|
|
})
|
|
|
this.getUserInfo();
|
|
|
}
|
|
|
|
|
|
if (this.data.familyid != '') {
|
|
|
this.getAddress()
|
|
|
}
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
|
onReady: function() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
|
onHide: function() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
onUnload: function() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
*/
|
|
|
onPullDownRefresh: function() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom: function() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
onShareAppMessage: function() {
|
|
|
|
|
|
}
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|