<template>
  <view class="container">
    <z-paging ref="paging" v-model="dataList" @query="queryList" :auto="false" >

      <view class="ul fs-p20">
        <view class="li fs-bg__white fs-p30 fs-size__h4 fs-radius__sm fs-mt20" v-for="(item, index) in dataList">
          <view @click="toDetails(item.planNo)">
            <view class="fs-flex__between">
              <view class="fs-weight__bold fs-flex1 fs-ellipsis">{{item.planName}}</view>
              <tui-text v-if="item.planStatus" text="已完成" type="success"></tui-text>
              <tui-text v-else text="未完成" type="danger"></tui-text>
            </view>
            <view class="fs-flex fs-mt20">
              <view class="fs-flex1">编码：{{item.hotlinenumber}}</view>
              <view class="fs-flex1">周期：{{item.levelValue}}{{item.cycleName}}</view>
            </view>
            <view class="fs-flex fs-mt20">
              <view class="fs-flex1">养护类型：{{item.maintainTypeName}}</view>
              <view class="fs-flex1">养护等级：{{item.curingLevelName}}</view>
            </view>
            <view class="fs-flex__between fs-mt20">
              <view class="fs-flex1">计划次数：{{item.planNum}}</view>
              <view class="fs-flex1">完成次数：{{item.planFinishNum}}</view>
            </view>
          </view>

        </view>
      </view>
    </z-paging>
  </view>
</template>

<script>
// const QQMapWX = require('./utils/qqmap-wx-jssdk.js')
// 实例化API核心类
// let qqMap = new QQMapWX({
//   key: 'H77BZ-RVOKL-UOXPH-EXMFC-5XSGT-YDFIC'
// });
import { hotlinecaseList } from '@/api/work'
import { useCounterStore } from '@/stores/counter'
export default {
  data() {
    return {
      dataList: [],
      qqmapsdk:null
    }
  },
  onLoad() {
    // this.qqmapsdk = new QQMapWX({
    //   key: 'H77BZ-RVOKL-UOXPH-EXMFC-5XSGT-YDFIC'
    // })
  },
  onShow(){
    if (this.$refs.paging) {
      this.$refs.paging.refresh() // 重置到第一页并触发query事件
    }
    const address = '北京市海淀区中关村大街'

    // this.qqmapsdk.geocoder({
    //   address: address,
    //   success: (res) => {
    //     if (res.status === 0) {
    //       this.location = res.result.location
    //       console.log('解析成功：', res.result.location)
    //     } else {
    //       console.error('解析失败：', res.message)
    //     }
    //   },
    //   fail: (err) => {
    //     console.error('接口调用失败：', err)
    //   }
    // })

  },
  methods: {
    // 获取巡检列表
    queryList() {
      const useCounter = useCounterStore()
      console.log(useCounter.userInfo.userId)
      const params = {
        dispperson:useCounter.userInfo.userId,
        taskstate:'gdtype02'
      }
      hotlinecaseList({data:params}).then(res => {
        this.$refs.paging.complete(res.rows)
      })
    },

    // 跳转详情
    toDetails(planno) {
      uni.$tui.href(`/pages/work/daily/inspection/details?planno=${planno}`)
    },
    // 跳转记录
    toRecord(planno) {
      uni.$tui.href(`/pages/work/daily/inspection/record?planno=${planno}`)
    }
  }
}
</script>

<style lang="scss" scoped>
.ul .li:first-child {
  margin-top: 0;
}
</style>
