作者 刘晓艳

添加保单

// pages/Suggest/Suggest.js
const app=getApp();
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
list:[]
list: []
},
setcontent(e){
let list =this.data.list;
list.content = e.detail.value;
this.setData({
list:list
})
},
setreprt(e){
let list = this.data.list;
list.report = e.detail.value;
this.setData({
list: list
})
},
setcontent(e) {
let list = this.data.list;
list.content = e.detail.value;
this.setData({
list: list
})
},
setreprt(e) {
let list = this.data.list;
list.report = e.detail.value;
this.setData({
list: list
})
},
//查看预设建议列表
getAdviseLook(){
let that=this;
let url ='counselor/AdviseLook';
app.post(url, {
userId: app.globalData.UserId
// userId: 166
}).then((res)=>{
if(res.data.code==200){
that.setData({
list:res.data.data
getAdviseLook() {
let that = this;
let url = 'counselor/AdviseLook';
app.post(url, {
userId: app.globalData.UserId
}).then((res) => {
if (res.data.code == 200) {
that.setData({
list: res.data.data
})
}
}).catch((err) => {
console.log(err)
})
}
}).catch((err)=>{
console.log(err)
})
},
save_btn(){
let that=this;
let url ='counselor/AdviseSave';
let params={
userId: app.globalData.UserId,
report: that.data.list.report,
advise: that.data.list.content
}
app.post(url,params).then((res)=>{
console.log(res)
if(res.data.code==200){
wx.showToast({
title: '保存成功',
icon: 'none',
duration:2000,
},
save_btn() {
let that = this;
let url = 'counselor/AdviseSave';
let params = {
userId: app.globalData.UserId,
report: that.data.list.report,
advise: that.data.list.content
}
app.post(url, params).then((res) => {
console.log(res)
if (res.data.code == 200) {
wx.showToast({
title: '保存成功',
icon: 'none',
duration: 2000,
})
setTimeout(function() {
wx.navigateBack({
delta: 1,
})
}, 1000)
}
}).catch((err) => {
console.log(err)
})
setTimeout(function(){
wx.navigateBack({
delta: 1,
})
},1000)
}
}).catch((err)=>{
console.log(err)
})
},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let that=this;
that.getAdviseLook();
onLoad: function(options) {
let that = this;
that.getAdviseLook();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
let that = this;
that.getAdviseLook();
onShow: function() {
let that = this;
that.getAdviseLook();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
onShareAppMessage: function() {
}
})
\ No newline at end of file
... ...
... ... @@ -8,9 +8,9 @@
</view>
<view class='line_box'></view>
<view class='content_box'>
<view class='list_title'>体检报告预设</view>
<view class='list_title'>建议预设</view>
<view class='list_input'>
<textarea placeholder='请输入预设的体检报告' bindinput='setreprt' placeholder-class='pl_style'
<textarea placeholder='请输入预设的建议' bindinput='setreprt' placeholder-class='pl_style'
value='{{list.report}}'></textarea>
</view>
</view>
... ...
// pages/VipRecharge/VipRecharge.js
const app=getApp();
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
viplist:[],
toplist:[],
mainlist:[]
viplist: [],
toplist: [],
mainlist: []
},
//选择支付方式
buyWay(e) {
console.log(e)
console.log(e)
wx.navigateTo({
url: '../payWay/payWay?id=' + e.currentTarget.id + '&moneyt=' + e.currentTarget.dataset.moneyt,
url: '../payWay/payWay?id=' + e.currentTarget.id + '&moneyt=' + e.currentTarget.dataset.moneyt,
})
},
getvip(){
let that=this;
let url ='counselor/vip';
app.post(url,{}).then((res)=>{
if(res.data.code==200){
let viplist = res.data.data.viplist;
let toplist=[];
let mainlist=[];
for (let obj of viplist){
if (obj.status==1){
mainlist.push(obj)
} else if (obj.status == 2){
toplist.push(obj)
getvip() {
let that = this;
let url = 'counselor/vip';
app.post(url, {}).then((res) => {
if (res.data.code == 200) {
let viplist = res.data.data.viplist;
let toplist = [];
let mainlist = [];
for (let obj of viplist) {
if (obj.status == 1) {
mainlist.push(obj)
} else if (obj.status == 2) {
toplist.push(obj)
}
}
that.setData({
viplist: viplist,
toplist: toplist,
mainlist: mainlist
})
}
}
that.setData({
viplist: viplist,
toplist: toplist,
mainlist: mainlist
})
}
}).catch((err)=>{
console.log(err)
})
}).catch((err) => {
console.log(err)
})
},
... ... @@ -63,8 +65,8 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function() {
let that=this;
that.getvip();
let that = this;
that.getvip();
},
... ...
... ... @@ -21,7 +21,8 @@ Page({
name: ['受益人1', '受益人2'],
unit: ''
}],
tempfavoree: [],
tempfavoree: [], // 已选择的受益人
beneficiaryList: [],
beneficiaryindex: -1,
beneficiary_name: '',
imgs: [],
... ... @@ -36,7 +37,8 @@ Page({
risk_list: [{
name: '',
projectlist: [],
project_time: ''
project_time: '',
time: 1
}],
main_array: [],
warranty_one: [],
... ... @@ -45,6 +47,7 @@ Page({
long_money: [],
time_name: '',
type_money: '',
},
//投保人
... ... @@ -206,6 +209,7 @@ Page({
var main_array = []
var projectlist = Object.assign(this.data.projectlist, {})
for (var i = 0; i < projectlist.length; i++) {
if (projectlist[i].choose_status) {
main_array.push(projectlist[i])
}
... ... @@ -216,17 +220,20 @@ Page({
title: '添加成功',
icon: 'none'
})
if (type == 'fujiaxian') {
let tempRist = that.data.risk_list;
tempRist[index]['projectlist'] = main_array;
that.setData({
risk_list: tempRist,
})
} else {
that.setData({
main_array: main_array,
})
}
console.log(this.data.main_array)
// var temp = main_array
// for (var i = 0; i < main_array.length; i++) {
... ... @@ -280,22 +287,42 @@ Page({
beneficiarySelect(e) {
// console.log(e)
var index = e.currentTarget.dataset.mindex
var beneficiary_list = this.data.beneficiary_list;
for (var i = 0; i < beneficiary_list.length; i++) {
for (var j = 0; j < beneficiary_list[i].name.length; j++) {
var beneficiary_name = beneficiary_list[i].name[e.detail.value]
beneficiary_list[index].beneficiary_name = beneficiary_name
// console.log(beneficiary_list)
}
var beneficiary_list = Object.assign(this.data.beneficiary_list, {});
// 获取当前已选择的收益人
let tempBenefice = Object.assign(this.data.beneficiaryList, {})
// 当前选择的收益人
let nowPerson = beneficiary_list[index].name[e.detail.value];
// 判断受益人是否已经添加
const add = tempBenefice.every((tempBenefice) => {
return tempBenefice != nowPerson
})
console.log()
if (add) {
beneficiary_list[index].beneficiary_name = nowPerson;
tempBenefice.push(nowPerson)
} else {
wx.showToast({
title: '请不要重复添加受益人',
icon: 'none'
})
}
// for (var i = 0; i < beneficiary_list.length; i++) {
// for (var j = 0; j < beneficiary_list[i].name.length; j++) {
// var beneficiary_name =
// beneficiary_list[index].beneficiary_name = beneficiary_list[i].name[e.detail.value]
// // console.log(beneficiary_list)
// }
// }
// let tempRangArry = this.data.rang_beneficiary;
// tempRangArry[index] = beneficiary_list[index].name[e.detail.value]
// console.log(tempRangArry)
this.setData({
beneficiaryindex: e.detail.value,
beneficiary_list: beneficiary_list
beneficiary_list: beneficiary_list,
beneficiaryList: tempBenefice
})
},
... ... @@ -303,7 +330,6 @@ Page({
//添加收益比例
addUnit(e) {
// console.log(e)
var beneficiary_list = this.data.beneficiary_list;
beneficiary_list[beneficiary_list.length - 1].unit = e.detail.value;
this.setData({
... ... @@ -339,31 +365,48 @@ Page({
},
//重组添加受益人
tempBeneficiary() {
var beneficiary_list = this.data.beneficiary_list
var tempfavoree = this.data.tempfavoree
var temp = {}
var len = beneficiary_list.length
var len = beneficiary_list.length;
var tempfavoree1 = [];
for (var i = 0; i < beneficiary_list.length; i++) {
var temp = {}
if (beneficiary_list[i].unit != '') {
temp.name = beneficiary_list[i].beneficiary_name
temp.unit = beneficiary_list[i].unit
tempfavoree.push(temp)
temp.unit = beneficiary_list[i].unit;
}
var hash = {};
var temrecommend = tempfavoree.reduce(function(item, next) {
hash[next.name] ? '' : hash[next.name] = true && item.push(next);
return item
}, [])
// console.log(temrecommend)
tempfavoree1.push(temp)
// var hash = {};
// var temrecommend = tempfavoree.reduce(function (item, next) {
// hash[next.name] ? '' : hash[next.name] = true && item.push(next);
// return item
// }, [])
this.setData({
tempfavoree: temrecommend
tempfavoree: tempfavoree1
})
}
},
//删除收益人
deletebenefict(e) {
let index = e.currentTarget.dataset.index;
let tempbenefict = Object.assign(this.data.beneficiary_list, {});
let beneficiaryList = Object.assign(this.data.beneficiaryList, {});
// 获取当前选项的受益人
let person = tempbenefict[index].beneficiary_name;
tempbenefict.splice(index, 1);
if (person) beneficiaryList.splice(beneficiaryList.indexOf(person), 1)
this.setData({
beneficiaryList: beneficiaryList,
beneficiary_list: tempbenefict
})
},
//添加附加险
addRisk() {
var risk_list = Object.assign(this.data.risk_list, {});
... ... @@ -371,13 +414,23 @@ Page({
risk_list[len] = {
name: '',
projectlist: [],
project_time: ''
project_time: '',
time: ''
}
this.setData({
risk_list: risk_list
})
},
//删除附加险
deleteRisk(e) {
let index = e.currentTarget.dataset.index;
let risk_list = Object.assign(this.data.risk_list, {});
risk_list.splice(index, 1);
this.setData({
risk_list: risk_list
})
},
//上传图片
uploadImage() {
let that = this;
... ... @@ -503,7 +556,7 @@ Page({
var warranty_two = this.data.warranty_two
warranty_two.num = guarantee_name
warranty_two.title = unit
// console.log(warranty_two)
this.setData({
warranty_two: warranty_two
})
... ... @@ -533,54 +586,53 @@ Page({
var long_money = this.data.long_money
long_money.num = time_name
long_money.title = unit
console.log(long_money)
// console.log(long_money)
this.setData({
long_money: long_money
})
},
//计算缴费期满日
//计算缴费期满日,主线保障其
countImpletionTime() {
var time_name = parseInt(this.data.time_name)
var unit = this.data.unit2
var compact_time = this.data.compact_time
var year = parseInt(new Date(compact_time).getFullYear())
var month = parseInt(new Date(compact_time).getMonth())
var month = parseInt(new Date(compact_time).getMonth() + 1)
var day = parseInt(new Date(compact_time).getDate())
var runnian = ''
var cha=''
var impletion_time = this.data.impletion_time
var warranty_one = this.data.warranty_one
var birthday='1995-04-20'
var tempbirth_time = ''
var birthday = '1995-04-20'
var birthday_year = parseInt(new Date(birthday).getFullYear())
var tempbirth_time=''
if (unit == '年') {
var millSeconds = Math.abs(nDate) - (1 * 24 * 60 * 60 * 1000);
// runnian = parseInt(time_name / 4)
// cha = time_name - runnian
// var dateTemp = compact_time.split("-");
// var nDate = new Date(dateTemp[1] + '-' + dateTemp[2] + '-' + dateTemp[0]);
// var millSeconds = Math.abs(nDate) + (((cha * 365) + (runnian*366) )* 24 * 60 * 60 * 1000) - (1 * 24 * 60 * 60 * 1000);
// var rDate = new Date(millSeconds);
// var year = rDate.getFullYear();
// var month = rDate.getMonth() + 1;
// if (month < 10) month = "0" + month;
// var date = rDate.getDate();
// if (date < 10) date = "0" + date;
// console.log(year + "-" + month + "-" + date);
}else if(unit=='岁'){
var temp_year = (birthday_year + time_name - 1)
var temp_year = (year + time_name)
var temp_day = day - 1
if (month < 10) month = "0" + month;
if (temp_day < 10) temp_day = "0" + temp_day;
impletion_time = temp_year + '-' + month + '-' + temp_day
warranty_one = temp_year + '-' + month + '-' + temp_day
} else if (unit == '岁') {
var temp_year = (birthday_year + time_name - 1)
var temp_year2 = (birthday_year + time_name)
var temp_month = month
tempbirth_time = temp_year + '-' + temp_month + '-'+day
console.log(tempbirth_time)
if (temp_month < 10) temp_month = "0" + temp_month;
if (month < 10) month = "0" + month;
if (day < 10) day = "0" + day;
impletion_time = temp_year + '-' + temp_month + '-' + day
warranty_one = temp_year2 + '-' + month + '-' + day
} else if (unit == '终身') {
impletion_time = '终身缴费'
warranty_one = '终身'
}
this.setData({
impletion_time: impletion_time,
warranty_one: warranty_one
})
},
//缴费方式
... ... @@ -593,9 +645,12 @@ Page({
},
selectUnit4(e) {
var unit = e.currentTarget.dataset.unit
var unit = e.currentTarget.dataset.unit;
let index = e.currentTarget.dataset.index;
let risk_list = Object.assign(this.data.risk_list, {});
risk_list[index].time = unit
this.setData({
unit4: unit
risk_list: risk_list
})
},
... ... @@ -604,28 +659,29 @@ Page({
this.tempBeneficiary()
this.tempWarranty()
this.tempburningTime()
var warn = ""; //弹框时提示的内容
var flag = true; //判断信息输入是否完整判断弹窗
var in_num = e.detail.value.policy_num
var firm = e.detail.value.company;
var applicant = this.data.applicant_name
var recognizee = this.data.recognizee_name
var favoree = this.data.tempfavoree
var main_risks = e.detail.value.main_risks
var year_money = e.detail.value.year_money
var compact_time = this.data.compact_time
var impletion_time = this.data.impletion_time
var warranty_one = this.data.main_array
var warranty_two = this.data.warranty_two
var bank = e.detail.value.bank
var bank_num = e.detail.value.bank_num
var type_money = this.data.type_money
var long_money = this.data.long_money
var year_money = e.detail.value.year_money
// var coverage = e.detail.value.base_money
var main_risks = e.detail.value.main_risks
var warranty_one = this.data.main_array
var impletion_time = this.data.impletion_time
var warranty = e.detail.value.Guarantee_period
var bank = e.detail.value.Renew_bank
var bank_num = e.detail.value.renew_num
var coverage = e.detail.value.base_money
var picurl = JSON.stringify(this.data.imgs)
var guarantee = JSON.stringify(this.data.selectitem) //保障项目
var more = JSON.stringify(this.data.addlist)
... ...
... ... @@ -105,8 +105,9 @@
<input class='income_input' type='text' placeholder='受益比例%' name='beneficiary' value='{{item.unit}}' bindinput='addUnit'></input>
</view>
</view>
<view class='iconfont icon-guanbi shouyi' bindtap='deletebenefict' wx:if="{{its>0}}" data-index='{{its}}'></view>
</view>
<view class='iconfont icon-wuuiconxiangjifangda add_person' data-mindex='{{its}}' data-sindex='{{index}}' bindtap='addPersons'>
<view class='iconfont icon-wuuiconxiangjifangda add_person' wx:if="{{beneficiary_list.length<beneficiary_list[0].name.length}}" data-mindex='{{its}}' data-sindex='{{index}}' bindtap='addPersons'>
<text>添加受益人</text>
</view>
</view>
... ... @@ -270,12 +271,17 @@
</view>
</block>
<block wx:else> -->
<view class='list_input'>
<view class='list_input'>
<input type='text' placeholder='自动计算' name='warranty_one' value='{{warranty_one}}'></input>
</view>
<!-- <view class='list_input'>
<picker class='picker' range='{{period_time}}' value='{{period_index}}' bindchange='periodTime'>
<input placeholder='自动计算' value='{{period_time[period_index]}}' disabled='true'></input>
<input placeholder='自动计算' value='{{warranty_one}}' disabled='true'></input>
</picker>
<!-- <text class='iconfont icon-riqi'></text> -->
</view>
<!-- <text class='iconfont icon-riqi'></text>
</view> -->
<!-- </block> -->
</view>
</view>
... ... @@ -284,7 +290,7 @@
<!-- wx:for='{{addlist}}' wx:key='' -->
<view class='risk_box'>
<view class='risk_item' wx:for='{{risk_list}}' wx:key=''>
<view class='iconfont icon-guanbi symool_box' bindtap='deleteRisk' data-index='{{index}}'></view>
<view class='iconfont icon-guanbi symool_box' bindtap='deleteRisk' wx:if="{{index>0}}" data-index='{{index}}'></view>
<view class='item_list'>
<view class='list_title project'>附加险名称</view>
<view class='list_input'>
... ... @@ -297,14 +303,6 @@
<view>{{project.name}}</view>
<view class='protec_num'>{{project.num}}<block wx:for='{{project.title}}' wx:for-item='danwei' wx:key=''><text wx:if="{{danwei.label_state}}">{{danwei.name}}</text></block></view>
</view>
<!-- <view class='protec_item'>
<view>轻症重大疾病</view>
<view class='protec_num'>50万</view>
</view>
<view class='protec_item'>
<view>轻症重大疾病</view>
<view class='protec_num'>50万</view>
</view> -->
</view>
<view class='protec_bottom_box'>
<view class='add_risk_btn protec_btn' bindtap='ensureProject' data-type='fujiaxian' data-xulie='{{index}}'>
... ... @@ -320,9 +318,9 @@
<input type='text' placeholder='请输入' name='beneficiary' value='{{listdetail.favoree}}'></input>
</view>
<view class='list_label_box'>
<view class="list_label_item {{unit4==10?'list_label_active':''}}" bindtap='selectUnit4' data-unit='10'>年</view>
<view class="list_label_item {{unit4==11?'list_label_active':''}}" bindtap='selectUnit4' data-unit='11'>岁 </view>
<view class="list_label_item {{unit4==12?'list_label_active':''}}" bindtap='selectUnit4' data-unit='12'>终身</view>
<view class="list_label_item {{item.time==10?'list_label_active':''}}" bindtap='selectUnit4' data-index="{{index}}" data-unit='10'>年</view>
<view class="list_label_item {{item.time==11?'list_label_active':''}}" bindtap='selectUnit4' data-index="{{index}}" data-unit='11'>岁 </view>
<view class="list_label_item {{item.time==12?'list_label_active':''}}" bindtap='selectUnit4' data-index="{{index}}" data-unit='12'>终身</view>
</view>
</view>
</view>
... ...
... ... @@ -481,3 +481,11 @@ page {
color: #999;
margin-left: 15rpx;
}
.icon-guanbi.shouyi{
position: unset;
margin-left: -22rpx;
font-size: 22rpx;
align-self: flex-start;
margin-top:-10rpx;
}
\ No newline at end of file
... ...
// pages/index/payWay/payWay.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
VipId: '',
moneyt: '',
title: '',
PayType: 1, //1为余额支付2为微信支付
balance: '',
Page: 0,
},
setpaytype1() {
this.setData({
PayType: 1
})
},
setpaytype2() {
this.setData({
PayType: 2
})
},
// 立即支付
gopay() {
let url = 'counselor/gopay';
let that = this;
app.post(url, {
VipId: that.data.VipId,
PayType: that.data.PayType,
UserId: app.globalData.UserId
}).then((res) => {
console.log(res)
if (res.data.code == 200) {
if (res.data.data.type == 1) { //1订单写入成功,-1订单写入失败,-2余额不足
if (res.data.data.data != undefined) { //调用微信支付接口
console.log("微信支付")
console.log(res.data.data.data)
wx.requestPayment({
'timeStamp': res.data.data.data.timeStamp,
'nonceStr': res.data.data.data.nonceStr,
'package': res.data.data.data.package,
'signType': res.data.data.data.signType,
'paySign': res.data.data.data.paySign,
'success': (res) => {
wx.showToast({
title: '支付成功',
icon: 'success',
duration: 2000
})
setTimeout(function() {
//要延时执行的代码
wx.navigateBack({
delta: 2
})
}, 2000)
},
'fail': function(res) {
console.log(res)
}
})
} else {
wx.showToast({
title: '支付成功',
icon: 'success',
duration: 2000
})
setTimeout(function() {
//要延时执行的代码
wx.navigateBack({
delta: 2
})
}, 2000)
}
} else if (res.data.data.type == -2) {
wx.showToast({
title: '余额不足,请选择其他支付方式',
icon: 'none',
duration: 2000
})
} else if (res.data.data.type == -1) {
wx.showToast({
title: '购买失败',
icon: 'none',
duration: 2000
})
}
}
}).catch((errMsg) => {
console.log(errMsg)
})
},
// 调取TB接口
TB() {
let url = 'counselor/tlist'
let params = {
UserId: app.globalData.UserId,
Page: this.data.Page
}
app.post(url, params).then((res) => {
console.log(res)
if (res.data.code == 200) {
this.setData({
balance: Math.round(res.data.data.balance)
})
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
onLoad: function(options) {
let that = this;
that.setData({
VipId: options.id,
moneyt: options.moneyt,
title: options.title
})
this.TB()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
onShareAppMessage: function() {
}
})
\ No newline at end of file
... ...
... ... @@ -2,7 +2,7 @@
<view class='banner_box' id='{{VipId}}'>
<view>{{title}}</view>
<!-- <text class='money'>100</text> 元 </view>-->
<view class='banner_hint'>返{{backt}}T币</view>
<view class='banner_hint'>返{{moneyt}}T币</view>
</view>
<view class='content_item'>
<view class='item_list' bindtap='setpaytype1' >
... ... @@ -27,4 +27,4 @@
</view>
</view>
<view class='balance'>您的可用T币余额: <text>{{balance}}</text> </view>
<view class='bottom_btn' bindtap='gopay'>立即支付</view>
\ No newline at end of file
<view class='bottom_btn' bindtap='gopay'>立即支付</view>
\ No newline at end of file
... ...
... ... @@ -36,7 +36,7 @@
"list": []
},
"miniprogram": {
"current": 1,
"current": 2,
"list": [
{
"id": -1,
... ... @@ -47,7 +47,13 @@
{
"id": -1,
"name": "保单添加",
"pathName": "pages/index/addListDetail/addListDetail"
"pathName": "pages/index/addListDetail/addListDetail",
"query": ""
},
{
"id": -1,
"name": "a",
"pathName": "pages/index/Suggest/Suggest"
}
]
}
... ...