var businessT = require('../../tool/business-tool.js') var sysT = require('../../tool/sys-tool.js') var app = getApp() var redDot = require('../../public/red-dot.js') Page({ /** * 页面的初始数据 */ data: { ui:{ tab:[ ['mine_w_f_p', '待付款'], ['mine_s', '社保流水'], ['mine_b', '补差额'], ['mine_w_f_d', '待办事项'], ['mine_o', '我的订单'] ], row: [ ['coustomer', '购买人员'], ['discount', '优惠券'], ['address', '邮寄信息'], ['contact', '联系我们'], ['about', '我的社保'] ] }, broadcast: { w: 0, n: 0, s: false, b: '', fa: '', sa: '', ta: '', fc: 'n', sc: 'h', tc: 'h' }, redDot: ['0', '0', '0', '0', '0'], rowTips: ['', '', '', '', ''], showContact: false, scroll: true, isLogin: true, shouldGetRedDot: false }, hiddenContactListener: function (e) { businessT.debugLog('hiddenContactListener') this.setData({ scroll: true }) }, judgeIsLogin: function () { if (app.loginStatus.key == "") { wx.navigateTo({ url: '../login/index', }) return false } return true }, tabAction:businessT.action(function (sender) { businessT.debugLog(sender.currentTarget.id) if (!this.judgeIsLogin()) { return } this.shouldGetRedDot = true switch (sender.currentTarget.id) { case '0': { wx.navigateTo({ url: 'pages/wait-for-pay/wait-for-pay', }) break } case '1': { wx.navigateTo({ url: 'pages/salary/salary', }) break } case '2': { wx.navigateTo({ url: 'pages/pay-price-difference/pay-price-difference', }) break } case '3': { wx.navigateTo({ url: 'pages/wait-for-do/wait-for-do', }) break } case '4': { wx.navigateTo({ url: 'pages/my-order/my-order', }) break } } }), rowAction:businessT.action(function (sender) { businessT.debugLog(sender.currentTarget.id) switch (sender.currentTarget.id) { case '0': { if (!this.judgeIsLogin()) { return } wx.navigateTo({ url: '../../public/pages/customer-view/customer-view?type=manager', }) break } case '1': { if (!this.judgeIsLogin()) { return } wx.navigateTo({ url: '../../public/pages/discount-view/discount-view?type=show', }) break } case '2': { if (!this.judgeIsLogin()) { return } wx.navigateTo({ url: 'pages/address/address', }) break } case '3': { this.setData({ showContact: true, scroll: false }) break } case '4': { wx.navigateTo({ url: 'pages/about/about', }) break } default: break } }), changeAccountAction: businessT.action(function (sender) { wx.navigateTo({ url: '../login/index', }) }), refreshRedDot: function () { businessT.debugLog('refreshRedDot') this.setData({ redDot: app.redDotArray }) }, broadcastAction: businessT.action(function (sender) { this.shouldGetRedDot = true wx.navigateTo({ url: '../../public/pages/edit-bank/edit-bank?i=' + app.bankCardTips.c.id, }) }), broadcastAnimation: function (length) { if (length > (640 + 200) * sysT.rpxToPx()) { this.setData({ broadcast: this.data.broadcast }) this.broadcastTextAnimation(length) } businessT.debugLog(length) }, broadcastTextAnimation: function (length) { this.data.broadcast.n++ var t = length * 17.5 var y = this.data.broadcast.n % 3 businessT.debugLog(y) switch (y) { case 1: { this.data.broadcast.fa = 'transition: transform ' + t + 'ms linear 0ms; transform: translateX(-' + length + 'px); transform-origin: 50% 50% 0px;' this.data.broadcast.sa = 'transition: transform ' + t + 'ms linear 0ms; transform: translateX(-' + length + 'px); transform-origin: 50% 50% 0px;' this.data.broadcast.ta = 'transition: transform ' + t + 'ms linear 0ms; transform: translateX(-' + length + 'px); transform-origin: 50% 50% 0px;' this.data.broadcast.fc = 'n' this.data.broadcast.sc = 'n' this.data.broadcast.tc = 'h' if (this.data.broadcast.n == 1) { var d = 1000 setTimeout(function () { this.setData({ broadcast: this.data.broadcast }) }.bind(this), d) t = t + d } else { this.setData({ broadcast: this.data.broadcast }) } break } case 2: { this.data.broadcast.fa = 'transition: transform ' + t + 'ms linear 0ms; transform: translateX(' + length + 'px); transform-origin: 50% 50% 0px;' this.data.broadcast.sa = 'transition: transform ' + t + 'ms linear 0ms; transform: translateX(-' + (length * 2) + 'px); transform-origin: 50% 50% 0px;' this.data.broadcast.ta = 'transition: transform ' + t + 'ms linear 0ms; transform: translateX(-' + (length * 2) + 'px); transform-origin: 50% 50% 0px;' this.data.broadcast.fc = 'h' this.data.broadcast.sc = 'n' this.data.broadcast.tc = 'n' this.setData({ broadcast: this.data.broadcast }) break } case 0: { this.data.broadcast.fa = 'transition: transform ' + t + 'ms linear 0ms; transform: translateX(0px); transform-origin: 50% 50% 0px;' this.data.broadcast.sa = 'transition: transform ' + t + 'ms linear 0ms; transform: translateX(0px); transform-origin: 50% 50% 0px;' this.data.broadcast.ta = 'transition: transform ' + t + 'ms linear 0ms; transform: translateX(-' + (length * 3) + 'px); transform-origin: 50% 50% 0px;' this.data.broadcast.fc = 'n' this.data.broadcast.sc = 'h' this.data.broadcast.tc = 'n' this.setData({ broadcast: this.data.broadcast }) break } default: break } this.broadcastTimeout = setTimeout(function () { this.broadcastTextAnimation(length) }.bind(this), t) }, judgeBroadcast: function () { if (this.data.broadcast.s) { var query = wx.createSelectorQuery(); //选择id query.select('#broadcastText').boundingClientRect() var that = this; query.exec(function (res) { //res就是 该元素的信息 数组 businessT.debugLog(res[0]) that.data.broadcast.n = 0 var singleLength = res[0].width + 200 * sysT.rpxToPx() that.data.broadcast.w = singleLength * 3 that.broadcastAnimation(singleLength) }) } }, refreshBroacast: function (b) { if (this.broadcastTimeout) { clearTimeout(this.broadcastTimeout) } var broadcast = { w: 0, n: 0, s: true, b: b, fa: '', sa: '', ta: '', fc: 'n', sc: 'h', tc: 'h' } this.setData({ broadcast: broadcast }) this.judgeBroadcast() }, hiddenBroadcast: function () { if (this.broadcastTimeout) { clearTimeout(this.broadcastTimeout) } this.data.broadcast.s = false this.setData({ broadcast: this.data.broadcast }) }, deleteBroadcast: businessT.action(function (sender) { this.hiddenBroadcast() }), judgeBankCardTips: function () { if (app.bankCardTips.t) { this.refreshBroacast(app.bankCardTips.t) } else { this.hiddenBroadcast() } }, route: function (path) { var pages = getCurrentPages() wx.navigateBack({ delta: pages.length }) setTimeout(function () { wx.navigateTo({ url: path, }) }.bind(this), 500) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { if (typeof this.getTabBar === 'function' && this.getTabBar()) { this.getTabBar().setData({ redDot: app.tabRedDot, selected: 2 }) } this.judgeBankCardTips() if (this.shouldGetRedDot) { this.shouldGetRedDot = false redDot.getRedDot() } else { this.refreshRedDot() } var isLogin = app.loginStatus.key != "" if (isLogin != this.data.isLogin) { this.setData({ isLogin: isLogin }) } }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { if (this.broadcastTimeout) { clearTimeout(this.broadcastTimeout) } var broadcast = { w: this.data.broadcast.w, n: -100, s: this.data.broadcast.s, b: this.data.broadcast.b, fa: '', sa: '', ta: '', fc: 'n', sc: 'h', tc: 'h' } this.setData({ broadcast: broadcast }) }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { return { path: '/page/home/index', imageUrl: '../../icon/public/share_img.png', title: '自助缴社保公积金,覆盖200多个城市,专业团队操作' } } })