123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 |
- var wxyj = require('../../../public/wxyj.js')
- Page({
- data: {
- selected: 0,
- monthData: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, '', '', ''],
- calendarStatus: 0,
- tabbarStatus: 0,
- canChoose: true
- },
- initData() {
- if (this.data.quickPay) {
- var year = String(this.data.date).slice(0, 4)
- var month = String(this.data.date).slice(4)
- var y = Number(year), yearData = [y, y + 1, y + 2]
- this.setData({
- initMonth: Number(month),
- sYear: year,
- yearData
- })
- this.data.sMonth[0][0] = this.data.initMonth - 1
- this.data.sMonth[0][1] = this.data.initMonth + 6
- if (this.data.initMonth > 6) {
- this.data.sMonth[1][1] = this.data.initMonth - 6
- } else {
- this.data.sMonth[1][1] = 0
- }
- this.setData({
- sMonth: this.data.sMonth
- })
- } else {
- var year = String(wxyj.wxyjData.data.wxyj[0].month).slice(0, 4)
- var month = String(wxyj.wxyjData.data.wxyj[0].month).slice(4)
- var minNums = wxyj.wxyjData.data.wxyj[0].nums
- if (this.data.type == 0 || this.data.type == 2) {
- console.log(this.data.sMonth)
- var y = Number(year), yearData = [y, y + 1, y + 2]
- this.setData({
- initMonth: Number(month),
- sYear: year,
- minNums,
- yearData
- })
- this.data.sMonth[0][0] = this.data.initMonth - 1
- this.data.sMonth[0][1] = this.data.initMonth + 6
- if (this.data.initMonth > 6) {
- this.data.sMonth[1][1] = this.data.initMonth - 6
- } else {
- this.data.sMonth[1][1] = 0
- }
- this.setData({
- sMonth: this.data.sMonth
- })
- } else if (this.data.type == 1) {
- var y = Number(year), yearData = [y - 1, y]
- var n = wxyj.wxyjData.data.wxyj[0].addeds_num
- this.setData({
- initMonth: Number(month) - 1,
- sYear: year,
- minNums,
- yearData
- })
- if (n > this.data.initMonth) {
- this.data.sMonth[0][0] = 12 - n + this.data.initMonth
- this.data.sMonth[0][1] = 13
- this.data.sMonth[1][0] = 0
- this.data.sMonth[1][1] = this.data.initMonth + 1
- } else {
- this.data.sMonth[1][0] = this.data.initMonth - n
- this.data.sMonth[1][1] = this.data.initMonth + 1
- }
- this.setData({
- sMonth: this.data.sMonth
- })
- console.log(this.data.sMonth)
- } else if (this.data.type == 3) {
- var y = Number(year), yearData = [y - 1, y]
- var n = wxyj.wxyjData.data.wxyj[0].addedf_num
- this.setData({
- initMonth: Number(month) - 1,
- sYear: year,
- minNums,
- yearData
- })
- if (n > this.data.initMonth) {
- this.data.sMonth[0][0] = 12 - n + this.data.initMonth
- this.data.sMonth[0][1] = 13
- this.data.sMonth[1][0] = 0
- this.data.sMonth[1][1] = this.data.initMonth + 1
- } else {
- this.data.sMonth[1][0] = this.data.initMonth - n
- this.data.sMonth[1][1] = this.data.initMonth + 1
- }
- this.setData({
- sMonth: this.data.sMonth
- })
- }
- }
- },
- createAnimation() {
- var width, moveX
- swan.createSelectorQuery().select('#tabItem').boundingClientRect((rect) => {
- width = parseInt(rect.width)
- }).exec()
- swan.createSelectorQuery().select('#tabbar').boundingClientRect((rect) => {
- moveX = parseInt(rect.width) - width
- var animation = swan.createAnimation()
- animation.translateX(moveX).step();
- this.setData({
- selected: 1,
- animationData: animation.export()
- })
- }).exec()
- },
- choose(e) {
- if (e.currentTarget.dataset.status == "able") {
- if (this.data.quickPay) {
- var sy, sm
- sy = e.currentTarget.dataset.value.substring(0, 4)
- sm = e.currentTarget.dataset.value.slice(4)
- var page = getCurrentPages()
- var prevPage = page[page.length - 2]
- prevPage.setData({ year: sy, month: sm })
- this.setData({ canChoose: false, sy, sm })
- setTimeout(() => {
- swan.navigateBack()
- }, 1000)
- return
- }
- if (this.data.type == 0 || this.data.type == 2) {
- if (this.data.calendarStatus == 0) {
- var sy, sm
- sy = Number(e.currentTarget.dataset.value.substring(0, 4))
- sm = Number(e.currentTarget.dataset.value.slice(4))
- if (this.data.sYear == sy) {
- this.data.sMonth[0][1] = sm + 12
- this.data.sMonth[1][1] = sm
- } else {
- this.data.sMonth[1][1] = sm + 12
- this.data.sMonth[2][1] = sm
- }
- this.setData({
- calendarStatus: 1,
- tabbarStatus: 1,
- sMonth: this.data.sMonth,
- sy,
- sm
- })
- this.createAnimation()
- } else if (this.data.calendarStatus == 1) {
- var ey, em
- ey = Number(e.currentTarget.dataset.value.substring(0, 4))
- em = Number(e.currentTarget.dataset.value.slice(4))
- if (ey == this.data.sy && em < this.data.sm) {
- if (ey == this.data.sYear) {
- this.data.sMonth[0][1] = em + 12
- this.data.sMonth[1][1] = em
- this.data.sMonth[2][1] = 0
- } else {
- this.data.sMonth[1][1] = em + 12
- this.data.sMonth[2][1] = em
- }
- this.setData({
- calendarStatus: 1,
- tabbarStatus: 1,
- sMonth: this.data.sMonth,
- sy: ey,
- sm: em
- })
- } else if (ey < this.data.sy) {
- this.data.sMonth[0][1] = em + 12
- this.data.sMonth[1][1] = em
- this.data.sMonth[2][1] = 0
- console.log(this.data.sMonth)
- this.setData({
- calendarStatus: 1,
- tabbarStatus: 1,
- sMonth: this.data.sMonth,
- sy: ey,
- sm: em
- })
- } else {
- if (this.data.sy == ey) {
- wxyj.wxyjData.order.nums = em - this.data.sm + 1
- } else {
- wxyj.wxyjData.order.nums = 13 - this.data.sm + em
- }
- if (wxyj.wxyjData.order.nums < wxyj.wxyjData.data.wxyj[0].nums) {
- swan.showToast({
- title: '你选择的城市至少需要购买2个月',
- icon: 'none',
- mask: true
- });
- return
- }
- this.setData({
- calendarStatus: 2,
- tabbarStatus: 2,
- ey,
- em
- })
- }
- }
- } else {
- if (this.data.calendarStatus == 0) {
- var sy, sm
- sy = Number(e.currentTarget.dataset.value.substring(0, 4))
- sm = Number(e.currentTarget.dataset.value.slice(4))
- this.setData({
- calendarStatus: 1,
- tabbarStatus: 1,
- sMonth: this.data.sMonth,
- sy,
- sm
- })
- this.createAnimation()
- } else if (this.data.calendarStatus == 1) {
- var ey, em
- ey = Number(e.currentTarget.dataset.value.substring(0, 4))
- em = Number(e.currentTarget.dataset.value.slice(4))
- if (ey == this.data.sy) {
- if (em < this.data.sm) {
- this.setData({
- calendarStatus: 1,
- tabbarStatus: 1,
- sMonth: this.data.sMonth,
- sy: ey,
- sm: em
- })
- } else {
- this.setData({
- calendarStatus: 2,
- tabbarStatus: 2,
- sMonth: this.data.sMonth,
- ey,
- em
- })
- }
- } else if ((ey > this.data.sy)) {
- this.setData({
- calendarStatus: 2,
- tabbarStatus: 2,
- sMonth: this.data.sMonth,
- ey,
- em
- })
- } else {
- this.setData({
- calendarStatus: 1,
- tabbarStatus: 1,
- sMonth: this.data.sMonth,
- sy: ey,
- sm: em
- })
- }
- }
- }
- if (this.data.calendarStatus == 2) {
- if (this.data.sy == this.data.ey) {
- wxyj.wxyjData.order.nums = this.data.em - this.data.sm + 1
- } else {
- wxyj.wxyjData.order.nums = 13 - this.data.sm + this.data.em
- }
- wxyj.wxyjData.startTime = [this.data.sy, this.data.sm]
- wxyj.wxyjData.endTime = [this.data.ey, this.data.em]
- this.setData({ canChoose: false })
- setTimeout(() => {
- swan.navigateBack()
- }, 1000)
- }
- } else {
- return
- }
- },
- onLoad: function (res) {
- // 监听页面加载的生命周期函数
- this.setData({
- type: res.type,
- quickPay: res.quickPay,
- date: res.date,
- sMonth: [[0, 0], [0, 0], [0, 0]]
- })
- this.initData()
- },
- onReady: function () {
- // 监听页面初次渲染完成的生命周期函数
- },
- onShow: function () {
- // 监听页面显示的生命周期函数
- 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('设置失败');
- },
- })
- wxyj.wxyjData.startTime = []
- wxyj.wxyjData.endTime = []
- },
- onHide: function () {
- // 监听页面隐藏的生命周期函数
- },
- onUnload: function () {
- // 监听页面卸载的生命周期函数
- },
- onPullDownRefresh: function () {
- // 监听用户下拉动作
- },
- onReachBottom: function () {
- // 页面上拉触底事件的处理函数
- },
- onShareAppMessage: function () {
- // 用户点击右上角转发
- }
- });
|