MarkStore.vue 3.47 KB
<template>
  <view class="inspection">
    <view class="store-search">
      <!-- #ifdef MP-WEIXIN -->
      <uv-input :placeholder="t('app.common.search')" prefixIcon="search" prefixIconStyle="font-size: 46rpx;color: #333333" border="none"
        placeholderStyle="color:#90949D;font-size:26rpx" clearable
        style="background-color: #fff;height: 68rpx;flex: none;margin-top: 16rpx;padding: 0 24rpx;"
        @input="handleSearch" v-model="searchVal"></uv-input>
        <uv-icon name="reload" @tap="getMallList"></uv-icon>
      <!-- #endif -->
      <!-- #ifndef MP-WEIXIN-->
      <uv-input :placeholder="t('app.common.search')" prefixIcon="search" prefixIconStyle="font-size: 46rpx;color: #333333" border="none"
        placeholderStyle="color:#90949D;font-size:26rpx" clearable
        style="background-color: #fff;height: 68rpx;flex: none;margin-top: 16rpx;padding: 0 24rpx;"
        @input="handleSearch" v-model="searchVal"></uv-input>
      <!-- #endif -->
      
    </view>
    <view class="store-list" v-if="showMallList.length > 0">
      <StoreItem v-for="sItem in showMallList" :key="sItem.id" :item="sItem"
        :options="{label:'name',children:'patrolGates'}" style="margin-bottom: 16rpx;"></StoreItem>
    </view>
    <view class="p-empty" v-else style="margin-top: 280rpx;">
      <image class="p-empty-img" v-if="!searchVal" src="/static/common/empty.png" mode=""></image>
      <image class="p-empty-img" v-else src="/static/common/no-result.png" mode=""></image>
      <text class="p-empty-text">{{ searchVal?t('app.common.noFilterData'):t('maintenance.monitor.project.empty.text') }}</text>
    </view>
  </view>
</template>
<script setup>
  import {
    computed,
    onMounted,
    ref
  } from 'vue';
  import {
    onLoad,
    onPullDownRefresh
  } from '@dcloudio/uni-app';
  import {
    getPatrolGateMarkMallsApi
  } from '@/api';
  import {
    getStageObj
  } from '@/utils'
  import StoreItem from './components/StoreItem.vue'
  import {
    t
  } from '@/plugins/index.js'

  const searchVal = ref('')
  onMounted(() => {
    getMallList()
  })
  const mallList = ref([])

  function getMallList() {
    uni.showLoading({
      title:'加载中'
    })
    const accountId = getStageObj('account')?.id
    // const userId = getStageObj('user')?.id
    if (accountId) {
      const params = {
        accountId,
        bookmark:true
      }
      getPatrolGateMarkMallsApi(params).then(res => {
        if (res.code === 200) {
          mallList.value = res.data || []
        }
      }).finally(()=>{
        uni.hideLoading()
      })
    }
  }

  // 搜索功能
  const keyword = ref('')

  function handleSearch(value) {
    keyword.value = value
  }
  const showMallList = computed(() => {
    if (keyword.value) {
      return mallList.value.filter(item => {
        if (item.name.includes(keyword.value)) {
          return true
        } else {
          return false
        }
      })
    } else {
      return mallList.value
    }
  })

  onLoad((options) => {
    getMallList()
  })
</script>

<style lang="scss">
  .inspection {
    .store-search {
      position: sticky;
      left: 0;
      top: 0;
      width: 750rpx;
      height: 100rpx;
      background-color: #f2f3f6;
      z-index: 100;
      padding: 0 20rpx;
      /* #ifdef MP-WEIXIN */
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: space-between
      /* #endif */

    }

    .i-content {
      padding: 0 20rpx;
    }

  }

  .store-list {
    padding: 0 20rpx;
  }
</style>