<template>
  <!-- 今日做糖列表 -->
  <div class="page flex-col">
    <s-header :name="$t('device.todaysSugarList')" :noback="false"></s-header>
    <div class="listBox">
        <div v-for="(item, index) in list" :key="index">
        {{item}}
        </div>
    </div>
    <nav-bar></nav-bar>
  </div>
</template>
<script>
import { onMounted, ref } from 'vue';
import navBar from '@/components/NavBar';
import sHeader from "@/components/SimpleHeader";
import { selectSugarStatus } from '@/service/device'
import { Toast } from 'vant';
import { getLoginUser } from '@/common/js/utils';

export default {
  setup() {
    const user = getLoginUser();
    const list = ref([]);
    // 初始化页面获取列表
    onMounted(async () => {
        selectSugarStatusFun();
    });

     // 获取设备列表数据
    const selectSugarStatusFun = async () => {
        console.log(user);
      const { data } = await selectSugarStatus({adminId : user.id});
      if (data.code) {
        list.value = data.data.map(item => {
          return item.productName
        });
      } else { Toast.fail(data.message); }
    }
 
    return { list };
  },
  components: { sHeader, navBar },
};
</script>
<style lang="less" scoped>
@import "../../common/style/common";
.listBox {
    font-size: 12px;
    line-height: 2;
    text-align: center;
}
</style>
