index.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. var businessT = require('../../tool/business-tool.js')
  2. var sysT = require('../../tool/sys-tool.js')
  3. var app = getApp()
  4. var redDot = require('../../public/red-dot.js')
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. ui:{
  11. tab:[
  12. ['mine_w_f_p', '待付款'],
  13. ['mine_s', '社保流水'],
  14. ['mine_b', '补差额'],
  15. ['mine_w_f_d', '待办事项'],
  16. ['mine_o', '我的订单']
  17. ],
  18. row: [
  19. ['coustomer', '购买人员'],
  20. ['discount', '优惠券'],
  21. ['address', '邮寄信息'],
  22. ['contact', '联系我们'],
  23. ['about', '我的社保']
  24. ]
  25. },
  26. broadcast: {
  27. w: 0,
  28. n: 0,
  29. s: false,
  30. b: '',
  31. fa: '',
  32. sa: '',
  33. ta: '',
  34. fc: 'n',
  35. sc: 'h',
  36. tc: 'h'
  37. },
  38. redDot: ['0', '0', '0', '0', '0'],
  39. rowTips: ['', '', '', '', ''],
  40. showContact: false,
  41. scroll: true,
  42. isLogin: true,
  43. shouldGetRedDot: false
  44. },
  45. hiddenContactListener: function (e) {
  46. businessT.debugLog('hiddenContactListener')
  47. this.setData({
  48. scroll: true
  49. })
  50. },
  51. judgeIsLogin: function () {
  52. if (app.loginStatus.key == "") {
  53. wx.navigateTo({
  54. url: '../login/index',
  55. })
  56. return false
  57. }
  58. return true
  59. },
  60. tabAction:businessT.action(function (sender) {
  61. businessT.debugLog(sender.currentTarget.id)
  62. if (!this.judgeIsLogin()) {
  63. return
  64. }
  65. this.shouldGetRedDot = true
  66. switch (sender.currentTarget.id) {
  67. case '0': {
  68. wx.navigateTo({
  69. url: 'pages/wait-for-pay/wait-for-pay',
  70. })
  71. break
  72. }
  73. case '1': {
  74. wx.navigateTo({
  75. url: 'pages/salary/salary',
  76. })
  77. break
  78. }
  79. case '2': {
  80. wx.navigateTo({
  81. url: 'pages/pay-price-difference/pay-price-difference',
  82. })
  83. break
  84. }
  85. case '3': {
  86. wx.navigateTo({
  87. url: 'pages/wait-for-do/wait-for-do',
  88. })
  89. break
  90. }
  91. case '4': {
  92. wx.navigateTo({
  93. url: 'pages/my-order/my-order',
  94. })
  95. break
  96. }
  97. }
  98. }),
  99. rowAction:businessT.action(function (sender) {
  100. businessT.debugLog(sender.currentTarget.id)
  101. switch (sender.currentTarget.id) {
  102. case '0': {
  103. if (!this.judgeIsLogin()) {
  104. return
  105. }
  106. wx.navigateTo({
  107. url: '../../public/pages/customer-view/customer-view?type=manager',
  108. })
  109. break
  110. }
  111. case '1': {
  112. if (!this.judgeIsLogin()) {
  113. return
  114. }
  115. wx.navigateTo({
  116. url: '../../public/pages/discount-view/discount-view?type=show',
  117. })
  118. break
  119. }
  120. case '2': {
  121. if (!this.judgeIsLogin()) {
  122. return
  123. }
  124. wx.navigateTo({
  125. url: 'pages/address/address',
  126. })
  127. break
  128. }
  129. case '3': {
  130. this.setData({
  131. showContact: true,
  132. scroll: false
  133. })
  134. break
  135. }
  136. case '4': {
  137. wx.navigateTo({
  138. url: 'pages/about/about',
  139. })
  140. break
  141. }
  142. default: break
  143. }
  144. }),
  145. changeAccountAction: businessT.action(function (sender) {
  146. wx.navigateTo({
  147. url: '../login/index',
  148. })
  149. }),
  150. refreshRedDot: function () {
  151. businessT.debugLog('refreshRedDot')
  152. this.setData({
  153. redDot: app.redDotArray
  154. })
  155. },
  156. broadcastAction: businessT.action(function (sender) {
  157. this.shouldGetRedDot = true
  158. wx.navigateTo({
  159. url: '../../public/pages/edit-bank/edit-bank?i=' + app.bankCardTips.c.id,
  160. })
  161. }),
  162. broadcastAnimation: function (length) {
  163. if (length > (640 + 200) * sysT.rpxToPx()) {
  164. this.setData({
  165. broadcast: this.data.broadcast
  166. })
  167. this.broadcastTextAnimation(length)
  168. }
  169. businessT.debugLog(length)
  170. },
  171. broadcastTextAnimation: function (length) {
  172. this.data.broadcast.n++
  173. var t = length * 17.5
  174. var y = this.data.broadcast.n % 3
  175. businessT.debugLog(y)
  176. switch (y) {
  177. case 1: {
  178. this.data.broadcast.fa = 'transition: transform ' + t + 'ms linear 0ms; transform: translateX(-' + length + 'px); transform-origin: 50% 50% 0px;'
  179. this.data.broadcast.sa = 'transition: transform ' + t + 'ms linear 0ms; transform: translateX(-' + length + 'px); transform-origin: 50% 50% 0px;'
  180. this.data.broadcast.ta = 'transition: transform ' + t + 'ms linear 0ms; transform: translateX(-' + length + 'px); transform-origin: 50% 50% 0px;'
  181. this.data.broadcast.fc = 'n'
  182. this.data.broadcast.sc = 'n'
  183. this.data.broadcast.tc = 'h'
  184. if (this.data.broadcast.n == 1) {
  185. var d = 1000
  186. setTimeout(function () {
  187. this.setData({
  188. broadcast: this.data.broadcast
  189. })
  190. }.bind(this), d)
  191. t = t + d
  192. } else {
  193. this.setData({
  194. broadcast: this.data.broadcast
  195. })
  196. }
  197. break
  198. }
  199. case 2: {
  200. this.data.broadcast.fa = 'transition: transform ' + t + 'ms linear 0ms; transform: translateX(' + length + 'px); transform-origin: 50% 50% 0px;'
  201. this.data.broadcast.sa = 'transition: transform ' + t + 'ms linear 0ms; transform: translateX(-' + (length * 2) + 'px); transform-origin: 50% 50% 0px;'
  202. this.data.broadcast.ta = 'transition: transform ' + t + 'ms linear 0ms; transform: translateX(-' + (length * 2) + 'px); transform-origin: 50% 50% 0px;'
  203. this.data.broadcast.fc = 'h'
  204. this.data.broadcast.sc = 'n'
  205. this.data.broadcast.tc = 'n'
  206. this.setData({
  207. broadcast: this.data.broadcast
  208. })
  209. break
  210. }
  211. case 0: {
  212. this.data.broadcast.fa = 'transition: transform ' + t + 'ms linear 0ms; transform: translateX(0px); transform-origin: 50% 50% 0px;'
  213. this.data.broadcast.sa = 'transition: transform ' + t + 'ms linear 0ms; transform: translateX(0px); transform-origin: 50% 50% 0px;'
  214. this.data.broadcast.ta = 'transition: transform ' + t + 'ms linear 0ms; transform: translateX(-' + (length * 3) + 'px); transform-origin: 50% 50% 0px;'
  215. this.data.broadcast.fc = 'n'
  216. this.data.broadcast.sc = 'h'
  217. this.data.broadcast.tc = 'n'
  218. this.setData({
  219. broadcast: this.data.broadcast
  220. })
  221. break
  222. }
  223. default: break
  224. }
  225. this.broadcastTimeout = setTimeout(function () {
  226. this.broadcastTextAnimation(length)
  227. }.bind(this), t)
  228. },
  229. judgeBroadcast: function () {
  230. if (this.data.broadcast.s) {
  231. var query = wx.createSelectorQuery();
  232. //选择id
  233. query.select('#broadcastText').boundingClientRect()
  234. var that = this;
  235. query.exec(function (res) {
  236. //res就是 该元素的信息 数组
  237. businessT.debugLog(res[0])
  238. that.data.broadcast.n = 0
  239. var singleLength = res[0].width + 200 * sysT.rpxToPx()
  240. that.data.broadcast.w = singleLength * 3
  241. that.broadcastAnimation(singleLength)
  242. })
  243. }
  244. },
  245. refreshBroacast: function (b) {
  246. if (this.broadcastTimeout) {
  247. clearTimeout(this.broadcastTimeout)
  248. }
  249. var broadcast = {
  250. w: 0,
  251. n: 0,
  252. s: true,
  253. b: b,
  254. fa: '',
  255. sa: '',
  256. ta: '',
  257. fc: 'n',
  258. sc: 'h',
  259. tc: 'h'
  260. }
  261. this.setData({
  262. broadcast: broadcast
  263. })
  264. this.judgeBroadcast()
  265. },
  266. hiddenBroadcast: function () {
  267. if (this.broadcastTimeout) {
  268. clearTimeout(this.broadcastTimeout)
  269. }
  270. this.data.broadcast.s = false
  271. this.setData({
  272. broadcast: this.data.broadcast
  273. })
  274. },
  275. deleteBroadcast: businessT.action(function (sender) {
  276. this.hiddenBroadcast()
  277. }),
  278. judgeBankCardTips: function () {
  279. if (app.bankCardTips.t) {
  280. this.refreshBroacast(app.bankCardTips.t)
  281. } else {
  282. this.hiddenBroadcast()
  283. }
  284. },
  285. route: function (path) {
  286. var pages = getCurrentPages()
  287. wx.navigateBack({
  288. delta: pages.length
  289. })
  290. setTimeout(function () {
  291. wx.navigateTo({
  292. url: path,
  293. })
  294. }.bind(this), 500)
  295. },
  296. /**
  297. * 生命周期函数--监听页面加载
  298. */
  299. onLoad: function (options) {
  300. },
  301. /**
  302. * 生命周期函数--监听页面初次渲染完成
  303. */
  304. onReady: function () {
  305. },
  306. /**
  307. * 生命周期函数--监听页面显示
  308. */
  309. onShow: function () {
  310. if (typeof this.getTabBar === 'function' &&
  311. this.getTabBar()) {
  312. this.getTabBar().setData({
  313. redDot: app.tabRedDot,
  314. selected: 2
  315. })
  316. }
  317. this.judgeBankCardTips()
  318. if (this.shouldGetRedDot) {
  319. this.shouldGetRedDot = false
  320. redDot.getRedDot()
  321. } else {
  322. this.refreshRedDot()
  323. }
  324. var isLogin = app.loginStatus.key != ""
  325. if (isLogin != this.data.isLogin) {
  326. this.setData({
  327. isLogin: isLogin
  328. })
  329. }
  330. },
  331. /**
  332. * 生命周期函数--监听页面隐藏
  333. */
  334. onHide: function () {
  335. if (this.broadcastTimeout) {
  336. clearTimeout(this.broadcastTimeout)
  337. }
  338. var broadcast = {
  339. w: this.data.broadcast.w,
  340. n: -100,
  341. s: this.data.broadcast.s,
  342. b: this.data.broadcast.b,
  343. fa: '',
  344. sa: '',
  345. ta: '',
  346. fc: 'n',
  347. sc: 'h',
  348. tc: 'h'
  349. }
  350. this.setData({
  351. broadcast: broadcast
  352. })
  353. },
  354. /**
  355. * 生命周期函数--监听页面卸载
  356. */
  357. onUnload: function () {
  358. },
  359. /**
  360. * 页面相关事件处理函数--监听用户下拉动作
  361. */
  362. onPullDownRefresh: function () {
  363. },
  364. /**
  365. * 页面上拉触底事件的处理函数
  366. */
  367. onReachBottom: function () {
  368. },
  369. /**
  370. * 用户点击右上角分享
  371. */
  372. onShareAppMessage: function () {
  373. return {
  374. path: '/page/home/index',
  375. imageUrl: '../../icon/public/share_img.png',
  376. title: '自助缴社保公积金,覆盖200多个城市,专业团队操作'
  377. }
  378. }
  379. })