<template>
  <view class="content">
    <button @click="addDevice" class="btn" hover-class="btn-hover">添加设备</button>
    <device-item
      v-for="(device, index) in deviceList"
      :key="index"
      :device="device"
      @onclick="goDeviceInfo(device)"
    ></device-item>

  </view>
</template>

<script>
import deviceItem from "../../components/device-manager/deviceItem/deviceItem.vue";
export default {
  components: { deviceItem },
  data() {
    return {
      title: "Hello",
    };
  },
  onLoad() {},
  methods: {
    addDevice() {
      //添加设备
      // this.$store.dispatch({
      // 	type: "moduleMqtt/addDevice",
      // 	clientId: `wx_${getApp().globalData.uid}`,
      // 	device: {
      // 		devName: "猫王。野力MAX",
      // 		uuid: "89860474192070498495",
      //     ProdModel:"MW-V"
      // 	},
      // });

      uni.navigateTo({
        url: "../addDevice/selectDevice/selectDevice",
      });
    },
    goDeviceInfo(device) {
      console.log("goDeviceInfo");
      uni.navigateTo({
        url: `../mine/device/deviceDetail/deviceDetail?model=${device.ProdModel}&name=${device.devName}&uuid=${device.uuid}`,
        complete(res) {
          console.warn(res);
        },
      });
    },
  },
  computed: {
    deviceList() {
      return this.$store.state.moduleMqtt.deviceList;
    },
  },
};
</script>

<style>
.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}



</style>
