uni-cart-fix.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. return this.$store.state.vuex_cartNums
  35. },
  36. },
  37. methods: {
  38. toCart() {
  39. let _this = this
  40. if(_this.closeCurPage){
  41. uni.redirectTo({
  42. url:"/pagesA/cart/cart"
  43. })
  44. }else{
  45. uni.navigateTo({
  46. url:"/pagesA/cart/cart"
  47. })
  48. }
  49. },
  50. btnClick() {
  51. console.log('btnClick');
  52. },
  53. btnTouchstart() {
  54. console.log('btnTouchstart');
  55. },
  56. btnTouchend() {
  57. console.log('btnTouchend');
  58. },
  59. },
  60. }
  61. </script>
  62. <style lang="scss">
  63. .cart-fix{
  64. position: fixed;
  65. z-index: 100000;
  66. // background: rgba($color: #ffffff, $alpha: 0.7);
  67. // padding: 10upx;
  68. // border-radius: 100%;
  69. bottom: 40%;
  70. right: 2%;
  71. // box-shadow: 3upx 3upx 8upx #ccc;
  72. }
  73. </style>