x-bluetooth.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <view>
  3. <view class="card_item_tooth" v-for="(item,index) in list" :key="index">
  4. <view class="card_wifi">
  5. <u-icon name="wifi" color="#2979ff" size="26"></u-icon>
  6. <view class="wifi_item_title">{{item.name}}</view>
  7. </view>
  8. <view style="display: flex;align-items: center;">
  9. <u-button style="margin-right: 10px;" size="small" type="warning" text="重连"
  10. @click="reconnection(item)" v-if="reconnectionFlag"></u-button>
  11. <u-button size="small" :type="btnType" :text="text" @click="connect(item)"></u-button>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. export default {
  18. name: 'x-bluetooth',
  19. props: {
  20. list: {
  21. type: Array,
  22. default () {
  23. return []
  24. }
  25. },
  26. text: {
  27. type: String,
  28. default () {
  29. return '连接'
  30. }
  31. },
  32. btnType: {
  33. type: String,
  34. default () {
  35. return 'primary'
  36. }
  37. },
  38. // 重新连接显示
  39. reconnectionFlag: {
  40. type: Boolean,
  41. default () {
  42. return false
  43. }
  44. }
  45. },
  46. data() {
  47. return {}
  48. },
  49. mounted() {},
  50. methods: {
  51. connect(value) {
  52. this.$emit('connect', value)
  53. },
  54. reconnection(event) {
  55. this.$emit('reconnection',event)
  56. }
  57. }
  58. }
  59. </script>
  60. <style lang="scss" scoped>
  61. .card_item_tooth {
  62. padding: 20rpx 0rpx;
  63. display: flex;
  64. justify-content: space-between;
  65. align-items: center;
  66. }
  67. .card_wifi {
  68. display: flex;
  69. align-items: center;
  70. }
  71. .wifi_item_title {
  72. font-size: 28rpx;
  73. margin-left: 16rpx;
  74. }
  75. </style>