index.js 4.0 KB

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