You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
441 B

3 years ago
  1. export default{
  2. computed: {
  3. cartCount(){
  4. return this.$store.state.cartCount;
  5. }
  6. },
  7. watch: {
  8. cartCount(count){
  9. this.resetTabCartCount();
  10. }
  11. },
  12. onShow(){
  13. this.resetTabCartCount();
  14. },
  15. methods: {
  16. resetTabCartCount(){
  17. if(this.cartCount > 0){
  18. uni.setTabBarBadge({
  19. index: 2,
  20. text: '' + this.cartCount
  21. })
  22. }else{
  23. uni.removeTabBarBadge({
  24. index: 2
  25. })
  26. }
  27. }
  28. }
  29. }