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 url = require('../../../../constant/url.js') import Net from '../../../../tool/net.js' var net = new Net() var businessType = require('../../../../public/business-type.js') var purchaseData = require('../../public/model/purchase-details.js') var key = require('../../../../constant/key.js') var app = getApp() import PurchaseOrder from '../../public/model/purchaseOrder.js' var login = require('../../../../public/login.js') Page({ /** * 页面的初始数据 */ data: { isFirstLoad: true, ui: { tips: { explain: [], choose: [], process: 'process_s', question: {}, tips: [] } }, data: { }, choseCity: {}, adapter: { suffix: '', isSupplementaryPay: false, leftButton: '一键续保', rightButton: '立即参保', city: { t: '参保城市', c: '', d: [], v: [0, 0], des: '' }, charge: 0, count: 10000, //客服需要的 isLogin: false, userInfo: { avatarUrl: '' }, params: { } }, project: { l: true,//是否有下横线 s: false,//是否展示 t: '参保方案', c: '', v: [] }, account: { l: true, t: '户籍性质', c: '本地城镇' }, tips: { s: false, t: [] }, accounts: null, accountsAnimation: {}, totals:[], list:[], choseAccount: 0, showContact: false, showContactHeight: -68, scroll: true, // confirmView: { // animation: {}, // hidden: true, // height: '800rpx', // bottom: '0rpx', // suffix: '' // }, scrollView: { top: 0 }, positionHeight: [0, 0, 0, 0, 0], chooseHidden: true, chooseing: false//是否点击选择购买流程等 }, // hiddenConfirmView: function () { // var animation = wx.createAnimation({ // duration: 300, // timingFunction: 'ease', // }) // animation.bottom('-' + this.data.confirmView.height).step() // this.data.confirmView.animation = animation.export() // this.data.confirmView.hidden = false // this.setData({ // confirmView: this.data.confirmView // }) // setTimeout(function () { // this.data.confirmView.hidden = true // this.setData({ // confirmView: this.data.confirmView, // scroll: true // }) // }.bind(this), 300) // }, // dismissConfirmView: businessT.action(function () { // this.hiddenConfirmView() // }), // showConfirmView: function (sender) { // if (!this.data.confirmView.hidden) { // return // } // var order = p.getOrder() // this.data.confirmView.hidden = false // this.data.confirmView.tips = {s: !order.isSupplementaryPay, t: [this.data.adapter.city.des] } // this.data.confirmView.city = this.data.adapter.city // this.data.confirmView.project = this.data.project // this.data.confirmView.account = this.data.account // this.setData({ // confirmView: this.data.confirmView, // scroll: false // }) // var animation = wx.createAnimation({ // duration: 300, // timingFunction: 'ease', // }) // animation.bottom('0rpx').step() // this.data.confirmView.animation = animation.export() // this.data.confirmView.hidden = false // setTimeout(function () { // this.setData({ // confirmView: this.data.confirmView // }) // }.bind(this), 300) // }, hiddenContactListener: function (e) { this.setData({ scroll: true }) }, toCalculator: function (sender) { var cha = sysT.sysInfo().system.indexOf("iOS") == 0 ? 'iOS' : 'Android' var order = p.getOrder() businessT.debugLog(app.purchase.purchaseData) wx.navigateTo({ url: '../../../../public/pages/html/html?host=https://www.wodeshebao.com/calc/app_index.html&f=' + cha + '&c=' + app.purchase.purchaseData.city_code + '&cid=' + app.purchase.purchaseData.id + '&hk=' + order.accountType, }) }, yearPay: function (sender) { wx.showToast({ title: '凡带年缴标识的首月一次性收取一年费用\n年费会因缴费首月不同稍有不同', icon: 'none' }) }, judgeIsLogin: function () { if (app.loginStatus.key == "") { wx.navigateTo({ url: '../../../login/index', }) return false } return true }, contactAction: function (sender) { if (!this.judgeIsLogin()) { return } // wx.navigateTo({ // url: '../../../../public/pages/html/html?host=https://kf.shanp.com/user.html&channel=h5XCX&phone=' + app.globalData.userInfo.phone + '&uid=' + app.globalData.userInfo.uid + '&t=' + new Date().getTime(), // }) }, phoneAction: function (sender) { this.setData({ showContact: true, scroll: false }) }, supplementaryPay: function (sender) { if (!this.judgeIsLogin()) { return } var purchase = app.purchase.purchaseData if (purchase.addeds_num == 0) { wx.showToast({ title: '该城市不支持补缴社保', icon: 'none' }) return } this.toCustomer() }, quickPurchase: function (sender) { if (!this.judgeIsLogin()) { return } if (app.globalData.customerList.length == 0) { wx.showToast({ title: '你还没有参保记录,请选择“立即参保”', icon: 'none' }) return } wx.navigateTo({ url: '../../../../public/pages/customer-view/customer-view?type=qPurchase&businessType=s', }) }, purchase: businessT.action(function (sender) { if (!this.judgeIsLogin()) { return } this.toCustomer() }), // confirmAction: businessT.action(function (sender) { // this.hiddenConfirmView() // setTimeout(function () { // this.toCustomer() // }.bind(this), 500) // }), toCustomer: function () { if (app.globalData.customerList.length > 0) { wx.navigateTo({ url: '../../../../public/pages/customer-view/customer-view?type=nPurchase', }) return } wx.navigateTo({ url: '../new-customer/new-customer', }) }, chooseProject: function (sender) { app.purchase.purchaseData = app.purchase.purchaseDataArray[sender.detail.value] this.handleData() }, chooseCity: function (sender) { //防止第一列还在滑动就确定,再次展示会错位 this.data.adapter.city.d[1] = publicData.purchaseCity[(publicData.purchaseCity.p)[sender.detail.value[0]].id] this.data.adapter.city.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.adapter.city.v[1] = 0 } this.data.choseCity = c this.setData({ adapter: this.data.adapter }) this.getData(c.id) }, chooseCityColumn: function (sender) { if (sender.detail.column == 0) { this.data.adapter.city.d[1] = publicData.purchaseCity[(publicData.purchaseCity.p)[sender.detail.value].id] this.data.adapter.city.v = [sender.detail.value, 0] this.setData({ adapter: this.data.adapter }) } }, chooseAccountP: businessT.action(function (sender) { this.changeAccount(sender.detail.value) }), chooseAccount: businessT.action(function (sender) { this.changeAccount(sender.currentTarget.id) }), changeAccount: function (index) { businessT.debugLog(index) var order = p.getOrder() order.accountType = Number(index) + 1 this.data.choseAccount = index businessT.debugLog(order) this.data.account.c = this.data.accounts[index] var animation = wx.createAnimation({ duration: 300, timingFunction: 'ease', }) var t = 190 * sysT.rpxToPx() * index animation.translateX(t).step() this.setData({ choseAccount: this.data.choseAccount, account: this.data.account, accountsAnimation: animation.export() }) this.calculateHeight() }, scroll: function (sender) { this.data.scrollView.top = sender.detail.scrollTop if (sender.detail.scrollTop >= this.data.positionHeight[0]) { this.data.chooseHidden = false this.setData({ chooseHidden: this.data.chooseHidden }) if (this.data.chooseing) { this.data.chooseing = false return } var chooseHeight = this.data.positionHeight[1] - this.data.positionHeight[0] if (sender.detail.scrollTop >= this.data.positionHeight[4] - chooseHeight) { this.changeChoose(3) } else if (sender.detail.scrollTop >= this.data.positionHeight[3] - chooseHeight) { this.changeChoose(2) } else if (sender.detail.scrollTop >= this.data.positionHeight[2] - chooseHeight) { this.changeChoose(1) } else if (sender.detail.scrollTop >= this.data.positionHeight[1] - chooseHeight) { this.changeChoose(0) } } else { this.data.chooseHidden = true this.setData({ chooseHidden: this.data.chooseHidden }) } }, tipsChoose: businessT.action(function (sender) { businessT.debugLog(sender.currentTarget.id) var index = Number(sender.currentTarget.id) var chooseHeight = this.data.positionHeight[1] - this.data.positionHeight[0] this.data.scrollView.top = this.data.positionHeight[index + 1] - chooseHeight this.setData({ scrollView: this.data.scrollView }) this.data.chooseing = true this.changeChoose(index) }), changeChoose: function (index) { var animation = wx.createAnimation({ duration: 300, timingFunction: 'ease', }) animation.translateX(index * 190 * sysT.rpxToPx()).step() this.data.ui.tips.choose.animation = animation.export() this.data.ui.tips.choose.c = index this.setData({ ui: this.data.ui }) }, 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) { purchaseData.handleData(res.data) this.handleData() if (order.isSupplementaryPay) { wx.setStorageSync(key.StorageKey.lastCity_s, this.data.choseCity) } else { wx.setStorageSync(key.StorageKey.lastCity_n, this.data.choseCity) } wx.hideLoading() } else { this.getDataFail() businessT.showFailTips({ code: 0, msg: '' }, '加载失败') } }, fail: (err, res) => { this.getDataFail() businessT.showFailTips(err, '加载失败') } }, true) }, getDataFail: function () { wx.hideLoading() var order = p.getOrder() this.data.choseCity = { name: order.cityName, id: order.city } this.data.adapter.city.c = this.data.choseCity.name this.setData({ adapter: this.data.adapter }) if (app.purchase.purchaseData == null) { setTimeout(function () { wx.navigateBack({ }) }.bind(this), 1000) } }, handleData: function () { if (this.data.ui.tips.question.height[0] == 0) { businessT.debugLog('算问题') var query = wx.createSelectorQuery(); for (var i in this.data.ui.tips.question.ids) { var id = this.data.ui.tips.question.ids[i] query.select('#' + id).boundingClientRect() } var that = this; query.exec(function (res) { //res就是 该元素的信息 数组 businessT.debugLog(res) for (var i in res) { that.data.ui.tips.question.height[i] = res[i].height } that.setData({ ui: that.data.ui }) }) } var order = p.getOrder() var data = app.purchase.purchaseData this.data.adapter.city.c = this.data.choseCity.name this.data.adapter.charge = order.isSupplementaryPay ? data.added_charge : data.shebao_charge this.data.adapter.city.des = '目前可购买' + data.month + '及之后月份,截止时间为' + purchaseData.getPurchaseDeadline(data.inc_date) + '月' + data.inc_date + '日' if (app.purchase.purchaseDataArray.length > 1) { this.data.project.s = true var v = [] for (var i in app.purchase.purchaseDataArray) { v.push(app.purchase.purchaseDataArray[i].shebao_type) } this.data.project.v = v } else { this.data.project.s = false this.data.project.v = [] } this.data.project.c = data.shebao_type if (order.isSupplementaryPay) { if (data.shebao_note == '') { this.data.tips.t = [] } else { this.data.tips.t = data.shebao_note.split('\n') } } else { if (data.shebao_desc == '') { this.data.tips.t = [] } else { this.data.tips.t = data.shebao_desc.split('\n') } } if (this.data.tips.t.length > 0) { this.data.tips.s = true } else { this.data.tips.s = false } if (data.shebaos && Object.prototype.toString.call(data.shebaos) == '[object Array]') { var list = [] var totals = [] for (var index in data.shebaos) { var d = data.shebaos[index].data var l =[] var sum = 0 var yearSum = 0 var isYear = false for (var _index in d) { var item = d[_index] sum += Number(item.p) if (item.s) { isYear = true } else { yearSum += Number(item.p) } l.push(item) } var charge = order.isSupplementaryPay ? data.added_charge : data.shebao_charge if (isYear) { var t = [ { t: '本年首月套餐费用', c: '¥ ' + Number(sum).toFixed(2) + '/月' }, { t: '非首月套餐费用', c: '¥ ' + Number(yearSum).toFixed(2) + '/月' } ] } else { var t = [ { t: '套餐费用', c: '¥ ' + Number(sum).toFixed(2) + '/月' } ] } list.push(l) totals.push(t) } this.data.list = list this.data.totals = totals } purchaseData.changeShebaoDataToCustomerData() order.cityName = this.data.choseCity.name this.setData({ adapter: this.data.adapter, project: this.data.project, tips: this.data.tips, list: this.data.list, totals: this.data.totals, showContactHeight: sysT.suffixOfClass() == '-X' ? 0 : -68 }) this.calculateHeight() }, calculateHeight: function () { //purchase-details-choose var query = wx.createSelectorQuery(); var that = this; //选择id query.select('#purchase-details-choose').boundingClientRect() query.select('#purchase-details-process').boundingClientRect() query.select('#purchase-details-advantage').boundingClientRect() query.select('#purchase-details-question').boundingClientRect() query.select('#purchase-details-tips').boundingClientRect() query.exec(function (res) { //res就是 该元素的信息 数组 that.data.positionHeight[0] = res[0].top + that.data.scrollView.top that.data.positionHeight[1] = res[1].top + that.data.scrollView.top that.data.positionHeight[2] = res[2].top + that.data.scrollView.top that.data.positionHeight[3] = res[3].top + that.data.scrollView.top that.data.positionHeight[4] = res[4].top + that.data.scrollView.top businessT.debugLog(that.data.positionHeight) }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { if (options.first) { login.autoLogin(true) } var order = p.getOrder() if (!order) { var order = new PurchaseOrder() p.setOrder(order) } if (options.isSupplementaryPay == 1) { order.isSupplementaryPay = true } else { order.isSupplementaryPay = false } order.setCity() order.purchaseType = businessType.PurchaseType.socialInsurance this.data.choseCity = {name: order.cityName, id: order.city} var title var tips if (order.isSupplementaryPay) { title = '社保补缴详情' tips = { explain: ['补缴必须与正常月份一起操作,所以下补缴单前请先下一个月正常单(点击首页-缴社保)', '补缴不能跨月操作。例如,现在可以下10月份订单,那么补缴必须从9月份开始往前连续购买,不可从8月份或其他月份开始(若9月份已缴费就不能操作补缴了)。', '本平台仅支持代缴服务,不支持生育津贴、住房补贴等申领,且不出具任何相关证明。'] } } else { title = '社保缴纳详情' tips = { explain: ['以前曾在单位参保过的,第一次下单购买前,请先确认前单位是否已经减员。若因前单位没有减员的,导致购买不成功,本平台不负责哦。', '本平台仅支持代缴服务,不支持生育津贴、住房补贴等申领,且不出具任何相关证明。'], attention: ['若您停止购买后,本平台通常会于次月截止时间后的一周操作减员(部分地区可能会有延迟),需提前减员的用户,请提前3-7工作日联系客服。', '如果您当月申请减员后,又想重新购买当月的社保,请务必先联系客服撤销减员,避免漏缴。'], attentionT: '社保减员注意事项' } } tips.choose = { t: ['购买流程', '平台优势', '常见问题', '温馨提示'], c: 0, animation: {} } tips.process = 'process_s' tips.tips = ['避免因错过了截止时间忘记下单,造成社保断缴的,建议一次性购买多个月份。若有新的工作单位,未缴费的月份可申请退款。', '凡带有“年缴”标识的,首月会一次性收取一年费用,年费会因地区和缴费月份不同稍有变化。', '带有“预收费用”的城市,因社保局已确定调费,但上调金额未定,固将预收一定的费用。待社保局确定上调金额后,我们会统一清算,多退少补(如:杭州市一般于6月份公布,但须从当年1月份开始执行)', '每年政府会调整社保缴费基数,我们会在第一时间通知您。若因政府调整通知滞后导致划扣金额不准确的,我们承诺多退少补,童叟无欺。', '本套餐适合于16岁至法定退休年龄之间的用户购买。'] tips.question = { t: '社保购买常见问题', c: [ '付款成功后,一般什么时候可以查询参保情况呢?', ['当月下单截止后,专员会开始进行跟进。\n如有异常,则会通过信息或电话通知您;没有通知则表示正常操作,一般可于', '次月1日-15日查询', '缴纳情况。'], '如果社保缴纳没有成功,你们会给予退款么?', '会的,因您自身原因办理不成功,或符合申请退款条件的,则给予退款。但支付宝或微信平台收取0.6%的手续费需由您承担。\n退款一般会于月底或次月初前原路退还给您。', '你们可以办理社保卡么?办理需要多长时间?', '可以办理的,但若您是停保期间是无法办卡的哦。\n社保卡一般会在当月成功缴费后的2 - 6个月内出卡(不同地区时间不一样)。\n办理成功后会以邮寄方式寄给您,邮费到付。' ], ids: ['questionLeft1', 'questionRight1', 'questionLeft2', 'questionRight2', 'questionLeft3', 'questionRight3'], height: [0, 0, 0, 0, 0, 0, 0, 0] } this.data.ui.tips = tips wx.setNavigationBarTitle({ title: title }) var cityData = [publicData.purchaseCity.p, publicData.purchaseCity[(publicData.purchaseCity.p)[0].id]] this.data.adapter = { suffix: sysT.suffixOfClass(), isSupplementaryPay: order.isSupplementaryPay, banner: order.isSupplementaryPay ? '../../../../icon/home/s_s_banner.png' : '../../../../icon/home/s_p_banner.png', title: '自助缴社保 按当地最低标准缴费', leftButton: '一键续保', rightButton: '立即参保', city: { t: '参保城市', c: this.data.choseCity.name, d: cityData, v: [0, 0], des: '' }, charge: 0, count: 10000, //客服需要的 isLogin: false, userInfo: { avatarUrl: '' }, params: { } } // this.data.confirmView.suffix = sysT.suffixOfClass() // if (sysT.suffixOfClass() == '-X') { // this.data.confirmView.height = '868rpx' // this.data.confirmView.bottom = '68rpx' // } this.setData({ choseCity: this.data.choseCity, adapter: this.data.adapter, accounts: publicData.accounts, ui: this.data.ui }) this.getData(this.data.choseCity.id) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { // var order = p.getOrder() // businessT.debugLog(order) // if(order.isSupplementaryPay) { // app.purchase.purchaseDataArray = app.purchase.supplementaryPurchaseDataArray // } else { // app.purchase.purchaseDataArray = app.purchase.normalPurchaseDataArray // } // var purchaseArray = app.purchase.purchaseDataArray // if (purchaseArray.length > 0) { // var purchase = purchaseArray[0] // if (purchase.city_code == this.data.choseCity.id && purchase.pack == 1) { // app.purchase.purchaseData = purchase // this.handleData() // } else { // app.purchase.purchaseDataArray = [] // app.purchase.purchaseData = null // this.getData(this.data.choseCity.id) // } // } else { // this.getData(this.data.choseCity.id) // } }, /** * 生命周期函数--监听页面显示 */ onShow: function () { //客服 this.data.adapter.isLogin = app.loginStatus.isLogin this.data.adapter.userInfo.nickName = app.globalData.userInfo.phone this.data.adapter.params.phone = app.globalData.userInfo.phone this.data.adapter.params.userId = app.globalData.userInfo.uid this.setData({ adapter: this.data.adapter }) if (this.data.isFirstLoad) { this.data.isFirstLoad = false return } var order = p.getOrder() this.data.choseCity = { name: order.cityName, id: order.city } this.handleData() }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { return { path: '/page/home/index', imageUrl: '../../../../icon/public/share_img.png', title: '自助缴社保公积金,覆盖200多个城市,专业团队操作' } } })