官方链接:https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.setTabBarBadge.html
通过调用wx.setTabBarBadge(Object object)来实现。
假如购物车的tabBar是第三个,所以他的索引是:2.,即index=2
只要点击添加购物车则调用
wx.setTabBarBadge({
index: 2,
text: '1'
})
其中 text 显示购物车中商品数量。