uni-cart-fix.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. if(_this.closeCurPage){
  46. uni.redirectTo({
  47. url:"/pages/cart/cart"
  48. })
  49. }else{
  50. uni.navigateTo({
  51. url:"/pages/cart/cart"
  52. })
  53. }
  54. },
  55. btnClick() {
  56. console.log('btnClick');
  57. },
  58. btnTouchstart() {
  59. console.log('btnTouchstart');
  60. },
  61. btnTouchend() {
  62. console.log('btnTouchend');
  63. },
  64. },
  65. }
  66. </script>
  67. <style lang="scss">
  68. .cart-fix{
  69. position: fixed;
  70. z-index: 100000;
  71. // background: rgba($color: #ffffff, $alpha: 0.7);
  72. // padding: 10upx;
  73. // border-radius: 100%;
  74. bottom: 40%;
  75. right: 2%;
  76. // box-shadow: 3upx 3upx 8upx #ccc;
  77. }
  78. </style>