<template>
    <view class="container">
        <view class="searchBox" :style="{ height: localHeight + 'px', paddingTop: top + 'px' }">
            <view class="searchBox_add">
                <view class="emptyCommunity" @click="addCommunity">
                    {{ communityVal }}
                </view>
            </view>
        </view>
        <!-- 背景图片区域 -->
        <view class="bg-image-container">
            <image class="bg-image" src="http://localhost:8080/test.png" mode="aspectFill"></image>
          <!-- <input class="search-box" placeholder='输入工单号进入工单' confirm-type='search' @input="searchInput"
            @confirm="searchInput" :value="selectKeyWord" /> -->
            <view class="search-box">
                <text class="search-placeholder">输入工单号进入工单</text>
            </view>
        </view>
        <view class="work-order-section">
            <view v-for="(item, index) in 9" :key="index">
                <view class="work-order-card" v-if="index == 0 && showWorkOrderSection"
                    @click="navigateToWorkOrderDashboard">
                    <image class="work-order-icon" src="http://localhost:8080/workOrder.png" mode="aspectFill" />
                    <text class="work-order-text">工单台</text>
                </view>
                <view class="work-order-card" v-else></view>
            </view>
        </view>
    </view>
</template>

<script>
import {
  request,
  picUrl,
  uniqueByField,
  menuButtonInfo,
  NavgateTo,
} from "../../../utils";

import { apiArr } from "../../../api/community";

export default {
    data() {
        return {
            communityVal: "添加我的房产",
            showWorkOrderSection: false
        }
    },
    onLoad() {
        const workOrderPermission = uni.getStorageSync('work_order_permission');
        const orderDispatchPermission = uni.getStorageSync('order_dispatch_permission');
        this.showWorkOrderSection = !(workOrderPermission === false && orderDispatchPermission === false);
    },
    async onShow(){
        this.communityVal = uni.getStorageSync('changeCommData').name;
        const params = {
            community_id: uni.getStorageSync('changeCommData').id,
        }
        const res = await request(apiArr.communityInfo, "POST", params);
        uni.setStorageSync('allow_grab_order', res.allow_grab_order == 1 ? true : false);
    },
    methods: {
        addCommunity() {
            NavgateTo("/packages/community/myCommunity/index");
        },

        // 跳转到工单台
        navigateToWorkOrderDashboard() {
            uni.navigateTo({
                url: '/packages/workOrderDashboard/index/index'
            });
        }
    }
}
</script>

<style scoped>
/* 引入外部CSS文件 */
@import url("./index.css");
</style>