对接小区、故障报修接口,更换图片地址
@@ -17,4 +17,31 @@ export const getLoginBySms = (data) =>{
|
||||
export const getResetPassword = (data) =>{
|
||||
return post('/api/butler/auth/forgetPassword',data)
|
||||
}
|
||||
// ======首页=====
|
||||
// 获取小区列表
|
||||
export const getVillageList = (data) =>{
|
||||
return get('/api/inspection/today/villageList',data)
|
||||
}
|
||||
// 切换小区
|
||||
export const switchVillage = (data) =>{
|
||||
return post('/api/inspection/today/switchVillage',data)
|
||||
}
|
||||
// ======故障上报=====
|
||||
// 获取报修项目
|
||||
export const getRepairOrder = () =>{
|
||||
return get('/manage/repair/order/list')
|
||||
}
|
||||
// 提交维修信息
|
||||
export const addRepairList = (data) =>{
|
||||
return post('/manage/repair/order',data)
|
||||
}
|
||||
// 上传图片
|
||||
export const uploadFile = (filePath) => {
|
||||
return upload(filePath,' /resource/oss/upload');
|
||||
}
|
||||
|
||||
|
||||
// 一键开门
|
||||
export const openDoor = (data) =>{
|
||||
return post('/manage/remote/open',data)
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
|
||||
let baseUrl = '';
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
baseUrl = 'http://192.168.0.239:8080'; // 开发环境
|
||||
} else {
|
||||
baseUrl = 'http://192.168.1.224:8080'; // 生产环境
|
||||
baseUrl = 'http://192.168.0.224:8080'; // 生产环境
|
||||
}
|
||||
|
||||
export default function request(url, data = {}, method = "GET") {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 加载中提示(提升用户体验)
|
||||
uni.showLoading({ title: '请求中...', mask: true });
|
||||
uni.showLoading({
|
||||
title: '请求中...',
|
||||
mask: true
|
||||
});
|
||||
|
||||
uni.request({
|
||||
url: baseUrl + url,
|
||||
@@ -17,65 +18,75 @@ export default function request(url, data = {}, method = "GET") {
|
||||
method: method,
|
||||
header: {
|
||||
"Authorization": "Bearer " + (uni.getStorageSync("token") || ''),
|
||||
"clientid": "resident",
|
||||
"clientid": "butler",
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
// header: {
|
||||
// "token": uni.getStorageSync("token") || '',
|
||||
// 'content-type': 'application/json'
|
||||
// },
|
||||
success: (res) => {
|
||||
uni.hideLoading(); // 关闭加载提示
|
||||
uni.hideLoading();
|
||||
|
||||
// 处理HTTP状态码(网络层面)
|
||||
// HTTP 失败
|
||||
if (res.statusCode !== 200) {
|
||||
const errMsg = `请求失败(${res.statusCode})`;
|
||||
uni.showToast({ title: errMsg, icon: "none", duration: 2000 });
|
||||
reject(errMsg);
|
||||
reject({ msg: `请求异常 ${res.statusCode}`, code: res.statusCode });
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理业务状态码(后端返回的data里)
|
||||
const resData = res.data || {}; // 兼容后端返回空的情况
|
||||
const resData = res.data || {};
|
||||
|
||||
// 优先处理token过期(401)
|
||||
// token 过期
|
||||
if (resData.code === 401) {
|
||||
uni.showToast({ title: '登录过期,请重新登录', icon: 'none', duration: 2000 });
|
||||
uni.showToast({ title: '登录过期,请重新登录', icon: 'none' });
|
||||
uni.clearStorageSync('token');
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({ url: '/pageSubPack/loginSub/pwd-login' });
|
||||
}, 1500);
|
||||
reject('token 过期');
|
||||
reject({ msg: '登录过期', code: 401 });
|
||||
return;
|
||||
}
|
||||
|
||||
// 业务成功(code=200)
|
||||
// 成功
|
||||
if (resData.code === 200) {
|
||||
resolve(resData); // 只返回核心数据,简化页面调用
|
||||
}
|
||||
// 业务失败(code=500)
|
||||
else if (resData.code === 500) {
|
||||
const errMsg = resData.msg || '请求失败';
|
||||
uni.showToast({ title: errMsg, icon: "none", duration: 2000 });
|
||||
// resolve(null)
|
||||
reject(errMsg);
|
||||
resolve(resData);
|
||||
}
|
||||
// 业务失败
|
||||
else {
|
||||
const errMsg = resData.msg || '业务异常';
|
||||
uni.showToast({ title: errMsg, icon: "none", duration: 2000 });
|
||||
reject(errMsg);
|
||||
reject({ msg: resData.msg || '请求失败', code: resData.code, data: resData });
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
uni.hideLoading(); // 关闭加载提示
|
||||
const errMsg = err.msg || '网络请求失败';
|
||||
uni.showToast({ title: errMsg, icon: "none", duration: 2000 });
|
||||
reject(err);
|
||||
uni.hideLoading();
|
||||
reject({ msg: '网络异常', code: -1, raw: err });
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export const get = (url, data) => request(url, data, 'GET');
|
||||
export const post = (url, data) => request(url, data, 'POST');
|
||||
// export const deleteMethod = (url, data) => request(url, data, 'DELETE');
|
||||
// export const putMethod = (url, data) => request(url, data, 'PUT');
|
||||
|
||||
|
||||
// 上传
|
||||
export const upload = (filePath, url) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.uploadFile({
|
||||
url: baseUrl + url,
|
||||
filePath: filePath,
|
||||
name: 'file',
|
||||
header: {
|
||||
"Authorization": "Bearer " + (uni.getStorageSync("token") || ''),
|
||||
"clientid": "resident"
|
||||
},
|
||||
success: (res) => {
|
||||
try {
|
||||
const data = JSON.parse(res.data);
|
||||
resolve(data.data || ''); // 直接返回图片地址
|
||||
} catch (e) {
|
||||
resolve('');
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
<view class="upload-item" v-for="(img, index) in form.images" :key="index">
|
||||
<image :src="img" mode="aspectFill" class="upload-img"></image>
|
||||
<image
|
||||
src="/static/imgs/delete.png"
|
||||
src="http://47.104.199.163:9090/images/imgs/delete.png"
|
||||
class="upload-delete"
|
||||
@click="deleteImage(index)"
|
||||
></image>
|
||||
@@ -75,10 +75,12 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
// import { onLoad, uniShowToast, uniNavigateBack, uniChooseImage, uniUploadFile } from '@dcloudio/uni-app'
|
||||
import {addRepairList,uploadFile} from '../../api/api.js'
|
||||
|
||||
|
||||
// 接收上个页面传的维修项目
|
||||
const repairProject = ref('')
|
||||
const repairId = ref('')
|
||||
|
||||
// 表单数据
|
||||
const form = ref({
|
||||
@@ -88,11 +90,15 @@ const form = ref({
|
||||
images: [] // 图片列表
|
||||
})
|
||||
|
||||
|
||||
// ==========方法========
|
||||
// 页面加载时获取传参
|
||||
onLoad(options => {
|
||||
if (options.category && options.project) {
|
||||
repairProject.value = `${options.category}-${options.project}`
|
||||
repairId.value = options.projectId
|
||||
}
|
||||
console.log('项目id',repairId.value)
|
||||
})
|
||||
|
||||
// 选择项目页
|
||||
@@ -124,14 +130,35 @@ const chooseImage = () => {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 上传图片
|
||||
const uploadImages = async () => {
|
||||
const uploadedUrls = []
|
||||
for (const path of form.value.images) {
|
||||
if (path.startsWith('http')) {
|
||||
uploadedUrls.push(path)
|
||||
continue
|
||||
}
|
||||
try {
|
||||
const res = await uploadFile(path)
|
||||
// 根据后端实际返回结构调整字段名
|
||||
uploadedUrls.push(res.url || '')
|
||||
} catch (err) {
|
||||
uni.showToast({
|
||||
title:e.msg || '图片上传失败',
|
||||
icon:'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
return uploadedUrls
|
||||
}
|
||||
// 删除图片
|
||||
const deleteImage = index => {
|
||||
form.value.images.splice(index, 1)
|
||||
}
|
||||
|
||||
|
||||
// 表单提交
|
||||
const submitForm = () => {
|
||||
const submitForm = async () => {
|
||||
// 表单校验
|
||||
if (!repairProject.value) {
|
||||
uni.showToast({ title: '请选择维修项目', icon: 'none' })
|
||||
@@ -149,20 +176,41 @@ const submitForm = () => {
|
||||
uni.showToast({ title: '请输入正确的手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
// 提交数据
|
||||
uni.showLoading({ title: '提交中...' ,})
|
||||
try {
|
||||
// 先上传图片
|
||||
const imageUrls = await uploadImages()
|
||||
|
||||
// 提交数据(替换成你的接口)
|
||||
uni.showLoading({ title: '提交中...' })
|
||||
const params = {
|
||||
maintenanceItemId:repairId.value,
|
||||
item: form.value.title,
|
||||
problem: form.value.desc,
|
||||
phone: form.value.phone,
|
||||
problemImageUrl: imageUrls.join(','),
|
||||
// projectType: '0',
|
||||
problemStatus:'0'
|
||||
}
|
||||
|
||||
// 模拟接口请求
|
||||
setTimeout(() => {
|
||||
uni.hideLoading()
|
||||
const res = await addRepairList(params)
|
||||
if (res.code === 200) {
|
||||
uni.showToast({ title: '提交成功', icon: 'success' })
|
||||
|
||||
// 提交成功后重置表单/返回上一页
|
||||
form.value = { title: '', desc: '', phone: '', images: [] }
|
||||
// 或返回上一页
|
||||
uni.navigateBack({ delta: 3 })
|
||||
}, 1000)
|
||||
repairProject.value = ''
|
||||
// uni.navigateBack({ delta: 2 })
|
||||
setTimeout(() => {
|
||||
uni.switchTab({ url: '/pages/index/index' })
|
||||
}, 1500)
|
||||
} else {
|
||||
uni.showToast({ title: res.msg || '提交失败', icon: 'none' })
|
||||
}
|
||||
} catch (e) {
|
||||
uni.showToast({ title: e.msg || '网络异常', icon: 'none' })
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
v-for="item in categoryList"
|
||||
:key="item.id"
|
||||
>
|
||||
{{ item.name }}
|
||||
{{ item.projectName }}
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
v-for="item in currentProjectList"
|
||||
:key="item.id"
|
||||
>
|
||||
{{ item.name }}
|
||||
{{ item.projectName }}
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
@@ -38,20 +38,21 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
// import { uniNavigateTo } from '@dcloudio/uni-app'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import {getRepairOrder} from '../../api/api.js'
|
||||
|
||||
// 分类列表
|
||||
const categoryList = ref([
|
||||
{ id: 1, name: '基础设施' },
|
||||
{ id: 2, name: '电子设施' }
|
||||
// { id: 1, name: '基础设施' },
|
||||
// { id: 2, name: '电子设施' }
|
||||
])
|
||||
|
||||
// 所有项目数据
|
||||
const projectList = ref([
|
||||
{ id: 101, categoryId: 1, name: '路灯' },
|
||||
{ id: 102, categoryId: 1, name: '楼层指示灯' },
|
||||
{ id: 103, categoryId: 2, name: '应急出口灯' },
|
||||
{ id: 104, categoryId: 1, name: '草坪灯' }
|
||||
// { id: 101, categoryId: 1, name: '路灯' },
|
||||
// { id: 102, categoryId: 1, name: '楼层指示灯' },
|
||||
// { id: 103, categoryId: 2, name: '应急出口灯' },
|
||||
// { id: 104, categoryId: 1, name: '草坪灯' }
|
||||
])
|
||||
|
||||
// 选中的分类
|
||||
@@ -72,14 +73,39 @@ const currentProjectList = computed(() => {
|
||||
const selectCategory = (item) => {
|
||||
activeCategory.value = item.id
|
||||
}
|
||||
// 获取维修项目
|
||||
const fetchProjectList = async () => {
|
||||
try {
|
||||
const res = await getRepairOrder()
|
||||
if (res.code === 200) {
|
||||
const data = res.data || []
|
||||
// 兼容后端嵌套格式 [{id, name, children: [{id, name}]}]
|
||||
categoryList.value = data.map(item => ({ id: item.id, projectName: item.projectName }))
|
||||
projectList.value = data.flatMap(item =>
|
||||
(item.children || []).map(child => ({
|
||||
id: child.id,
|
||||
categoryId: item.id,
|
||||
projectName: child.projectName
|
||||
}))
|
||||
)
|
||||
activeCategory.value = categoryList.value[0]?.id || 1
|
||||
}
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '获取项目列表失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
|
||||
onLoad(() =>{
|
||||
fetchProjectList()
|
||||
})
|
||||
|
||||
// 选择项目并跳转到维修项目填写页
|
||||
const selectProject = (item) => {
|
||||
// 获取分类名称
|
||||
const categoryName = categoryList.value.find(c => c.id === item.categoryId)?.name
|
||||
const categoryName = categoryList.value.find(c => c.id === item.categoryId)?.projectName
|
||||
// 跳转并传参
|
||||
uni.navigateTo({
|
||||
url: `/pageSubPack/fault-reporting/fault-reporting?category=${categoryName}&project=${item.name}`
|
||||
url: `/pageSubPack/fault-reporting/fault-reporting?category=${categoryName}&project=${item.projectName}&projectId=${item.id}`
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 搜索区域 -->
|
||||
<view class="search-container">
|
||||
@@ -10,55 +10,28 @@
|
||||
<uni-icons type="clear" size="18" color="#999"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <button class="search-btn" @tap="handleSearch">搜索</button> -->
|
||||
</view>
|
||||
|
||||
<!-- 小区列表 -->
|
||||
<scroll-view class="community-list" scroll-y :scroll-into-view="scrollIntoViewId" @scrolltolower="loadMoreData"
|
||||
:lower-threshold="100">
|
||||
<view v-for="item in displayedCommunities" :key="item.id" class="community-item" :id="'item-' + item.id"
|
||||
@tap="selectCommunity(item)" :class="{active:selectedItem?.id === item.id}">
|
||||
<scroll-view class="community-list" scroll-y>
|
||||
<view v-for="item in displayedCommunities" :key="item.id" class="community-item"
|
||||
@tap="selectCommunity(item)" :class="{active: selectedItem?.id === item.id}">
|
||||
<view class="community-item-left">
|
||||
<image src="/static/imgs/community.png" style="width: 48rpx;height: 48rpx;"></image>
|
||||
<image src="http://47.104.199.163:9090/images/imgs/community.png" style="width: 48rpx;height: 48rpx;"></image>
|
||||
<view class="community-info">
|
||||
<text class="community-name">{{ item.name }}</text>
|
||||
<text class="community-name">{{ item.villageName }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="selectedItem && selectedItem.id === item.id" class="selected-icon">
|
||||
<image src="/static/imgs/check.png" style="width: 48rpx;height: 48rpx;"></image>
|
||||
<image src="http://47.104.199.163:9090/images/imgs/check.png" style="width: 48rpx;height: 48rpx;"></image>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view v-if="hasMoreData" class="load-more-container">
|
||||
<view v-if="!isLoading" class="load-more-btn" @tap="loadMoreData">
|
||||
<text>加载更多</text>
|
||||
<uni-icons type="arrow-down" size="16" color="#007AFF"></uni-icons>
|
||||
</view>
|
||||
<view v-else class="loading-container">
|
||||
<uni-icons type="spinner-cycle" size="20" color="#007AFF" class="loading-icon"></uni-icons>
|
||||
<text>正在加载...</text>
|
||||
</view>
|
||||
<!-- <text class="page-info">第 {{ currentPage }} 页 / 共 {{ totalPages }} 页</text> -->
|
||||
</view>
|
||||
|
||||
<!-- 没有更多数据 -->
|
||||
<view v-if="!hasMoreData && displayedCommunities.length > 0" class="no-more-data">
|
||||
<text>没有更多数据了</text>
|
||||
</view>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<view v-if="displayedCommunities.length === 0 && !isSearching" class="empty-state">
|
||||
<view v-if="displayedCommunities.length === 0 && !isLoading" class="empty-state">
|
||||
<uni-icons type="info" size="60" color="#ccc"></uni-icons>
|
||||
<text class="empty-text">暂无小区数据</text>
|
||||
</view>
|
||||
|
||||
<!-- 搜索无结果 -->
|
||||
<view v-if="displayedCommunities.length === 0 && isSearching" class="empty-state">
|
||||
<uni-icons type="search" size="60" color="#ccc"></uni-icons>
|
||||
<text class="empty-text">未找到相关小区</text>
|
||||
<!-- <text class="empty-tip">请尝试其他关键词</text> -->
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<!-- 确认按钮 -->
|
||||
@@ -69,170 +42,65 @@
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
ref,
|
||||
computed,
|
||||
onMounted,
|
||||
watch
|
||||
} from 'vue'
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import {onLoad} from '@dcloudio/uni-app'
|
||||
import { getVillageList,switchVillage} from '../../api/api.js'
|
||||
|
||||
// 响应式数据
|
||||
const searchText = ref('')
|
||||
const selectedItem = ref(null)
|
||||
const scrollIntoViewId = ref('')
|
||||
|
||||
// 分页相关
|
||||
const currentPage = ref(1)
|
||||
const pageSize = 5
|
||||
const totalCommunities = ref([])
|
||||
const displayedCommunities = ref([])
|
||||
const hasMoreData = ref(true)
|
||||
const isLoading = ref(false)
|
||||
|
||||
// 搜索状态
|
||||
const isSearching = ref(false)
|
||||
let searchTimeout = null
|
||||
const defaultVillageId = ref('')
|
||||
|
||||
// 所有小区数据
|
||||
const allCommunities = ref([{
|
||||
id: 1,
|
||||
name: '北境碧桂园小区',
|
||||
address: '北境市光明区碧桂路1号'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '南湖花园小区',
|
||||
address: '南湖市滨湖区湖滨路28号'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '东城国际社区',
|
||||
address: '东城市新城区人民路156号'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: '西湖雅苑',
|
||||
address: '西湖市风景区梅灵路88号'
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: '北境锦绣家园',
|
||||
address: '北境市朝阳区朝阳路56号'
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: '阳光100小区',
|
||||
address: '阳光市高新区创业路100号'
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: '绿城玫瑰园',
|
||||
address: '绿城市西湖区学院路188号'
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
name: '金地自在城',
|
||||
address: '金城市江干区金沙大道200号'
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
name: '万科城市花园',
|
||||
address: '万城市余杭区文一西路299号'
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
name: '保利中央公园',
|
||||
address: '保利市拱墅区莫干山路500号'
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
name: '龙湖天街小区',
|
||||
address: '龙湖市滨江区江南大道100号'
|
||||
},
|
||||
])
|
||||
|
||||
// 计算属性
|
||||
const totalPages = computed(() => {
|
||||
return Math.ceil(totalCommunities.value.length / pageSize)
|
||||
// 调用接口获取小区列表
|
||||
const fetchVillageList = async (villageName = '') => {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res = await getVillageList({ villageName })
|
||||
if (res.code === 200) {
|
||||
displayedCommunities.value = res.data
|
||||
// 自动选中传入的小区
|
||||
if (defaultVillageId.value) {
|
||||
const found = displayedCommunities.value.find(
|
||||
item => String(item.id) === String(defaultVillageId.value)
|
||||
)
|
||||
if (found) {
|
||||
selectedItem.value = found
|
||||
}
|
||||
}
|
||||
} else {
|
||||
uni.showToast({ title: res.msg || '获取数据失败', icon: 'none' })
|
||||
}
|
||||
} catch (err) {
|
||||
uni.showToast({ title: '网络错误', icon: 'none' })
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
// 接收传入的参数
|
||||
onLoad((options) => {
|
||||
if (options?.villageId) {
|
||||
defaultVillageId.value = options.villageId
|
||||
}
|
||||
})
|
||||
|
||||
// 方法
|
||||
// 加载分页数据
|
||||
const loadPageData = (pageNum) => {
|
||||
isLoading.value = true
|
||||
|
||||
// 模拟网络请求延迟
|
||||
setTimeout(() => {
|
||||
const startIndex = (pageNum - 1) * pageSize
|
||||
const endIndex = startIndex + pageSize
|
||||
const pageData = totalCommunities.value.slice(startIndex, endIndex)
|
||||
|
||||
if (pageNum === 1) {
|
||||
displayedCommunities.value = pageData
|
||||
} else {
|
||||
displayedCommunities.value = [...displayedCommunities.value, ...pageData]
|
||||
}
|
||||
|
||||
currentPage.value = pageNum
|
||||
hasMoreData.value = displayedCommunities.value.length < totalCommunities.value.length
|
||||
isLoading.value = false
|
||||
|
||||
// 滚动到新加载的内容
|
||||
if (pageNum > 1 && pageData.length > 0) {
|
||||
setTimeout(() => {
|
||||
scrollIntoViewId.value = 'item-' + pageData[0].id
|
||||
}, 100)
|
||||
}
|
||||
}, 500)
|
||||
}
|
||||
|
||||
// 加载更多数据
|
||||
const loadMoreData = () => {
|
||||
if (isLoading.value || !hasMoreData.value) return
|
||||
loadPageData(currentPage.value + 1)
|
||||
}
|
||||
|
||||
// 处理搜索输入
|
||||
// 处理搜索输入(防抖)
|
||||
const handleSearchInput = () => {
|
||||
// 防抖处理
|
||||
if (searchTimeout) {
|
||||
clearTimeout(searchTimeout)
|
||||
}
|
||||
|
||||
if (searchTimeout) clearTimeout(searchTimeout)
|
||||
searchTimeout = setTimeout(() => {
|
||||
handleSearch()
|
||||
fetchVillageList(searchText.value.trim())
|
||||
}, 300)
|
||||
}
|
||||
|
||||
// 处理搜索
|
||||
const handleSearch = () => {
|
||||
const keyword = searchText.value.trim().toLowerCase()
|
||||
|
||||
if (!keyword) {
|
||||
isSearching.value = false
|
||||
totalCommunities.value = [...allCommunities.value]
|
||||
loadPageData(1)
|
||||
return
|
||||
}
|
||||
|
||||
isSearching.value = true
|
||||
totalCommunities.value = allCommunities.value.filter(community =>
|
||||
community.name.toLowerCase().includes(keyword) ||
|
||||
community.address.toLowerCase().includes(keyword)
|
||||
)
|
||||
|
||||
loadPageData(1)
|
||||
}
|
||||
|
||||
// 清空搜索
|
||||
const clearSearch = () => {
|
||||
searchText.value = ''
|
||||
isSearching.value = false
|
||||
totalCommunities.value = [...allCommunities.value]
|
||||
loadPageData(1)
|
||||
fetchVillageList('')
|
||||
}
|
||||
|
||||
// 选择小区
|
||||
@@ -243,59 +111,49 @@
|
||||
// 确认选择
|
||||
const handleConfirm = () => {
|
||||
if (!selectedItem.value) {
|
||||
uni.showToast({
|
||||
title: '请先选择小区',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
uni.showToast({ title: '请先选择小区', icon: 'none', duration: 2000 })
|
||||
return
|
||||
}
|
||||
|
||||
uni.showModal({
|
||||
title: '确认选择',
|
||||
content: `您已选择: ${selectedItem.value.name}`,
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.showToast({
|
||||
title: '选择成功',
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
})
|
||||
|
||||
// 在实际应用中,这里可以触发回调或页面跳转
|
||||
// uni.navigateBack() 或 emit('confirm', selectedItem.value)
|
||||
uni.showLoading({ title: '切换中...', mask: true })
|
||||
switchVillage({ villageId: selectedItem.value.id }).then((res) =>{
|
||||
if(res.code === 200){
|
||||
uni.showToast({ title: '切换成功', icon: 'success', duration: 1500 })
|
||||
uni.$emit('confirm', selectedItem.value)
|
||||
// 模拟2秒后返回上一页
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
}else{
|
||||
uni.showToast({ title: res.msg || '切换失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
}).catch((err)=>{
|
||||
uni.hideLoading()
|
||||
uni.showToast({title:err.msg || '网络异常',icon:'none'})
|
||||
})
|
||||
|
||||
|
||||
// uni.showModal({
|
||||
// title: '确认选择',
|
||||
// content: `您已选择: ${selectedItem.value.villageName}`,
|
||||
// success: (res) => {
|
||||
// if (res.confirm) {
|
||||
// uni.showToast({ title: '选择成功', icon: 'success', duration: 1500 })
|
||||
// uni.$emit('confirm', selectedItem.value)
|
||||
// setTimeout(() => {
|
||||
// uni.navigateBack()
|
||||
// }, 1500)
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
}
|
||||
|
||||
// 监听搜索文本变化
|
||||
watch(searchText, (newVal) => {
|
||||
if (!newVal.trim()) {
|
||||
clearSearch()
|
||||
}
|
||||
})
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
// 初始化数据
|
||||
totalCommunities.value = [...allCommunities.value]
|
||||
loadPageData(1)
|
||||
|
||||
// 默认选中第一项
|
||||
if (displayedCommunities.value.length > 0) {
|
||||
selectedItem.value = displayedCommunities.value[0]
|
||||
}
|
||||
fetchVillageList()
|
||||
})
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 页面容器 */
|
||||
<style scoped>
|
||||
.container {
|
||||
min-height: 100vh;
|
||||
background-color: #f5f5f5;
|
||||
@@ -304,13 +162,11 @@
|
||||
padding: 0rpx 40rpx;
|
||||
}
|
||||
|
||||
/* 搜索区域 */
|
||||
.search-container {
|
||||
padding: 20rpx 30rpx;
|
||||
background-color: #ffffff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
/* box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05); */
|
||||
z-index: 10;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
@@ -324,7 +180,6 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 80rpx;
|
||||
/* margin-right: 20rpx; */
|
||||
}
|
||||
|
||||
.search-icon {
|
||||
@@ -351,44 +206,25 @@
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.search-btn {
|
||||
background-color: #007AFF;
|
||||
color: #fff;
|
||||
font-size: 28rpx;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
border-radius: 10rpx;
|
||||
padding: 0 30rpx;
|
||||
margin: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* 小区列表 */
|
||||
.community-list {
|
||||
flex: 1;
|
||||
/* padding: 0 30rpx; */
|
||||
margin-top: 20rpx;
|
||||
margin-bottom: 180rpx;
|
||||
|
||||
}
|
||||
|
||||
.community-item {
|
||||
background-color: #fff;
|
||||
/* border-radius: 12rpx; */
|
||||
padding: 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
/* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05); */
|
||||
/* transition: all 0.2s; */
|
||||
}
|
||||
|
||||
.community-item.active {
|
||||
background-color: #F5FAFF;
|
||||
border: 1px solid #2F77FD;
|
||||
transform: translateY(2rpx);
|
||||
|
||||
}
|
||||
|
||||
.community-item-left {
|
||||
@@ -397,10 +233,6 @@
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.house-icon {
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.community-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -414,87 +246,10 @@
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.community-address {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-bottom: 5rpx;
|
||||
}
|
||||
|
||||
.community-id {
|
||||
font-size: 22rpx;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.selected-icon {
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
/* 加载更多容器 */
|
||||
.load-more-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 40rpx 0;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.load-more-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 20rpx 40rpx;
|
||||
background-color: #f8f8f8;
|
||||
border-radius: 50rpx;
|
||||
color: #007AFF;
|
||||
font-size: 28rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.load-more-btn text {
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.loading-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 20rpx 40rpx;
|
||||
background-color: #f8f8f8;
|
||||
border-radius: 50rpx;
|
||||
color: #007AFF;
|
||||
font-size: 28rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.loading-icon {
|
||||
margin-right: 10rpx;
|
||||
animation: rotate 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes rotate {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.page-info {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 没有更多数据 */
|
||||
.no-more-data {
|
||||
text-align: center;
|
||||
padding: 40rpx 0;
|
||||
color: #999;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
/* 空状态 */
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -507,15 +262,8 @@
|
||||
font-size: 32rpx;
|
||||
color: #999;
|
||||
margin-top: 20rpx;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
font-size: 24rpx;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
/* 确认区域 */
|
||||
.confirm-area {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
@@ -542,21 +290,10 @@
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.selected-info {
|
||||
text-align: center;
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
margin-top: 20rpx;
|
||||
padding: 10rpx;
|
||||
background-color: #f8f8f8;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
/* 适配不同屏幕 */
|
||||
@media (min-width: 768px) {
|
||||
.container {
|
||||
max-width: 500px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<uni-nav-bar left-icon="left" title="远程开门" backgroundColor ="none" :border="false" @clickLeft="narBack" />
|
||||
</view>
|
||||
<view class="top-img">
|
||||
<image src="/static/imgs/xuancheng-bg.png" mode="" style="width: 100%;height: 100%;"></image>
|
||||
<image src="http://47.104.199.163:9090/images/imgs/xuancheng-bg.png" mode="" style="width: 100%;height: 100%;"></image>
|
||||
</view>
|
||||
|
||||
<!-- 提示文案 -->
|
||||
@@ -49,6 +49,7 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
|
||||
// 响应式数据:选中的门索引、开门成功提示
|
||||
const selectedDoor = ref(-1) // -1表示未选中
|
||||
const showSuccess = ref(false)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<swiper-item>
|
||||
<view class="guide-item">
|
||||
<view class="guide-img">
|
||||
<image src="/static/imgs/guide1.png" style="width: 100%;height: 100%;"></image>
|
||||
<image src="http://47.104.199.163:9090/images/imgs/guide1.png" style="width: 100%;height: 100%;"></image>
|
||||
</view>
|
||||
<view style="height: 200rpx;width: 100%;"></view>
|
||||
<view class="guide-title">精准服务</view>
|
||||
@@ -26,7 +26,7 @@
|
||||
<swiper-item>
|
||||
<view class="guide-item">
|
||||
<view class="guide-img">
|
||||
<image src="/static/imgs/guide2.png" style="width: 100%;height: 100%;"></image>
|
||||
<image src="http://47.104.199.163:9090/images/imgs/guide2.png" style="width: 100%;height: 100%;"></image>
|
||||
</view>
|
||||
<view style="height: 200rpx;width: 100%;"></view>
|
||||
<view class="guide-title">高效沟通</view>
|
||||
@@ -38,7 +38,7 @@
|
||||
<swiper-item>
|
||||
<view class="guide-item">
|
||||
<view class="guide-img">
|
||||
<image src="/static/imgs/guide3.png" style="width: 100%;height: 100%;"></image>
|
||||
<image src="http://47.104.199.163:9090/images/imgs/guide3.png" style="width: 100%;height: 100%;"></image>
|
||||
</view>
|
||||
<view style="height: 200rpx;width: 100%;"></view>
|
||||
<view class="guide-title">智能管理</view>
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
<view class="location-area">
|
||||
<!-- 定位图标 -->
|
||||
<view class="location-icon">
|
||||
<image src="/static/imgs/adress.png" style="height: 100%; width: 100%"></image>
|
||||
<image src="http://47.104.199.163:9090/images/imgs/adress.png" style="height: 100%; width: 100%"></image>
|
||||
</view>
|
||||
<!-- 小区名称和下拉箭头 -->
|
||||
<view class="community-selector">
|
||||
<text class="community-name">{{ currentCommunity }}</text>
|
||||
<view class="community-icon">
|
||||
<image src="/static/imgs/三角形.png" style="height: 100%; width: 100%"></image>
|
||||
<image src="http://47.104.199.163:9090/images/imgs/三角形.png" style="height: 100%; width: 100%"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -52,7 +52,7 @@
|
||||
<view class="noticeClass">
|
||||
<!-- 左侧消息通知文字 -->
|
||||
<view class="notice-left">
|
||||
<image src="/static/imgs/notice.png" class="notice-icon"></image>
|
||||
<image src="http://47.104.199.163:9090/images/imgs/notice.png" class="notice-icon"></image>
|
||||
</view>
|
||||
<!-- 右侧滚动公告 -->
|
||||
<view class="notice-right" @click="getNoticeMore">
|
||||
@@ -93,26 +93,26 @@
|
||||
<!-- 第一行功能:故障上报、一键开门、工单大厅、我的工单 -->
|
||||
<view class="function-row">
|
||||
<view class="function-item" @click="goToReport">
|
||||
<image class="item-icon" src="/static/imgs/fault-report.png" mode="aspectFit"></image>
|
||||
<image class="item-icon" src="http://47.104.199.163:9090/images/imgs/fault-report.png" mode="aspectFit"></image>
|
||||
<text class="item-text">故障上报</text>
|
||||
</view>
|
||||
<view class="function-item" @click="goToOneOpenDoor">
|
||||
<image class="item-icon" src="/static/imgs/open.png" mode="aspectFit"></image>
|
||||
<image class="item-icon" src="http://47.104.199.163:9090/images/imgs/open.png" mode="aspectFit"></image>
|
||||
<text class="item-text">一键开门</text>
|
||||
</view>
|
||||
<view class="function-item" @tap="goToTicketHall">
|
||||
<image class="item-icon" src="/static/imgs/work-order.png" mode="aspectFit"></image>
|
||||
<image class="item-icon" src="http://47.104.199.163:9090/images/imgs/work-order.png" mode="aspectFit"></image>
|
||||
<text class="item-text">工单大厅</text>
|
||||
</view>
|
||||
<view class="function-item" @tap="goToMyTicket">
|
||||
<image class="item-icon" src="/static/imgs/my-work.png" mode="aspectFit"></image>
|
||||
<image class="item-icon" src="http://47.104.199.163:9090/images/imgs/my-work.png" mode="aspectFit"></image>
|
||||
<text class="item-text">我的工单</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 第二行 -->
|
||||
<view class="function-row" style="margin-top: 2px">
|
||||
<view class="function-item" @tap="goToComplaint">
|
||||
<image class="item-icon" src="/static/imgs/complaint.png" mode="aspectFit"></image>
|
||||
<image class="item-icon" src="http://47.104.199.163:9090/images/imgs/complaint.png" mode="aspectFit"></image>
|
||||
<text class="item-text">投诉处理</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -126,15 +126,22 @@ import { onLoad, onUnload } from '@dcloudio/uni-app'
|
||||
|
||||
// 列表数据状态
|
||||
const current = ref(0)
|
||||
const currentCommunity = ref('碧桂园小区')
|
||||
const bannerList = ref([{ img: '/static/imgs/banner1.png' }])
|
||||
const currentCommunity = ref('')
|
||||
const bannerList = ref([{ img: 'http://47.104.199.163:9090/images/imgs/banner1.png' }])
|
||||
const noticeText = ref('公告公告本小区今天安装了摄像头')
|
||||
|
||||
// =======方法=======
|
||||
// 跳转小区
|
||||
const navigateToPage = () => {
|
||||
const curVillageId = uni.getStorageSync('currentVillage')
|
||||
let villageId = ''
|
||||
if(curVillageId){
|
||||
try{
|
||||
villageId = JSON.parse(curVillageId).id
|
||||
}catch(e){}
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: '/pageSubPack/notice-list/select-community'
|
||||
url: `/pageSubPack/notice-list/select-community?villageId=${villageId}`
|
||||
})
|
||||
}
|
||||
// 跳转公告
|
||||
@@ -187,11 +194,20 @@ const goToReport = () => {
|
||||
}
|
||||
// 接收选择小区返回的参数
|
||||
const slelctHomeData = data => {
|
||||
currentCommunity.value = data.name
|
||||
currentCommunity.value = data.villageName
|
||||
uni.setStorageSync('currentVillage', JSON.stringify(data))
|
||||
}
|
||||
|
||||
onLoad(() => {
|
||||
uni.$on('confirm', slelctHomeData)
|
||||
// 读取本地缓存的小区
|
||||
const cache = uni.getStorageSync('currentVillage')
|
||||
if (cache) {
|
||||
try {
|
||||
const village = JSON.parse(cache)
|
||||
currentCommunity.value = village.villageName
|
||||
} catch (e) {}
|
||||
}
|
||||
})
|
||||
|
||||
onUnload(() => {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<scroll-view class="page" scroll-y>
|
||||
<view class="topBox">
|
||||
<view class="name">
|
||||
<image src="/static/imgs/touxiang.png" class="img" />
|
||||
<image src="http://47.104.199.163:9090/images/imgs/touxiang.png" class="img" />
|
||||
<span
|
||||
style="padding: 5rpx 5rpx; display: flex; flex-direction: column; line-height: 60rpx"
|
||||
>
|
||||
@@ -50,16 +50,16 @@ import { ref } from 'vue'
|
||||
|
||||
const list = ref([
|
||||
{
|
||||
icon: '/static/imgs/shangbao.png',
|
||||
icon: 'http://47.104.199.163:9090/images/imgs/shangbao.png',
|
||||
title: '上报记录'
|
||||
},
|
||||
{
|
||||
icon: '/static/imgs/xunjian.png',
|
||||
icon: 'http://47.104.199.163:9090/images/imgs/xunjian.png',
|
||||
title: '巡检记录'
|
||||
// desc: "您可以在这里添加家人、朋友、租客~"
|
||||
},
|
||||
{
|
||||
icon: '/static/imgs/xunjian.png',
|
||||
icon: 'http://47.104.199.163:9090/images/imgs/xunjian.png',
|
||||
title: '仪表换新'
|
||||
// desc: "您可以在这里添加家人、朋友、租客~"
|
||||
},
|
||||
|
||||
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 114 KiB |
|
Before Width: | Height: | Size: 763 B |
|
Before Width: | Height: | Size: 827 B |
|
Before Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 608 B |
|
Before Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 240 B |