123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445 |
- 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()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- ui: {
- tab: [['在线客服', 'info_o_s'], ['客服热线', 'info_p'], ['留言反馈', 'info_m']]
- },
- broadcast: {
- w: 0,
- n: 0,
- s: false,
- b:'',
- fa: '',
- sa: '',
- ta: '',
- fc: 'n',
- sc: 'h',
- tc: 'h'
- },
- data: [],
- questionIndex: 0,
- questions: [],
- details: {},
- scroll: true,
- questionDetailsView: {
- animation: {},
- hidden: true,
- scroll:0
- },
- showContact: false,
- //客服需要的
- isLogin: false,
- userInfo: {
- avatarUrl: ''
- },
- params: {
- }
- },
- hiddenContactListener: function(e) {
- businessT.debugLog('hiddenContactListener')
- this.setData({
- scroll: true
- })
- },
- showQuestionDetails:businessT.action(function (sender) {
- businessT.debugLog(sender.currentTarget.id)
- if (!this.data.questionDetailsView.hidden) {
- return
- }
- var i = this.data.questionIndex + Number(sender.currentTarget.id)
- if (i > this.data.data.length - 1) {
- i = i - this.data.data.length
- }
- this.data.details = this.data.data[i]
- businessT.debugLog(i)
- this.data.questionDetailsView.hidden = false
- this.setData({
- questionDetailsView: this.data.questionDetailsView,
- scroll: false,
- details: this.data.details
- })
- var animation = wx.createAnimation({
- duration: 300,
- timingFunction: 'ease',
- })
- animation.bottom('0rpx').step()
- this.setData({
- questionDetailsView: {
- animation: animation.export(),
- hidden: false
- }
- })
- }),
- hiddenQuestionDetail:businessT.action(function (sender) {
- var animation = wx.createAnimation({
- duration: 300,
- timingFunction: 'ease',
- })
- animation.bottom('-800rpx').step()
- this.setData({
- questionDetailsView: {
- animation: animation.export(),
- hidden: false
- }
- })
- setTimeout(function () {
- this.data.questionDetailsView.hidden = true
- this.setData({
- questionDetailsView: this.data.questionDetailsView,
- scroll: true
- })
- }.bind(this), 300)
- }),
- judgeIsLogin: function () {
- if (app.loginStatus.key == "") {
- wx.navigateTo({
- url: '../login/index',
- })
- return false
- }
- return true
- },
- tabAction: businessT.action(function (sender) {
- businessT.debugLog(sender.currentTarget)
- switch (sender.currentTarget.id) {
- case '0': {
- if (!this.judgeIsLogin()) {
- return
- }
- // wx.navigateTo({
- // url: '../../public/pages/html/html?host=http://testwdsbh5.shanp.com/user.html&channel=h5XCX&phone=' + app.globalData.userInfo.phone + '&uid=' + app.globalData.userInfo.uid + '&t=' + new Date().getTime(),
- // })
- break
- }
- case '1': {
- this.setData({
- showContact: true,
- scroll: false
- })
- break
- }
- case '2': {
- businessT.debugLog('a')
- if (!this.judgeIsLogin()) {
- return
- }
- wx.navigateTo({
- url: 'pages/leave-message-list/leave-message-list',
- })
- break
- }
- }
- }),
- 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()
- },
- deleteBroadcast: businessT.action(function (sender) {
- if (this.broadcastTimeout) {
- clearTimeout(this.broadcastTimeout)
- }
- this.data.broadcast.s = false
- this.setData({
- broadcast: this.data.broadcast
- })
- }),
- route: function (path) {
- var pages = getCurrentPages()
- wx.navigateBack({
- delta: pages.length
- })
- setTimeout(function () {
- wx.navigateTo({
- url: path,
- })
- }.bind(this), 500)
- },
- changeQuestion: businessT.action(function (sender) {
- var l = this.data.questionIndex + 5
- this.data.questions = []
- for (var i = 0; i < 5; i++) {
- var ind = i + l
- if (ind > this.data.data.length - 1) {
- ind = ind - this.data.data.length
- }
- businessT.debugLog(ind)
- this.data.questions.push(this.data.data[ind].topic)
- }
- if (l > this.data.data.length - 1) {
- l = l - this.data.data.length
- }
- this.data.questionIndex = l
- this.setData({
- questions: this.data.questions
- })
- }),
- getQuestions: function () {
- net.connect({
- url: url.app_host + url.getHotTopicList,
- data: {},
- method: 'GET',
- success: (err, res) => {
- this.data.data = res.data
- var max = this.data.data.length > 5 ? 5 : this.data.data.length
- for (var i = 0; i < max; i++) {
- this.data.questions.push(this.data.data[i].topic)
- }
- this.setData({
- questions: this.data.questions
- })
- },
- fail: (err, res) => {
- }
- }, true)
- },
- getBroadcast: function() {
- net.connect({
- url: url.app_host + url.getBroadcast,
- data: {},
- method: 'GET',
- success: (err, res) => {
- if (this.data.broadcast.b == res.data) {
- return
- }
- this.refreshBroacast(res.data)
- },
- fail: (err, res) => {
- }
- }, true)
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.getQuestions()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- if (typeof this.getTabBar === 'function' &&
- this.getTabBar()) {
- this.getTabBar().setData({
- redDot: app.tabRedDot,
- selected: 1
- })
- }
- this.judgeBroadcast()
- this.getBroadcast()
- this.data.userInfo.nickName = app.globalData.userInfo.phone
- this.data.params.phone = app.globalData.userInfo.phone
- this.data.params.userId = app.globalData.userInfo.uid
- this.setData({
- isLogin: app.loginStatus.isLogin,
- userInfo: this.data.userInfo,
- params: this.data.params
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- 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多个城市,专业团队操作'
- }
- }
- })
|