var sysT = require('../../../../tool/sys-tool.js') var businessT = require('../../../../tool/business-tool.js') var purchaseO = require('../../public/model/purchaseOrder.js') var p = require('../../public/model/public.js') var publicData = require('../../../../constant/data.js') var key = require('../../../../constant/key.js') var purchaseData = require('../../public/model/purchase-details.js') var handleData = require('../../public/model/purchase-imformation.js') var app = getApp() var url = require('../../../../constant/url.js') import Net from '../../../../tool/net.js' var net = new Net() var businessType = require('../../../../public/business-type.js') Page({ /** * 页面的初始数据 */ data: { adapter: { suffix: '', bgHeight: '', isSupplementaryPay: false, }, choseCity: { v: [0, 0], d: {} }, header: [ { lt: '开始月份', lc: '', b: '', rt: '结束月份', rc: '', la: 'chooseTime', ra: 'chooseTime' }, { lt: '所在城市', lc: '', b: '', rt: '户籍性质', rc: '', lr: [], rr: [] }, ], tips: { t: '同时购买公积金,公积金服务费立减'}, data: [ { t: '本城市首次参保', c: false, i: '1'},//switch { t: '社保卡办理', c: '', r: [], v: 0, i: '2' },//pick { t: '办理费用', c: '', d: '缴费成功后2-6个月出卡' }, { t: '是否购买公积金', c: false, i: '3' },//switch { t: '本城市首次缴公积金', c: false, i: '4' },//switch { t: '缴费金额', p: '', v: '', i: '1' }, { l: '工资基数(参考)\n企业比例\n个人比例', r: '' }, { t: '公积金费用', c: ''}, { t: '社保流水', p: '', v: '', s: false, i: '2' }, { t: '参保方案', c: '', r: [], s: false, i: '5' },//pick { t: '是否在职', s: false, tips: true, c: false, i: '5' },//switch ], sData: { t: { t: '社保费用', c: '' } }, sTotals: [0, 0], charges: { pack: false, f: 0, r: '' }, minSalary: 2500, tipsInfo:{ h: true, a: '' }, shebaoTips: { s: false, t: [] }, }, chooseTime: businessT.action(function (sender) { wx.navigateTo({ url: '../choose-date/choose-date?type=double', }) }), finishChooseDate: function (date) { businessT.debugLog(date) var order = p.getOrder() var tempTimeInterval = order.timeInterval var tempBeginTime = order.beginTime var tempEndTime = order.endTime var beginMonth = date.beginMonth % 100 var endMonth = date.endMonth % 100 if (date.endMonth - date.beginMonth + 1 > 12) { order.timeInterval = endMonth + 12 - beginMonth + 1 } else { order.timeInterval = date.endMonth - date.beginMonth + 1 } if (beginMonth < 10) { order.beginTime = ((date.beginMonth / 100) | 0) + '年0' + beginMonth + '月' } else { order.beginTime = ((date.beginMonth / 100) | 0) + '年' + beginMonth + '月' } if (endMonth < 10) { order.endTime = ((date.endMonth / 100) | 0) + '年0' + endMonth + '月' } else { order.endTime = ((date.endMonth / 100) | 0) + '年' + endMonth + '月' } this.data.header[0].lc = order.beginTime this.data.header[0].rc = order.endTime this.data.header[0].b = order.timeInterval + '个月' this.setData({ header: this.data.header }) handleData.calculateBuyTotalFee({ success: res => { this.handleCalculateData() }, failure: err => { order.beginTime = tempBeginTime order.endTime = tempEndTime order.timeInterval = tempTimeInterval this.data.header[0].lc = order.beginTime this.data.header[0].rc = order.endTime this.data.header[0].b = order.timeInterval + '个月' this.setData({ header: this.data.header }) } }) }, chooseAccount: function (sender) { var index = sender.detail.value var order = p.getOrder() var tempAccountType = order.accountType this.changeAccount(Number(index) + 1) handleData.calculateBuyTotalFee({ success: res => { this.handleCalculateData() }, failure: err => { this.changeAccount(tempAccountType) } }) }, changeAccount: function (a) { var order = p.getOrder() order.accountType = a this.changeAccountData() this.setData({ header: this.data.header, data: this.data.data, sData: this.data.sData }) }, getData: function (cityId) { wx.showLoading({ title: '加载中', mask: true }) var order = p.getOrder() var path = order.isSupplementaryPay ? url.getSupplementaryPurchaseData : url.getNormalPurchaseData net.connect({ url: url.app_host + path, method: 'POST', data: { city_code: cityId, type: 1 }, success: (err, res) => { if (Object.prototype.toString.call(res.data) == '[object Array]' && res.data.length > 0) { var indexOfScenario = 0 if (order.isSupplementaryPay) { var canContinue = false for (var index in res.data) { var data = res.data[index] if (data.addedf_num != 0) { canContinue = true indexOfScenario = Number(index) break } } if (!canContinue) { this.getDataFail() wx.showModal({ title: '', content: '您选择的城市不支持补缴社保', confirmColor: '#3296FB', cancelColor: '#3296FB', confirmText: '确定', showCancel: false, success: function (res) { } }) return } } var tempPurchaseDataArr = app.purchase.purchaseDataArray var tempPurchase = app.purchase.purchaseData var tempOrder = order.copy() purchaseData.handleData(res.data) // if (indexOfScenario != 0) { // app.purchase.purchaseData = app.purchase.purchaseDataArray[indexOfScenario] // } purchaseData.changeShebaoDataToCustomerData() order.cityName = this.data.choseCity.d.name handleData.calculateBuyTotalFee({ success: res => { this.getDataSuccess() this.handleCalculateData() }, failure: err => { app.purchase.purchaseDataArray = tempPurchaseDataArr app.purchase.purchaseData = tempPurchase p.setOrder(tempOrder) purchaseData.changeShebaoDataToCustomerData() this.handleData() wx.hideLoading() } }) } else { this.getDataFail() businessT.showFailTips({ code: 0, msg: '' }, '加载失败') } }, fail: (err, res) => { this.getDataFail() businessT.showFailTips(err, '加载失败') } }, true) }, getDataSuccess: function () { wx.hideLoading() var order = p.getOrder() this.handleData() if (order.isSupplementaryPay) { wx.setStorageSync(key.StorageKey.lastCity_s, this.data.choseCity.d) } else { wx.setStorageSync(key.StorageKey.lastCity_n, this.data.choseCity.d) } }, getDataFail: function () { wx.hideLoading() var order = p.getOrder() this.data.choseCity.d = { name: order.cityName, id: order.city } this.data.header[1].lc = this.data.choseCity.d.name this.setData({ header: this.data.header }) }, chooseCity: function (sender) { businessT.debugLog('abc') businessT.debugLog(sender.detail.value) //防止第一列还在滑动就确定,再次展示会错位 this.data.header[1].lr[1] = publicData.purchaseCity[(publicData.purchaseCity.p)[sender.detail.value[0]].id] this.data.choseCity.v = sender.detail.value var pr = publicData.purchaseCity.p[sender.detail.value[0]].id var c = publicData.purchaseCity[pr][sender.detail.value[1]] if (!c) { c = publicData.purchaseCity[pr][0] this.data.choseCity.v[1] = 0 } this.data.header[1].lc = c.name this.data.choseCity.d = c this.setData({ header: this.data.header }) this.getData(c.id) }, chooseCityColumn: function (sender) { if (sender.detail.column == 0) { this.data.header[1].lr[1] = publicData.purchaseCity[(publicData.purchaseCity.p)[sender.detail.value].id] this.data.choseCity.v = [sender.detail.value, 0] this.setData({ header: this.data.header }) } }, switchAction: function (sender) { businessT.debugLog(sender) var order = p.getOrder() if (sender.currentTarget.id == '1') { order.isFirstBuyShebao = sender.detail.value this.data.data[0].c = sender.detail.value } else if (sender.currentTarget.id == '3') { if (app.purchase.purchaseData.funds[order.accountType - 1][1] <= 0 || !app.purchase.purchaseData.pack) { wx.showToast({ title: '该城市不支持打包购买', icon: 'none' }) p.setOrderPack(false) this.data.data[3].c = false } else { p.setOrderPack(sender.detail.value) this.data.data[3].c = sender.detail.value this.data.data[4].c = order.isFirstBuyFund } this.handleCalculateData() return } else if (sender.currentTarget.id == '4') { order.isFirstBuyFund = sender.detail.value this.data.data[4].c = sender.detail.value } else if (sender.currentTarget.id == '5') { order.isInOffice = sender.detail.value this.data.data[10].c = sender.detail.value this.data.data[8].s = !sender.detail.value } this.setData({ data: this.data.data }) }, changeAccountData: function () { var order = p.getOrder() var purchase = app.purchase.purchaseData this.data.header[1].rc = publicData.accounts[order.accountType - 1] this.data.data[5].p = purchase.funds[order.accountType - 1][0] + '元-' + purchase.funds[order.accountType - 1][1] + '元' this.data.data[6].r = purchaseData.getWageBase() + '元\n' + purchase.funds[order.accountType - 1][2] + '%\n' + purchase.funds[order.accountType - 1][3] + '%' }, pickerAction: function (sender) { businessT.debugLog(sender) var order = p.getOrder() if (sender.currentTarget.id == '2') { var tempSSCard = order.SSCard this.changeSSCard(sender.detail.value) handleData.calculateBuyTotalFee({ success: res => { this.handleCalculateData() }, failure: err => { this.changeSSCard(tempSSCard) } }) } else if (sender.currentTarget.id == '5') { if (!order.isSupplementaryPay && app.purchase.purchaseDataArray.length > sender.detail.value) { var data = app.purchase.purchaseDataArray[sender.detail.value] var tempData = app.purchase.purchaseData businessT.debugLog(app.purchase.purchaseData) app.purchase.purchaseData = data businessT.debugLog(app.purchase.purchaseData) purchaseData.changeShebaoDataToCustomerData() this.handleData() handleData.calculateBuyTotalFee({ success: res => { this.handleCalculateData() }, failure: err => { app.purchase.publicData = tempData purchaseData.changeShebaoDataToCustomerData() this.handleData() } }) } } }, changeSSCard: function (v) { var order = p.getOrder() order.SSCard = v this.data.data[1].c = publicData.ssCards[order.SSCard].substr(0, 3) this.data.data[1].v = order.SSCard this.setData({ data: this.data.data }) }, inputAction: function (sender) { businessT.debugLog(sender) if (sender.currentTarget.id == '1') { this.changeFund(sender.detail.value) } else if (sender.currentTarget.id == '2') { this.changeSalary(sender.detail.value) } }, changeSalary: function(salary) { var order = p.getOrder() order.salary = salary this.data.data[8].v = salary this.setData({ data: this.data.data }) }, changeFund: function(fund) { var order = p.getOrder() var purchase = app.purchase.purchaseData order.accumulationFund = fund this.data.data[5].v = fund this.data.data[6].r = purchaseData.getWageBase() + '元\n' + purchase.funds[order.accountType - 1][2] + '%\n' + purchase.funds[order.accountType - 1][3] + '%' if (order.timeInterval == 1) { this.data.data[7].c = '¥ ' + Number(order.accumulationFund).toFixed(0) + '/月' } else { this.data.data[7].c = '¥ ' + (Number(order.accumulationFund) * order.timeInterval).toFixed(0) + ' (共' + order.timeInterval + '月)' } this.data.sTotals = this.getAmount() this.setData({ data: this.data.data, sTotals: this.data.sTotals }) }, nextStep: businessT.action(function (sender) { var order = p.getOrder() var fund = Number(order.accumulationFund) var purchase = app.purchase.purchaseData if (order.pack && fund == 0) { wx.showToast({ title: '请填写缴费范围内的公积金金额', icon: 'none' }) return } if (order.pack && (fund > purchase.funds[order.accountType - 1][1] || fund < purchase.funds[order.accountType - 1][0])) { wx.showToast({ title: '请填写缴费范围内的公积金金额', icon: 'none' }) return } if (!order.isSupplementaryPay && purchase.sb_wage) { var salary = Number(order.salary) if (!order.isInOffice) { if (salary == 0) { wx.showToast({ title: '请填写范围内的社保流水', icon: 'none' }) return } if (salary < this.data.minSalary || salary > 5000) { wx.showToast({ title: '请填写范围内的社保流水', icon: 'none' }) return } } businessT.debugLog(salary) order.isNeedSalary = true } else { order.isNeedSalary = false } businessT.debugLog(order) var that = this handleData.handleImformation((fund) => { that.changeFund(fund) }) }), handleData: function () { var order = p.getOrder() this.data.header[1].lc = order.cityName this.data.header[0].lc = order.beginTime this.data.header[0].rc = order.endTime this.data.header[0].b = order.timeInterval + '个月' var purchase = app.purchase.purchaseData this.data.data[0].c = order.isFirstBuyShebao this.data.data[1].r = publicData.ssCards this.data.data[1].c = publicData.ssCards[order.SSCard].substr(0, 3) this.data.data[1].v = order.SSCard // this.data.data[2].c = '¥ ' + purchase.shebao_card_charge.toFixed(2) var dis = purchase.shebao_charge + purchase.fund_charge - purchase.package_charge if (dis != (dis | 0)) { dis = dis.toFixed(2) } this.data.tips.t = '同时购买公积金,公积金服务费立减' + dis + '元/月' this.data.data[3].c = order.pack this.data.data[4].c = order.isFirstBuyFund this.data.data[5].v = order.accumulationFund // this.data.data[5].p = purchase.funds[order.accountType - 1][0] + '元-' + purchase.funds[order.accountType - 1][1] + '元' // this.data.data[6].r = purchaseData.getWageBase() + '元\n' + purchase.funds[order.accountType - 1][2] + '%\n' + purchase.funds[order.accountType - 1][3] + '%' // this.data.data[7].c = '¥ ' + (purchase.package_charge - purchase.fund_charge + Number(order.accumulationFund)).toFixed(2) + '/月' // this.data.data[7].d = '含服务费' + (purchase.package_charge - purchase.fund_charge) + '元/月' this.data.data[10].s = purchase.sb_wage this.data.data[8].s = !order.isInOffice && purchase.sb_wage this.data.minSalary = wx.getStorageSync(key.StorageKey.minSalary) this.data.data[8].p = this.data.minSalary + '元-5000元' if (app.purchase.purchaseDataArray.length > 1) { this.data.data[9].s = true var v = [] for (var i in app.purchase.purchaseDataArray) { v.push(app.purchase.purchaseDataArray[i].shebao_type) } this.data.data[9].r = v } else { this.data.data[9].s = false this.data.data[9].r = [] } this.data.data[9].c = purchase.shebao_type this.changeAccountData() if (order.isSupplementaryPay) { if (purchase.shebao_note == '') { this.data.shebaoTips.t = [] } else { this.data.shebaoTips.t = purchase.shebao_note.split('\n') } } else { if (purchase.shebao_desc == '') { this.data.shebaoTips.t = [] } else { this.data.shebaoTips.t = purchase.shebao_desc.split('\n') } } if (order.isSupplementaryPay && this.data.shebaoTips.t.length > 0) { this.data.shebaoTips.s = true } else { this.data.shebaoTips.s = false } this.setData({ adapter: this.data.adapter, tips: this.data.tips, header: this.data.header, data: this.data.data, sData: this.data.sData, choseCity: this.data.choseCity, shebaoTips: this.data.shebaoTips }) }, wxvoid: function () { }, tipsInfo: businessT.action(function (sender) { if (!this.data.tipsInfo.h) { return } this.data.tipsInfo.h = false this.setData({ tipsInfo: this.data.tipsInfo }) var animation = wx.createAnimation({ duration: 300, timingFunction: 'ease', }) animation.bottom('0rpx').step() this.setData({ tipsInfo: { a: animation.export(), h: false } }) }), dismissSalaryInfo: businessT.action(function (sender) { var animation = wx.createAnimation({ duration: 300, timingFunction: 'ease', }) animation.bottom('-800rpx').step() this.setData({ tipsInfo: { a: animation.export(), h: false } }) setTimeout(function () { this.data.tipsInfo.h = true this.setData({ tipsInfo: this.data.tipsInfo }) }.bind(this), 300) }), handleCalculateData: function () { var total = handleData.getTotal() var order = p.getOrder() var charges = this.getCharge() this.data.data[2].c = '¥ ' + total[1] if (order.timeInterval == 1) { this.data.sData.t.c = '¥ ' + total[0] + '/月' this.data.data[7].c = '¥ ' + Number(order.accumulationFund).toFixed(0) + '/月' if (order.pack) { this.data.charges.pack = true this.data.charges.f = '¥ ' + charges[1] + '/月' this.data.charges.r = '已优惠' + charges[2] + '元' } else { this.data.charges.pack = false this.data.charges.f = '¥ ' + charges[0] + '/月' } } else { this.data.sData.t.c = '¥ ' + total[0] + ' (共' + order.timeInterval + '月)' this.data.data[7].c = '¥ ' + (Number(order.accumulationFund) * order.timeInterval).toFixed(0) + ' (共' + order.timeInterval + '月)' if (order.pack) { this.data.charges.pack = true this.data.charges.f = '¥ ' + charges[1] + ' (共' + order.timeInterval + '月)' this.data.charges.r = '已优惠' + charges[2] + '元' } else { this.data.charges.pack = false this.data.charges.f = '¥ ' + charges[0] + ' (共' + order.timeInterval + '月)' } } this.data.sTotals = this.getAmount() this.setData({ data: this.data.data, sData: this.data.sData, sTotals: this.data.sTotals, charges: this.data.charges, firstCalculate: true }) }, firstCalculateTotal: function () { handleData.calculateBuyTotalFee({ success: res => { this.handleCalculateData() }, failure: err => { setTimeout(function () { wx.navigateBack({ }) }.bind(this), 1000) } }) }, getCharge: function () { var order = p.getOrder() var purchaseData = app.purchase.purchaseData if (order.isSupplementaryPay) { var charge = (purchaseData.added_charge * order.timeInterval).toFixed(0) return [String(charge), '', ''] } if (order.pack) { var packCharge = (purchaseData.package_charge * order.timeInterval).toFixed(0) var reduce = ((purchaseData.shebao_charge + purchaseData.fund_charge - purchaseData.package_charge) * order.timeInterval).toFixed(0) return ['', String(packCharge), String(reduce)] } var charge = (purchaseData.shebao_charge * order.timeInterval).toFixed(0) return [String(charge), '', ''] }, getAmount: function () { var order = p.getOrder() var t = handleData.getTotal() var amout = (Number(t[0]) + Number(t[1])) var charge = this.getCharge() amout += (Number(charge[0]) + Number(charge[1])) if (order.pack) { amout += (order.accumulationFund * order.timeInterval) } amout = String(amout.toFixed(2)) return [amout.substr(0, amout.length - 2), amout.substr(amout.length - 2, 2)] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { handleData.setOut(true) sysT.adaptor() var order = p.getOrder() // var purchase = app.purchase.purchaseData // if (order.isSupplementaryPay) { // if (order.purchaseType == businessType.PurchaseType.socialInsurance || order.purchaseType == businessType.PurchaseType.socialInsurancePackage) { // this.data.tips.t = purchase.shebao_note.split('\n') // } else { // this.data.tips.t = purchase.fund_note.split('\n') // } // this.data.tips.s = true // } else { // this.data.tips.s = false // } wx.setNavigationBarTitle({ title: order.isSupplementaryPay ? '社保补缴信息' : '社保信息' }) this.data.adapter = { suffix: sysT.suffixOfClass(), bgHeight: sysT.usableHeight(112), isSupplementaryPay: order.isSupplementaryPay } var cityData = [publicData.purchaseCity.p, publicData.purchaseCity[(publicData.purchaseCity.p)[0].id]] this.data.header[1].lr = cityData this.data.header[1].rr = publicData.accounts this.data.choseCity.d = { name: order.cityName, id: order.city } this.handleData() this.firstCalculateTotal() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { handleData.finish() }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ // onShareAppMessage: function () { // } })