red-dot.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. var url = require('../constant/url.js')
  2. import Net from './../tool/net.js'
  3. var net = new Net()
  4. var app = getApp()
  5. function getRedDot() {
  6. net.connectNeedLogin({
  7. url: url.app_host + url.getPersonalPageCount,
  8. data: {},
  9. success: (err, res) => {
  10. var all = 0
  11. if (res.data.buy > 99) {
  12. app.redDotArray[0] = '99+'
  13. } else {
  14. app.redDotArray[0] = String(res.data.buy)
  15. }
  16. all += res.data.buy
  17. if (res.data.wage > 99) {
  18. app.redDotArray[1] = '99+'
  19. } else {
  20. app.redDotArray[1] = String(res.data.wage)
  21. }
  22. all += res.data.wage
  23. if (res.data.added > 99) {
  24. app.redDotArray[2] = '99+'
  25. } else {
  26. app.redDotArray[2] = String(res.data.added)
  27. }
  28. all += res.data.added
  29. if (res.data.material_flow > 99) {
  30. app.redDotArray[3] = '99+'
  31. } else {
  32. app.redDotArray[3] = String(res.data.material_flow)
  33. }
  34. all += res.data.material_flow
  35. var pages = getCurrentPages()
  36. var page = pages[0]
  37. if (typeof page.refreshRedDot === 'function') {
  38. page.refreshRedDot()
  39. }
  40. if (all > 99) {
  41. all = '99+'
  42. } else {
  43. all = String(all)
  44. }
  45. app.tabRedDot = all
  46. if (typeof page.getTabBar === 'function' &&
  47. page.getTabBar()) {
  48. page.getTabBar().setData({
  49. redDot: all
  50. })
  51. }
  52. app.bankCardTips = {}
  53. outer:
  54. for (var i = 0; i < res.data.sbuids.length; i++) {
  55. var id = res.data.sbuids[i]
  56. for (var j = 0; j < app.globalData.customerList.length; j++) {
  57. var customer = app.globalData.customerList[j]
  58. if (id == customer.id) {
  59. app.bankCardTips = {
  60. 't': '请添加 ' + customer.user_name + ' 的银行卡,否则会影响流水费返还。',
  61. 'c': customer
  62. }
  63. break outer
  64. }
  65. }
  66. }
  67. if (typeof page.judgeBankCardTips === 'function') {
  68. page.judgeBankCardTips()
  69. }
  70. },
  71. fail: (err, res) => {
  72. }
  73. }, true)
  74. }
  75. module.exports = {
  76. getRedDot: getRedDot,
  77. }