123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420 |
- 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多个城市,专业团队操作'
- }
- }
- })
|