uni-cart-fix.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <view class="cart-fix" @click="toCart">
  3. <!-- <u-image width="70rpx" height="70rpx" src="/static/cart.png"></u-image>
  4. <u-badge absolute :offset="[15,10]" type="error" :count="count"></u-badge> -->
  5. <drag-button
  6. :isDock="true"
  7. :existTabBar="true"
  8. :dragPic="dragPic"
  9. :badge="count"
  10. @btnClick="toCart"
  11. @btnTouchstart="btnTouchstart"
  12. @btnTouchend="btnTouchend"
  13. />
  14. </view>
  15. </template>
  16. <script>
  17. import dragButton from "@/components/drag-button/drag-button.vue";
  18. export default {
  19. components: {
  20. dragButton
  21. },
  22. props:{
  23. closeCurPage:{
  24. type: Boolean,
  25. default: false
  26. },
  27. dragPic: {
  28. type: String,
  29. default: ''
  30. }
  31. },
  32. computed: {
  33. count() {
  34. let arr = this.$store.state.vuex_cartList || []
  35. let count = 0
  36. arr.map(item=>{
  37. count = count + item.shoppingCartGoodsList.length
  38. })
  39. return count
  40. },
  41. },
  42. methods: {
  43. toCart() {
  44. let _this = this
  45. this.$bindClick(function(){
  46. if(_this.closeCurPage){
  47. uni.redirectTo({
  48. url:"/pages/cart/cart"
  49. })
  50. }else{
  51. uni.navigateTo({
  52. url:"/pages/cart/cart"
  53. })
  54. }
  55. })
  56. },
  57. btnClick() {
  58. console.log('btnClick');
  59. },
  60. btnTouchstart() {
  61. console.log('btnTouchstart');
  62. },
  63. btnTouchend() {
  64. console.log('btnTouchend');
  65. },
  66. },
  67. }
  68. </script>
  69. <style lang="scss">
  70. .cart-fix{
  71. position: fixed;
  72. z-index: 100000;
  73. // background: rgba($color: #ffffff, $alpha: 0.7);
  74. // padding: 10upx;
  75. // border-radius: 100%;
  76. bottom: 40%;
  77. right: 2%;
  78. // box-shadow: 3upx 3upx 8upx #ccc;
  79. }
  80. </style>