tools.js 617 B

1234567891011121314151617181920212223242526272829303132
  1. const WXAPI = require('apifm-wxapi')
  2. // 显示购物车tabBar的Badge
  3. function showTabBarBadge(){
  4. const token = wx.getStorageSync('token')
  5. if (!token) {
  6. return
  7. }
  8. WXAPI.shippingCarInfo(token).then(res => {
  9. if (res.code == 700) {
  10. wx.removeTabBarBadge({
  11. index: 3
  12. });
  13. }
  14. if (res.code == 0) {
  15. if (res.data.number == 0) {
  16. wx.removeTabBarBadge({
  17. index: 3
  18. });
  19. } else {
  20. wx.setTabBarBadge({
  21. index: 3,
  22. text: `${res.data.number}`
  23. });
  24. }
  25. }
  26. })
  27. }
  28. module.exports = {
  29. showTabBarBadge: showTabBarBadge
  30. }