my-add-button.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view>
  3. <view class="p-fixed add" @tap="handleClick">
  4. <image src="/static/images/add.png" mode="widthFix"></image>
  5. </view>
  6. <u-action-sheet v-if="isBatch" @click="click" :list="buttonList" v-model="show"></u-action-sheet>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. props: {
  12. isBatch: {
  13. type: Boolean,
  14. default: false
  15. },
  16. buttonList: {
  17. type: Array,
  18. default: () => [
  19. {
  20. text: '扫码'
  21. },
  22. {
  23. text: '添加'
  24. },
  25. {
  26. text: '批量修改'
  27. },
  28. {
  29. text: '批量复制'
  30. }
  31. ]
  32. }
  33. },
  34. data() {
  35. return {
  36. show: false
  37. };
  38. },
  39. methods: {
  40. handleClick() {
  41. if (this.isBatch) {
  42. this.show = true;
  43. return;
  44. }
  45. this.$emit('handleClick')
  46. },
  47. scanCode() {
  48. uni.scanCode({
  49. success(e) {
  50. console.log(e.result);
  51. if (e.result) {
  52. uni.navigateTo({
  53. url:
  54. '/pages/equipment-detail/equipment-detail?detailId=' +
  55. e.result
  56. });
  57. }
  58. }
  59. });
  60. },
  61. click(index) {
  62. this.$emit('handleClick', this.buttonList[index])
  63. this.show = false
  64. /* console.log(index);
  65. switch (index) {
  66. case 0:
  67. break;
  68. case 1:
  69. this.$emit('handleClick');
  70. break;
  71. case 2:
  72. uni.navigateTo({
  73. url: '/pages/running/ceshi'
  74. });
  75. break;
  76. } */
  77. }
  78. }
  79. };
  80. </script>
  81. <style lang="less" scoped>
  82. .add {
  83. right: 50rpx;
  84. bottom: 170rpx;
  85. z-index: 10000;
  86. width: 128rpx;
  87. height: 128rpx;
  88. background-color: #fff;
  89. border-radius: 50%;
  90. display: flex;
  91. justify-content: center;
  92. align-items: center;
  93. image {
  94. width: 128rpx;
  95. height: 128rpx;
  96. }
  97. }
  98. </style>