App.vue 676 B

1234567891011121314151617181920212223242526272829303132333435
  1. <script>
  2. export default {
  3. onLaunch: function () {
  4. console.log('App Launch')
  5. },
  6. onShow: function () {
  7. console.log('App Show')
  8. if (this.vuex_token) {
  9. this.findCartList()
  10. }
  11. },
  12. onHide: function () {
  13. console.log('App Hide')
  14. },
  15. methods: {
  16. // 设置购物车badge
  17. findCartList() {
  18. let badge = this.vuex_cartList.length
  19. // 设置tab badge
  20. if (badge > 0) {
  21. uni.setTabBarBadge({ //显示数字
  22. index: 2,
  23. text: '' + badge + ''
  24. })
  25. }
  26. },
  27. }
  28. }
  29. </script>
  30. <style lang="scss">
  31. @import "uview-ui/index.scss";
  32. /*每个页面公共css */
  33. @import url("./common/common.css");
  34. </style>