index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import {
  2. ApiModel
  3. } from "../utils/api";
  4. const _Http = new ApiModel();
  5. Component({
  6. /**
  7. * 组件的属性列表
  8. */
  9. properties: {},
  10. lifetimes: {
  11. attached() {},
  12. ready: function () {
  13. // 在组件实例进入页面节点树时执行
  14. },
  15. },
  16. /**
  17. * 组件的初始数据
  18. */
  19. data: {
  20. active: 0,
  21. tabbarList: [{
  22. icon: '/static/tabbar-icon/home.png',
  23. iconA: '/static/tabbar-icon/home-a.png',
  24. text: '首页',
  25. url: '/pages/tabbar-pages/home/index'
  26. },
  27. {
  28. icon: '/static/tabbar-icon/service.png',
  29. iconA: '/static/tabbar-icon/service-a.png',
  30. text: '在线客服',
  31. url: '/pages/tabbar-pages/customer-service-staff/index'
  32. },
  33. {
  34. icon: '/static/tabbar-icon/bazaar.png',
  35. iconA: '/static/tabbar-icon/bazaar-a.png',
  36. text: '供需广场',
  37. url: '/pages/tabbar-pages/supplyAndDemand/index'
  38. },
  39. {
  40. icon: '/static/tabbar-icon/message.png',
  41. iconA: '/static/tabbar-icon/message-a.png',
  42. text: '消息',
  43. url: '/pages/tabbar-pages/message/index',
  44. fcount: '0'
  45. },
  46. {
  47. icon: '/static/tabbar-icon/user.png',
  48. iconA: '/static/tabbar-icon/user-a.png',
  49. text: '我的',
  50. url: '/pages/tabbar-pages/user/index'
  51. }
  52. ],
  53. show: false,
  54. phoneNumber: '',
  55. },
  56. /**
  57. * 组件的方法列表
  58. */
  59. methods: {
  60. /* tabbar */
  61. onChange(event) {
  62. if (this.data.phoneNumber == '') this.setData({
  63. phoneNumber: getApp().globalData.servicehotline
  64. });
  65. if (event.target.dataset.index == 1) return this.setData({
  66. show: true
  67. })
  68. this.setData({
  69. active: event.target.dataset.index
  70. });
  71. wx.switchTab({
  72. url: this.data.tabbarList[event.target.dataset.index].url
  73. });
  74. },
  75. init() {
  76. const page = getCurrentPages().pop();
  77. this.setData({
  78. active: this.data.tabbarList.findIndex(item => item.url === `/${page.route}`)
  79. });
  80. },
  81. /* 呼叫电话 */
  82. CallOut() {
  83. wx.makePhoneCall({
  84. phoneNumber: getApp().globalData.servicehotline
  85. }).catch((e) => {})
  86. },
  87. onClose() {
  88. this.setData({
  89. show: false
  90. })
  91. },
  92. /* 获取未阅读消息数量查询 */
  93. unReadMessageCount() {
  94. _Http.basic({
  95. "accesstoken": wx.getStorageSync('userData').token,
  96. "classname": "system.message.Message",
  97. "method": "unReadMessageCount",
  98. "content": {}
  99. }).then(res => {
  100. if (res.msg != '成功') console.log('未读消息数量查询失败')
  101. const fcount = (res.data[0].fcount == 0) ? '' : res.data[0].fcount;
  102. getApp().globalData.msgFcount = fcount;
  103. })
  104. }
  105. },
  106. })