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 pay = require('../../../../public/pay.js') var businessType = require('../../../../public/business-type.js') var app = getApp() Page({ /** * 页面的初始数据 */ data: { scroll: true, isLoading: true, detailsView: { // data: {}, // scroll: false, // left: 0, hidden: true, // animation: {}, // discountU: false, // status: 1, // sa: false, // isSalary: true }, tab: { id: '1', animation: {} }, data: [[], []],//bs1是只有左边按钮,2是右边有一按钮,3都展示,4流水 hadLeft: false,//判断左边是否有数据 hadRight: false,//判断右边边是否有数据 bgAnimation: {} }, getDetailsView: function () { return { data: {}, scroll: false, left: 0, hidden: true, animation: { }, discountU: false, status: 1, sa: false, isSalary: true, failReason: '' } }, tabChoose: businessT.action(function (sender) { if (sender.currentTarget.id == this.data.tab.id) { return } // this.data.bgScrollView.scroll = true; // this.setData({ // bgScrollView: this.data.bgScrollView // }) var animation = wx.createAnimation({ duration: 300, timingFunction: 'ease', }) var bgAnimation = wx.createAnimation({ duration: 300, timingFunction: 'ease', }) var w = sysT.sysInfo().windowWidth businessT.debugLog(w) var s = sender.currentTarget.id - 1 // if (sender.currentTarget.id == "1") { // animation.translateX(0).step() // this.data.bgScrollView.left = 0 // } else { // animation.translateX(w / 2).step() // this.data.bgScrollView.left = sysT.sysInfo().windowWidth // } animation.translateX(s * w / 2).step() bgAnimation.translateX(-w * s).step() this.data.tab.id = sender.currentTarget.id this.data.tab.animation = animation.export() // this.data.bgScrollView.scroll = false; this.setData({ tab: this.data.tab, bgAnimation: bgAnimation.export() // bgScrollView: this.data.bgScrollView }) businessT.debugLog(sender.currentTarget.id) if (this.data.tab.id == "1") { if (!this.data.hadLeft) { this.getOrderData(true) } } else { if (!this.data.hadRight) { this.getOrderData(false) } } }), progressAction: businessT.action(function (sender) { this.showDetails(sender.currentTarget.id, '返还状态') this.detailsScroll(1, false) }), payAction: businessT.action(function (sender) { businessT.debugLog(sender) this.showDetails(sender.currentTarget.id, '社保流水订单详情') this.detailsScroll(1, false) }), detailsAction: businessT.action(function (sender) { businessT.debugLog(sender) this.showDetails(sender.currentTarget.id, '社保流水订单详情') }), detailsPay: businessT.action(function (sender) { businessT.debugLog(sender) this.detailsScroll(1, true) }), showProgress: businessT.action(function (sender) { this.data.detailsView.title = '返还状态' this.setData({ detailsView: this.data.detailsView }) this.detailsScroll(1, true) }), showDetails: function (i, title) { if (!this.data.detailsView.hidden) { return } var t = Number(this.data.tab.id) var data = this.data.data[t - 1][i] this.data.detailsView = this.getDetailsView() this.data.detailsView.suffix = sysT.suffixOfClass() this.data.detailsView.data = data this.data.detailsView.title = title this.data.detailsView.status = data.pay_status var month = String(data.opt_month) month = month.substring(0, 4) + '年' + month.substring(4,6) + '月' if (data.pay_status == businessType.SalaryOrderStatus.salaryOrderStatusNotPay) { var time = data.gen_time if (time.length > 16) { time = String(time).substring(0, 16) } this.data.detailsView.mt = '参保姓名\n月份\n城市\n截止付款时间\n预计返还时间\n创建时间' this.data.detailsView.m = data.uname + '\n' + month + '\n' + data.city + '\n' + data.pay_date + '\n流水月逢周三返还' + '\n' + time } else { var time = data.pay_time if (time.length > 16) { time = String(time).substring(0, 16) } this.data.detailsView.mt = '参保姓名\n月份\n城市\n预计返还时间\n成交时间' this.data.detailsView.m = data.uname + '\n' + month + '\n' + data.city + '\n流水月逢周三返还' + '\n' + time //需要流水进度 var bankCard = null var haveCustomer = false for (var i = 0; i < app.globalData.customerList.length; i ++) { var customer = app.globalData.customerList[i] // businessT.debugLog(customer) if (customer.id == data.sbu_id) { haveCustomer = true this.data.editCustomerIndex = i if (customer.bank && customer.bank.length != 0 && customer.bank_code && customer.bank_code.length != 0) { var bankCode = String(customer.bank_code) bankCard = customer.bank + '(' + bankCode.substring(bankCode.length - 4) + ')' } break } } this.data.detailsView.haveNoCustomer = false this.data.detailsView.haveNoBank = false this.data.detailsView.isFail = false // if(1) { if (data.pay_status == businessType.SalaryOrderStatus.salaryOrderStatusPaySuccessAndNotBack && !haveCustomer) { this.data.detailsView.haveNoCustomer = true this.data.detailsView.progressInfoT = '收款姓名\n返还账户' this.data.detailsView.progressInfoC = data.uname + '\n暂无' // } else if (1) { } else if (data.pay_status == businessType.SalaryOrderStatus.salaryOrderStatusPaySuccessAndNotBack && !bankCard) { this.data.detailsView.haveNoBank = true this.data.detailsView.progressInfoT = '收款姓名\n返还账户' this.data.detailsView.progressInfoC = data.uname + '\n暂无' // } else if (1) { } else if (data.pay_status == businessType.SalaryOrderStatus.salaryOrderStatusPaySuccessAndBackFail) { this.data.detailsView.isFail = true this.data.detailsView.failReason = data.fail_reason if (!haveCustomer) { this.data.detailsView.haveNoCustomer = true this.data.detailsView.progressInfoT = '收款姓名' this.data.detailsView.progressInfoC = data.uname } else if (!bankCard) { this.data.detailsView.haveNoBank = true this.data.detailsView.progressInfoT = '收款姓名' this.data.detailsView.progressInfoC = data.uname } else { this.data.detailsView.progressInfoT = '收款姓名\n返还账户' this.data.detailsView.progressInfoC = data.uname + '\n' + bankCard } } else if (!haveCustomer || !bankCard || data.pay_status == businessType.SalaryOrderStatus.salaryOrderStatusReturnBack || data.pay_status == businessType.SalaryOrderStatus.salaryOrderStatusRefund) { this.data.detailsView.progressInfoT = '收款姓名' this.data.detailsView.progressInfoC = data.uname } else { this.data.detailsView.progressInfoT = '收款姓名\n返还账户' this.data.detailsView.progressInfoC = data.uname + '\n' + bankCard } this.data.detailsView.progressPayT = data.pay_time.substring(5, 16) this.data.detailsView.progressBack = data.wage.toFixed(2) this.data.detailsView.progressPayTime = data.pay_time if (this.data.detailsView.progressPayTime.length > 16) { this.data.detailsView.progressPayTime = this.data.detailsView.progressPayTime.substring(0,16) } if (data.pay_status == businessType.SalaryOrderStatus.salaryOrderStatusBack || data.pay_status == businessType.SalaryOrderStatus.salaryOrderStatusReturnBack || data.pay_status == businessType.SalaryOrderStatus.salaryOrderStatusRefund) { this.data.detailsView.progressStatus = '交易成功' this.data.detailsView.progressStatusColor = '#3AB261' this.data.detailsView.progressLineImg = 'salary_line' this.data.detailsView.progressBackImg = 'salary_done' this.data.detailsView.progressBackColor = '#3296FB' this.data.detailsView.progressBackT = data.hf_time.substring(5, 16) } else { this.data.detailsView.progressStatus = '等待处理' this.data.detailsView.progressStatusColor = '#FF8D36' if (this.data.detailsView.isFail) { this.data.detailsView.progressLineImg = 'salary_line' this.data.detailsView.progressBackImg = 'salary_failure' this.data.detailsView.progressBackColor = '#FF5E5E' this.data.detailsView.progressBackT = null } else { this.data.detailsView.progressLineImg = 'salary_dashed' this.data.detailsView.progressBackImg = 'salary_undone' this.data.detailsView.progressBackColor = '#999999' this.data.detailsView.progressBackT = null } } } this.data.detailsView.t = data.a // this.data.detailsView.id = i var at = '社保流水 (返还费用)\n服务费' var a = '¥' + data.wage.toFixed(2) + '\n¥' + data.charge.toFixed(2) this.data.detailsView.at = at this.data.detailsView.a = a this.data.detailsView.hidden = false //为了兼容iOS低版本系统,不能用bottom,所以计算margan-top的位置 sysT.adaptor() businessT.debugLog(sysT.sysInfo().windowHeight) var s = this.data.detailsView.suffix == '-X' ? -1068 : -1000 s = sysT.rpxToPx() * s this.data.detailsView.top = sysT.sysInfo().windowHeight - s this.setData({ detailsView: this.data.detailsView, scroll: false }) setTimeout(function () { var animation = wx.createAnimation({ duration: 300, timingFunction: 'ease', }) // animation.top('0rpx').step() animation.translateY(s).step() this.data.detailsView.animation = animation.export() this.setData({ detailsView: this.data.detailsView }) }.bind(this), 100) }, hiddenDetails: businessT.action(function (sender) { this.hiddenDetailsAction() }), hiddenDetailsAction: function () { this.detailsScroll(0, false) var animation = wx.createAnimation({ duration: 300, timingFunction: 'ease', }) animation.translateY(0).step() this.data.detailsView.animation = animation.export() this.setData({ detailsView: this.data.detailsView }) setTimeout(function () { this.data.detailsView.hidden = true this.setData({ detailsView: this.data.detailsView, scroll: true }) }.bind(this), 300) }, detailsScroll: function (i, a) { this.data.detailsView.scroll = true this.data.detailsView.sa = a this.setData({ detailsView: this.data.detailsView }) this.data.detailsView.left = i * sysT.sysInfo().windowWidth this.data.detailsView.scroll = false; this.setData({ detailsView: this.data.detailsView }) }, detailsConfirmPay: businessT.action(function (sender) { wx.showLoading({ title: '正在提交订单', mask: true }) pay.prepay({ success: e => { this.createOrder() }, fail: e => { wx.hideLoading() businessT.showFailTips(err, '提交订单失败') } }) }), createOrder: function () { var data = this.data.detailsView.data var that = this net.connectNeedLogin({ url: url.app_host + url.createSalaryOrder, data: { order_no: data.order_no, pay_channel: 5 }, success: (err, res) => { pay.wxPay({ data: res.data, success: e => { that.judgeCustomer() }, fail: e => { wx.hideLoading() businessT.showFailTips(err, '提交订单失败') } }) }, fail: (err, res) => { wx.hideLoading() businessT.showFailTips(err, '提交订单失败') } }, true) }, judgeCustomer: function () { var id = this.data.detailsView.data.sbu_id var haveBank = false var haveCustomer = false for (var i = 0; i < app.globalData.customerList.length; i++) { var customer = app.globalData.customerList[i] // businessT.debugLog(customer) if (customer.id == id) { haveCustomer = true if (customer.bank && customer.bank.length != 0 && customer.bank_code && customer.bank_code.length != 0) { haveBank = true } break } } var pages = getCurrentPages() if (!haveCustomer) { businessT.debugLog('haveNoCustomer') pages[0].route('../../public/pages/pay-success/pay-success?type=tipsCard') } else if (!haveBank) { businessT.debugLog('haveNoBank') pages[0].route('../../public/pages/pay-success/pay-success?type=addCard&customerId='+ id) } else { pages[0].route('../../public/pages/pay-success/pay-success?type=none') } }, getOrderData: function (isLeft) { wx.showLoading({ title: '加载中', mask: true }) this.setData({ isLoading: true }) var u = isLeft ? url.getUndoneSalaryList : url.getDoneSalaryList net.connectNeedLogin({ url: url.app_host + u, data: {}, success: (err, res) => { var data = this.handleOrderData(res.data) businessT.debugLog(res.data) if (isLeft) { this.data.hadLeft = true this.data.data[0] = data } else { this.data.hadRight = true this.data.data[1] = data } this.data.isLoading = false this.setData({ data: this.data.data, isLoading: this.data.isLoading }) wx.hideLoading() }, fail: (err, res) => { wx.hideLoading() businessT.showFailTips(err, '加载失败') setTimeout(function () { wx.navigateBack({ }) }.bind(this), 1000) } }, true) }, handleOrderData: function (data) { var r = [] for (var i in data) { var item = data[i] item.orderListType = businessType.OrderListType.orderListTypeSalary item.isSalary = true item.a = item.total_fee.toFixed(2) item.title = String(item.opt_month).substring(4, 6) + '月社保流水' // item.details = '查看补差额月份' item.ct = '参保姓名\n购买月份' var month = String(item.opt_month).substring(0, 4) + '年' + String(item.opt_month).substring(4, 6) + '月' item.c = item.uname + '\n' + month if (item.pay_status == businessType.SalaryOrderStatus.salaryOrderStatusNotPay) { item.s = { t: '等待付款', c: 'order-item-status-w' } item.hasSalaryTips = true item.salaryTips = 'salary_sj_w' item.salaryTipsC = 'salary-tips-status-w' item.st = '截止付款时间' item.sc = item.pay_date item.bs = 2 } else { if (item.pay_status == businessType.SalaryOrderStatus.salaryOrderStatusBack || item.pay_status == businessType.SalaryOrderStatus.salaryOrderStatusRefund || item.pay_status == businessType.SalaryOrderStatus.salaryOrderStatusReturnBack) { item.hasSalaryTips = false item.s = { t: '返还成功', c: 'order-item-status-f' } } else if (item.pay_status == businessType.SalaryOrderStatus.salaryOrderStatusPaySuccessAndBackFail) { item.hasSalaryTips = true item.s = { t: '返还失败', c: 'order-item-status-fail' } } else { item.hasSalaryTips = true item.s = { t: '交易完成', c: 'order-item-status-f' } } item.salaryTips = 'salary_sj_f' item.salaryTipsC = 'salary-tips-status-f' item.st = '预计返还时间' item.sc = '流水月逢周三返还' item.bs = 4 } r.push(item) } return r }, editCustomer: businessT.action(function (sender) { this.hiddenDetailsAction() this.data.hadLeft = false this.data.hadRight = false wx.navigateTo({ url: '../../../../public/pages/edit-bank/edit-bank?i=' + this.data.editCustomerIndex, }) }), /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { // this.data.detailsView.suffix = sysT.suffixOfClass() this.getOrderData(true) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { if (this.data.tab.id == "1") { if (!this.data.hadLeft) { this.getOrderData(true) } } else { if (!this.data.hadRight) { this.getOrderData(false) } } }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { return { path: '/page/home/index', imageUrl: '../../../../icon/public/share_img.png', title: '自助缴社保公积金,覆盖200多个城市,专业团队操作' } } })