var businessT = require('../../../../tool/business-tool.js') var sysT = require('../../../../tool/sys-tool.js') var url = require('../../../../constant/url.js') import Net from '../../../../tool/net.js' var net = new Net() var app = getApp() var wxyj = require('../../../../public/wxyj.js') Page({ data: { orderStatus: false, discountStatus: false, discountData: '', cheapData: [] }, showModal(e) { var index = e.currentTarget.dataset.index if (e.currentTarget.dataset.type == 'delete') { var syear = this.data.list[index].syear var smonth = this.data.list[index].smonth var eyear = this.data.list[index].eyear var emonth = this.data.list[index].emonth var type var content if (this.data.list[index].pay_for == 1 || this.data.list[index].pay_for == 2) { type = this.data.list[index].title + '缴纳' } else { type = this.data.list[index].title } if (this.data.list[index].nums == 1) { content = '是否要取消' + syear + '年' + smonth + '月的' + type + '订单' } else { content = '是否要取消' + syear + '年' + smonth + '月-' + eyear + '年' + emonth + '月的' + type + '订单' } swan.showModal({ title: '取消后将无法恢复', content: content, showCancel: true, cancelText: '取消', cancelColor: '#3296FB', confirmText: '确定', confirmColor: '#3296FB', success: res => { if (res.confirm) { this.deleteOrder(index) } } }) } else if (e.currentTarget.dataset.type == 'detail') { const animation = swan.createAnimation() animation.translateY(-500).step(); this.setData({ orderStatus: true }, () => { this.setData({ animationData: animation.export() }) }) var detail = {} detail.data = this.data.list[index] if (this.data.list[index].nums == 1) { detail.date = this.data.list[index].syear + '年' + this.data.list[index].smonth + '月' } else { detail.date = this.data.list[index].syear + '年' + this.data.list[index].smonth + '月-' + this.data.list[index].eyear + '年' + this.data.list[index].emonth + '月' } this.setData({ orderStatus: true, detail, currentData: this.data.list[index] }) } }, closeModal(status) { const animation = swan.createAnimation() animation.translateY(0).step(); this.setData({ animationData: animation.export(), cheapData: [] }, () => { setTimeout(() => { this.setData({ orderStatus: false, discountStatus: false }) if(status=='showPay'){ this.showPayModal() } }, 400) }) this.data.discountData.forEach((item) => { item.isSelected = false }) this.setData({discountData:this.data.discountData,cheapDataLength:0}) }, initData() { swan.showLoading({ title: '请稍后...', mask: true, }); net.connectNeedLogin({ url: url.app_host + url.getWaitForPayList, data: {}, success: (err, res) => { this.setData({ list: res.data }) if (this.data.list.length) { this.setData({ isEmpty: false }) } else { this.setData({ isEmpty: true }) } swan.hideLoading(); this.countTime() }, failed: (err, res) => { swan.hideLoading(); businessT.showFailTips(err) } }) net.connectNeedLogin({ url: url.app_host + url.getCashCoupon, data: { phone: app.globalData.userInfo.phone, page: 1, expired: 0 }, success: (err, res) => { this.getCashCouponListSuccess(res, 0) }, failed: (err, res) => { businessT.showFailTips(err) } }) }, getCashCouponListSuccess(res, expired) { var data = res.data.list if (data.length == 0) { this.setData({ haveCashCoupon: false }) return } else { this.setData({ haveCashCoupon: true }) } for (var index in data) { var item = data[index] if (item.status == 1 && item.expired == 0) { // item.end_time = '2019-03-17 00:00:01' var now = new Date().format('yyyy-MM-dd h:m:s') var nowDate = now.slice(0, 10) var endDate = item.end_time.slice(0, 10) if (nowDate == endDate) { item.p = '今天过期' } else { var tempNowDate = nowDate + ' 00:00:00' var tempEndDate = endDate + ' 00:00:00' var d = businessT.dateDiff('d', tempNowDate, tempEndDate) if (tempEndDate == item.end_time) { d -= 1 } if (d == 0) { item.p = '今天过期' } else { item.p = '还有' + d + '天过期' } } } else { if (item.status == 1) { item.p = '已过期' } else { item.p = '已使用' } } item.end = item.end_time.slice(0, 10) } this.setData({ discountData: data }) }, choose(e) { let current = this.data.discountData[e.currentTarget.id] var i, cheapMoney = 0 if (current.isSelected) { current.isSelected = false this.data.cheapData.forEach((item, index) => { if (current.id == item.id) { i = index } }) this.data.cheapData.splice(i, 1) } else { if (this.data.cheapData.length < this.data.nums) { current.isSelected = true this.data.cheapData.push(current) } else { swan.showToast({ title: '本次购买仅可选择' + this.data.nums + '张抵用券', icon: 'none', mask: false }); } } this.data.cheapData.forEach((item, index) => { cheapMoney += item.coupon_price }) this.setData({ discountData: this.data.discountData, cheapDataLength: this.data.cheapData.length, cheapMoney: cheapMoney.toFixed(2) }) }, deleteOrder(index) { swan.showLoading({ title: '请稍后...', mask: true, }); net.connectNeedLogin({ url: url.app_host + url.cancelPurchaseOrder, data: { key: app.loginStatus.key, buy_no: this.data.list[index].buy_no }, success: (err, res) => { this.data.list.splice(index, 1) console.log(this.data.list) this.setData({ list: this.data.list }) swan.hideLoading(); swan.showToast({ title: '取消订单成功', icon: 'none' }); if (this.data.list.length == 0) { this.setData({ isEmpty: true }) } }, fail: (err, res) => { swan.hideLoading(); businessT.showFailTips(err) } }) }, countTime() { var length = String(this.data.list[0].start_month).length this.data.list.forEach((item) => { item.syear = String(item.start_month).substring(0, length - 2) item.smonth = String(item.start_month).slice(-2) if (item.smonth.indexOf('0') == 0) { item.smonth = item.smonth.slice(1) } if (Number(item.smonth) + item.nums == 13) { item.eyear = item.syear item.emonth = 12 } else if (Number(item.smonth) + item.nums > 13) { item.eyear = Number(item.syear) + 1 item.emonth = Number(item.smonth) + item.nums - 13 } else { item.eyear = Number(item.syear) item.emonth = Number(item.smonth) + item.nums - 1 } }) this.setData({ list: this.data.list }) }, showPayModal(e) { if (e) { var currentData = this.data.list[e.currentTarget.dataset.index] } else { var currentData = this.data.currentData } this.setData({ currentData }) this.getParams(currentData) if (this.data.discountData.length) { const animation = swan.createAnimation() animation.translateY(-500).step(); this.setData({ discountStatus: true, nums: currentData.nums }, () => { this.setData({ animationData: animation.export() }) }) } else { this.pay() } }, showPayModalLater() { this.closeModal('showPay') }, getParams(currentData) { var obj = { sbuId: currentData.sbuId, id_card: '', cid: currentData.cid, month: currentData.start_month, newCard: currentData.newCard, shebao_card: currentData.shebao_card, hukou_type: currentData.hukou_type, fund: currentData.fund / currentData.nums, couponuser_id: '', pay_channel: 13, nums: currentData.nums, first_sb: currentData.first_sb, first_fund: currentData.first_fund, sb_wage: currentData.sb_wage, working: currentData.working } if (currentData.pay_for == 2) { obj.buyShebao = false } else { obj.buyShebao = true } this.setData({ payData: obj }) console.log(obj) }, pay() { var currentData = this.data.currentData, path if (this.data.cheapData.length) { var id = '' this.data.cheapData.forEach((item) => { if (item) { id += item.id + ',' } }) if (id) { id = id.slice(0, -1) } this.data.payData.couponuser_id = id } if (currentData.pay_for == 1 || currentData.pay_for == 3) { if (currentData.added) { path = url.createShebaoSupplementaryPayOrder } else { path = url.createShebaoOrder } } else if (currentData.pay_for == 2 || currentData.pay_for == 4) { if (currentData.added) { path = url.createFundSupplementaryPayOrder } else { path = url.createFundOrder } } net.connectNeedLogin({ url: url.app_host + path, data: this.data.payData, success: (err, res) => { swan.requestPolymerPayment({ orderInfo: res.data, success: res => { this.needSurvey() }, fail: err => { swan.showToast({ title: '支付失败', icon: 'none' }); } }); }, fail: (err, res) => { swan.hideLoading() businessT.showFailTips(err, '提交订单失败') } }, true) if (this.data.orderStatus || this.data.discountStatus) { this.closeModal() } }, needSurvey() { if(wxyj.wxyjData.order.sb_wage){ swan.navigateTo({ url: '../../../../public/pages/pay-success/pay-success?type=salary' }); return } net.connectNeedLogin({ url: url.app_host + url.checkSurvey, data: {}, success: (err, res) => { if (res.data) { swan.navigateTo({ url: '../../../../public/pages/pay-success/pay-success?type=survey&payfor=' + order.pay_for, }); }else{ this.needRepair() } }, fail: (err, res) => { swan.navigateTo({ url: '../../../../public/pages/pay-success/pay-success?type=share' }); } }, false) }, needRepair(){ net.connectNeedLogin({ url: url.app_host + url.queryPayPriceDifference, data: {}, success: (err, res) => { if(res.data){ swan.navigateTo({ url: '../../../../public/pages/pay-success/pay-success?type=repair' }); }else{ swan.navigateTo({ url: '../../../../public/pages/pay-success/pay-success?type=share' }); } }, fail: (err, res) => { swan.navigateTo({ url: '../../../../public/pages/pay-success/pay-success?type=share' }); } },false) }, onLoad: function () { // 监听页面加载的生命周期函数 this.initData() this.setData({ suffix: sysT.suffixOfClass() }) swan.setPageInfo && swan.setPageInfo({ title: '【我的社保】官方APP-社保挂靠公积金代理全国自助缴纳查询社保公积金_主页', keywords: '我的社保,我的社保网,我的社保APP,社会保障,社保,社保代缴,公积金代缴,社会保险,五险一金,医保,医疗保险,公积金,养老,生育,工伤,失业,住房公积金,社保代理,代缴社保,公积金代理,查悦社保,大社保,亲亲小保,社保掌上通,招聘求职,创业,买房,贷款,计算器,人社局,摇号', description: '我的社保APP是为个人、企业提供社保代缴代扣、公积金代扣代缴、社保查询、公积金查询服务的名牌产品。解决个体工商户、自由职业者、待业人员、全职妈妈、创业者等的个人社保公积金断缴难题,同时解决贷款, 买房, 买车, 养老, 医疗, 生育, 医疗报销等难题。同时为企业提供全国专业社保代理和公积金代理。', articleTitle: '【我的社保】官方APP-社保挂靠公积金代理全国自助缴纳查询社保公积金_主页', release_date: '2019-02-23 20:00:00', success: function () { console.log('页面基础信息设置完成'); }, fail: function (res) { console.log('设置失败'); }, }) }, onReady: function () { // 监听页面初次渲染完成的生命周期函数 }, onShow: function () { // 监听页面显示的生命周期函数 }, onHide: function () { // 监听页面隐藏的生命周期函数 }, onUnload: function () { // 监听页面卸载的生命周期函数 }, onPullDownRefresh: function () { // 监听用户下拉动作 }, onReachBottom: function () { // 页面上拉触底事件的处理函数 }, onShareAppMessage: function () { // 用户点击右上角转发 } });