对接小区、故障报修接口,更换图片地址
@@ -17,4 +17,31 @@ export const getLoginBySms = (data) =>{
|
|||||||
export const getResetPassword = (data) =>{
|
export const getResetPassword = (data) =>{
|
||||||
return post('/api/butler/auth/forgetPassword',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,81 +1,92 @@
|
|||||||
|
|
||||||
let baseUrl = '';
|
let baseUrl = '';
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
baseUrl = 'http://192.168.0.239:8080'; // 开发环境
|
baseUrl = 'http://192.168.0.239:8080'; // 开发环境
|
||||||
} else {
|
} else {
|
||||||
baseUrl = 'http://192.168.1.224:8080'; // 生产环境
|
baseUrl = 'http://192.168.0.224:8080'; // 生产环境
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function request(url, data = {}, method = "GET") {
|
export default function request(url, data = {}, method = "GET") {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// 加载中提示(提升用户体验)
|
uni.showLoading({
|
||||||
uni.showLoading({ title: '请求中...', mask: true });
|
title: '请求中...',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
|
||||||
uni.request({
|
uni.request({
|
||||||
url: baseUrl + url,
|
url: baseUrl + url,
|
||||||
data: data,
|
data: data,
|
||||||
method: method,
|
method: method,
|
||||||
header: {
|
header: {
|
||||||
"Authorization": "Bearer " + (uni.getStorageSync("token") || ''),
|
"Authorization": "Bearer " + (uni.getStorageSync("token") || ''),
|
||||||
"clientid": "resident",
|
"clientid": "butler",
|
||||||
'content-type': 'application/json'
|
'content-type': 'application/json'
|
||||||
},
|
},
|
||||||
// header: {
|
|
||||||
// "token": uni.getStorageSync("token") || '',
|
|
||||||
// 'content-type': 'application/json'
|
|
||||||
// },
|
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
uni.hideLoading(); // 关闭加载提示
|
uni.hideLoading();
|
||||||
|
|
||||||
// 处理HTTP状态码(网络层面)
|
// HTTP 失败
|
||||||
if (res.statusCode !== 200) {
|
if (res.statusCode !== 200) {
|
||||||
const errMsg = `请求失败(${res.statusCode})`;
|
reject({ msg: `请求异常 ${res.statusCode}`, code: res.statusCode });
|
||||||
uni.showToast({ title: errMsg, icon: "none", duration: 2000 });
|
|
||||||
reject(errMsg);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理业务状态码(后端返回的data里)
|
const resData = res.data || {};
|
||||||
const resData = res.data || {}; // 兼容后端返回空的情况
|
|
||||||
|
|
||||||
// 优先处理token过期(401)
|
// token 过期
|
||||||
if (resData.code === 401) {
|
if (resData.code === 401) {
|
||||||
uni.showToast({ title: '登录过期,请重新登录', icon: 'none', duration: 2000 });
|
uni.showToast({ title: '登录过期,请重新登录', icon: 'none' });
|
||||||
uni.clearStorageSync('token');
|
uni.clearStorageSync('token');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.reLaunch({ url: '/pageSubPack/loginSub/pwd-login' });
|
uni.reLaunch({ url: '/pageSubPack/loginSub/pwd-login' });
|
||||||
}, 1500);
|
}, 1500);
|
||||||
reject('token 过期');
|
reject({ msg: '登录过期', code: 401 });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 业务成功(code=200)
|
// 成功
|
||||||
if (resData.code === 200) {
|
if (resData.code === 200) {
|
||||||
resolve(resData); // 只返回核心数据,简化页面调用
|
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);
|
|
||||||
}
|
}
|
||||||
|
// 业务失败
|
||||||
else {
|
else {
|
||||||
const errMsg = resData.msg || '业务异常';
|
reject({ msg: resData.msg || '请求失败', code: resData.code, data: resData });
|
||||||
uni.showToast({ title: errMsg, icon: "none", duration: 2000 });
|
|
||||||
reject(errMsg);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
uni.hideLoading(); // 关闭加载提示
|
uni.hideLoading();
|
||||||
const errMsg = err.msg || '网络请求失败';
|
reject({ msg: '网络异常', code: -1, raw: err });
|
||||||
uni.showToast({ title: errMsg, icon: "none", duration: 2000 });
|
|
||||||
reject(err);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export const get = (url, data) => request(url, data, 'GET');
|
export const get = (url, data) => request(url, data, 'GET');
|
||||||
export const post = (url, data) => request(url, data, 'POST');
|
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">
|
<view class="upload-item" v-for="(img, index) in form.images" :key="index">
|
||||||
<image :src="img" mode="aspectFill" class="upload-img"></image>
|
<image :src="img" mode="aspectFill" class="upload-img"></image>
|
||||||
<image
|
<image
|
||||||
src="/static/imgs/delete.png"
|
src="http://47.104.199.163:9090/images/imgs/delete.png"
|
||||||
class="upload-delete"
|
class="upload-delete"
|
||||||
@click="deleteImage(index)"
|
@click="deleteImage(index)"
|
||||||
></image>
|
></image>
|
||||||
@@ -75,10 +75,12 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
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 repairProject = ref('')
|
||||||
|
const repairId = ref('')
|
||||||
|
|
||||||
// 表单数据
|
// 表单数据
|
||||||
const form = ref({
|
const form = ref({
|
||||||
@@ -88,11 +90,15 @@ const form = ref({
|
|||||||
images: [] // 图片列表
|
images: [] // 图片列表
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// ==========方法========
|
||||||
// 页面加载时获取传参
|
// 页面加载时获取传参
|
||||||
onLoad(options => {
|
onLoad(options => {
|
||||||
if (options.category && options.project) {
|
if (options.category && options.project) {
|
||||||
repairProject.value = `${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 => {
|
const deleteImage = index => {
|
||||||
form.value.images.splice(index, 1)
|
form.value.images.splice(index, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 表单提交
|
// 表单提交
|
||||||
const submitForm = () => {
|
const submitForm = async () => {
|
||||||
// 表单校验
|
// 表单校验
|
||||||
if (!repairProject.value) {
|
if (!repairProject.value) {
|
||||||
uni.showToast({ title: '请选择维修项目', icon: 'none' })
|
uni.showToast({ title: '请选择维修项目', icon: 'none' })
|
||||||
@@ -149,20 +176,41 @@ const submitForm = () => {
|
|||||||
uni.showToast({ title: '请输入正确的手机号', icon: 'none' })
|
uni.showToast({ title: '请输入正确的手机号', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// 提交数据
|
||||||
|
uni.showLoading({ title: '提交中...' ,})
|
||||||
|
try {
|
||||||
|
// 先上传图片
|
||||||
|
const imageUrls = await uploadImages()
|
||||||
|
|
||||||
// 提交数据(替换成你的接口)
|
const params = {
|
||||||
uni.showLoading({ title: '提交中...' })
|
maintenanceItemId:repairId.value,
|
||||||
|
item: form.value.title,
|
||||||
|
problem: form.value.desc,
|
||||||
|
phone: form.value.phone,
|
||||||
|
problemImageUrl: imageUrls.join(','),
|
||||||
|
// projectType: '0',
|
||||||
|
problemStatus:'0'
|
||||||
|
}
|
||||||
|
|
||||||
// 模拟接口请求
|
const res = await addRepairList(params)
|
||||||
setTimeout(() => {
|
if (res.code === 200) {
|
||||||
|
uni.showToast({ title: '提交成功', icon: 'success' })
|
||||||
|
form.value = { title: '', desc: '', phone: '', images: [] }
|
||||||
|
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()
|
uni.hideLoading()
|
||||||
uni.showToast({ title: '提交成功', icon: 'success' })
|
}
|
||||||
|
|
||||||
|
|
||||||
// 提交成功后重置表单/返回上一页
|
|
||||||
form.value = { title: '', desc: '', phone: '', images: [] }
|
|
||||||
// 或返回上一页
|
|
||||||
uni.navigateBack({ delta: 3 })
|
|
||||||
}, 1000)
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
v-for="item in categoryList"
|
v-for="item in categoryList"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
>
|
>
|
||||||
{{ item.name }}
|
{{ item.projectName }}
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
v-for="item in currentProjectList"
|
v-for="item in currentProjectList"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
>
|
>
|
||||||
{{ item.name }}
|
{{ item.projectName }}
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
@@ -38,20 +38,21 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue'
|
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([
|
const categoryList = ref([
|
||||||
{ id: 1, name: '基础设施' },
|
// { id: 1, name: '基础设施' },
|
||||||
{ id: 2, name: '电子设施' }
|
// { id: 2, name: '电子设施' }
|
||||||
])
|
])
|
||||||
|
|
||||||
// 所有项目数据
|
// 所有项目数据
|
||||||
const projectList = ref([
|
const projectList = ref([
|
||||||
{ id: 101, categoryId: 1, name: '路灯' },
|
// { id: 101, categoryId: 1, name: '路灯' },
|
||||||
{ id: 102, categoryId: 1, name: '楼层指示灯' },
|
// { id: 102, categoryId: 1, name: '楼层指示灯' },
|
||||||
{ id: 103, categoryId: 2, name: '应急出口灯' },
|
// { id: 103, categoryId: 2, name: '应急出口灯' },
|
||||||
{ id: 104, categoryId: 1, name: '草坪灯' }
|
// { id: 104, categoryId: 1, name: '草坪灯' }
|
||||||
])
|
])
|
||||||
|
|
||||||
// 选中的分类
|
// 选中的分类
|
||||||
@@ -72,14 +73,39 @@ const currentProjectList = computed(() => {
|
|||||||
const selectCategory = (item) => {
|
const selectCategory = (item) => {
|
||||||
activeCategory.value = item.id
|
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 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({
|
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>
|
</script>
|
||||||
|
|||||||
@@ -1,562 +1,299 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<!-- 搜索区域 -->
|
<!-- 搜索区域 -->
|
||||||
<view class="search-container">
|
<view class="search-container">
|
||||||
<view class="search-input-wrapper">
|
<view class="search-input-wrapper">
|
||||||
<uni-icons class="search-icon" type="search" size="20" color="#999"></uni-icons>
|
<uni-icons class="search-icon" type="search" size="20" color="#999"></uni-icons>
|
||||||
<input class="search-input" placeholder="请输入关键字进行搜索" placeholder-class="placeholder" v-model="searchText"
|
<input class="search-input" placeholder="请输入关键字进行搜索" placeholder-class="placeholder" v-model="searchText"
|
||||||
@input="handleSearchInput" />
|
@input="handleSearchInput" />
|
||||||
<view v-if="searchText" class="clear-icon" @tap="clearSearch">
|
<view v-if="searchText" class="clear-icon" @tap="clearSearch">
|
||||||
<uni-icons type="clear" size="18" color="#999"></uni-icons>
|
<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}">
|
|
||||||
<view class="community-item-left">
|
|
||||||
<image src="/static/imgs/community.png" style="width: 48rpx;height: 48rpx;"></image>
|
|
||||||
<view class="community-info">
|
|
||||||
<text class="community-name">{{ item.name }}</text>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="selectedItem && selectedItem.id === item.id" class="selected-icon">
|
</view>
|
||||||
<image src="/static/imgs/check.png" style="width: 48rpx;height: 48rpx;"></image>
|
|
||||||
|
<!-- 小区列表 -->
|
||||||
|
<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="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.villageName }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view v-if="selectedItem && selectedItem.id === item.id" class="selected-icon">
|
||||||
|
<image src="http://47.104.199.163:9090/images/imgs/check.png" style="width: 48rpx;height: 48rpx;"></image>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 加载更多 -->
|
<!-- 空状态 -->
|
||||||
<view v-if="hasMoreData" class="load-more-container">
|
<view v-if="displayedCommunities.length === 0 && !isLoading" class="empty-state">
|
||||||
<view v-if="!isLoading" class="load-more-btn" @tap="loadMoreData">
|
<uni-icons type="info" size="60" color="#ccc"></uni-icons>
|
||||||
<text>加载更多</text>
|
<text class="empty-text">暂无小区数据</text>
|
||||||
<uni-icons type="arrow-down" size="16" color="#007AFF"></uni-icons>
|
|
||||||
</view>
|
</view>
|
||||||
<view v-else class="loading-container">
|
</scroll-view>
|
||||||
<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">
|
<view class="confirm-area">
|
||||||
<text>没有更多数据了</text>
|
<button class="confirm-btn" :disabled="!selectedItem" :class="{ 'disabled-btn': !selectedItem }"
|
||||||
|
@tap="handleConfirm">
|
||||||
|
确认
|
||||||
|
</button>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 空状态 -->
|
|
||||||
<view v-if="displayedCommunities.length === 0 && !isSearching" 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>
|
|
||||||
|
|
||||||
<!-- 确认按钮 -->
|
|
||||||
<view class="confirm-area">
|
|
||||||
<button class="confirm-btn" :disabled="!selectedItem" :class="{ 'disabled-btn': !selectedItem }"
|
|
||||||
@tap="handleConfirm">
|
|
||||||
确认
|
|
||||||
</button>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</template>
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import { ref, onMounted } from 'vue'
|
||||||
ref,
|
import {onLoad} from '@dcloudio/uni-app'
|
||||||
computed,
|
import { getVillageList,switchVillage} from '../../api/api.js'
|
||||||
onMounted,
|
|
||||||
watch
|
|
||||||
} from 'vue'
|
|
||||||
|
|
||||||
// 响应式数据
|
// 响应式数据
|
||||||
const searchText = ref('')
|
const searchText = ref('')
|
||||||
const selectedItem = ref(null)
|
const selectedItem = ref(null)
|
||||||
const scrollIntoViewId = ref('')
|
const displayedCommunities = ref([])
|
||||||
|
const isLoading = ref(false)
|
||||||
|
let searchTimeout = null
|
||||||
|
const defaultVillageId = ref('')
|
||||||
|
|
||||||
// 分页相关
|
// 调用接口获取小区列表
|
||||||
const currentPage = ref(1)
|
const fetchVillageList = async (villageName = '') => {
|
||||||
const pageSize = 5
|
isLoading.value = true
|
||||||
const totalCommunities = ref([])
|
try {
|
||||||
const displayedCommunities = ref([])
|
const res = await getVillageList({ villageName })
|
||||||
const hasMoreData = ref(true)
|
if (res.code === 200) {
|
||||||
const isLoading = ref(false)
|
displayedCommunities.value = res.data
|
||||||
|
// 自动选中传入的小区
|
||||||
// 搜索状态
|
if (defaultVillageId.value) {
|
||||||
const isSearching = ref(false)
|
const found = displayedCommunities.value.find(
|
||||||
let searchTimeout = null
|
item => String(item.id) === String(defaultVillageId.value)
|
||||||
|
)
|
||||||
// 所有小区数据
|
if (found) {
|
||||||
const allCommunities = ref([{
|
selectedItem.value = found
|
||||||
id: 1,
|
}
|
||||||
name: '北境碧桂园小区',
|
}
|
||||||
address: '北境市光明区碧桂路1号'
|
} else {
|
||||||
},
|
uni.showToast({ title: res.msg || '获取数据失败', icon: 'none' })
|
||||||
{
|
|
||||||
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 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)
|
|
||||||
}
|
|
||||||
|
|
||||||
searchTimeout = setTimeout(() => {
|
|
||||||
handleSearch()
|
|
||||||
}, 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)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 选择小区
|
|
||||||
const selectCommunity = (item) => {
|
|
||||||
selectedItem.value = item
|
|
||||||
}
|
|
||||||
|
|
||||||
// 确认选择
|
|
||||||
const handleConfirm = () => {
|
|
||||||
if (!selectedItem.value) {
|
|
||||||
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.$emit('confirm', selectedItem.value)
|
|
||||||
// 模拟2秒后返回上一页
|
|
||||||
setTimeout(() => {
|
|
||||||
uni.navigateBack()
|
|
||||||
}, 1500)
|
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
uni.showToast({ title: '网络错误', icon: 'none' })
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// 接收传入的参数
|
||||||
|
onLoad((options) => {
|
||||||
|
if (options?.villageId) {
|
||||||
|
defaultVillageId.value = options.villageId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 处理搜索输入(防抖)
|
||||||
|
const handleSearchInput = () => {
|
||||||
|
if (searchTimeout) clearTimeout(searchTimeout)
|
||||||
|
searchTimeout = setTimeout(() => {
|
||||||
|
fetchVillageList(searchText.value.trim())
|
||||||
|
}, 300)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 清空搜索
|
||||||
|
const clearSearch = () => {
|
||||||
|
searchText.value = ''
|
||||||
|
fetchVillageList('')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 选择小区
|
||||||
|
const selectCommunity = (item) => {
|
||||||
|
selectedItem.value = item
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认选择
|
||||||
|
const handleConfirm = () => {
|
||||||
|
if (!selectedItem.value) {
|
||||||
|
uni.showToast({ title: '请先选择小区', icon: 'none', duration: 2000 })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
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)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 初始化
|
||||||
|
onMounted(() => {
|
||||||
|
fetchVillageList()
|
||||||
})
|
})
|
||||||
}
|
</script>
|
||||||
|
|
||||||
// 监听搜索文本变化
|
<style scoped>
|
||||||
watch(searchText, (newVal) => {
|
|
||||||
if (!newVal.trim()) {
|
|
||||||
clearSearch()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// 初始化
|
|
||||||
onMounted(() => {
|
|
||||||
// 初始化数据
|
|
||||||
totalCommunities.value = [...allCommunities.value]
|
|
||||||
loadPageData(1)
|
|
||||||
|
|
||||||
// 默认选中第一项
|
|
||||||
if (displayedCommunities.value.length > 0) {
|
|
||||||
selectedItem.value = displayedCommunities.value[0]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
/* 页面容器 */
|
|
||||||
.container {
|
|
||||||
min-height: 100vh;
|
|
||||||
background-color: #f5f5f5;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
.search-input-wrapper {
|
|
||||||
flex: 1;
|
|
||||||
background-color: #f3f3f3;
|
|
||||||
border-radius: 10rpx;
|
|
||||||
padding: 8rpx 20rpx;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
height: 80rpx;
|
|
||||||
/* margin-right: 20rpx; */
|
|
||||||
}
|
|
||||||
|
|
||||||
.search-icon {
|
|
||||||
margin-right: 15rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.search-input {
|
|
||||||
flex: 1;
|
|
||||||
height: 100%;
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.placeholder {
|
|
||||||
color: #999;
|
|
||||||
font-size: 28rpx;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.clear-icon {
|
|
||||||
padding: 10rpx;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
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 {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.house-icon {
|
|
||||||
margin-right: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.community-info {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.community-name {
|
|
||||||
font-size: 32rpx;
|
|
||||||
color: #222;
|
|
||||||
font-weight: 500;
|
|
||||||
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;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 100rpx 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.empty-text {
|
|
||||||
font-size: 32rpx;
|
|
||||||
color: #999;
|
|
||||||
margin-top: 20rpx;
|
|
||||||
margin-bottom: 10rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.empty-tip {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #ccc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 确认区域 */
|
|
||||||
.confirm-area {
|
|
||||||
position: fixed;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
padding: 20rpx 30rpx 40rpx;
|
|
||||||
background-color: #fff;
|
|
||||||
box-shadow: 0 -2rpx 20rpx rgba(0, 0, 0, 0.05);
|
|
||||||
}
|
|
||||||
|
|
||||||
.confirm-btn {
|
|
||||||
background-color: #4D5DFA;
|
|
||||||
color: #fff;
|
|
||||||
height: 80rpx;
|
|
||||||
line-height: 80rpx;
|
|
||||||
border-radius: 8rpx;
|
|
||||||
font-size: 28rpx;
|
|
||||||
width: 100%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.disabled-btn {
|
|
||||||
background-color: #ccc;
|
|
||||||
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 {
|
.container {
|
||||||
max-width: 500px;
|
min-height: 100vh;
|
||||||
margin: 0 auto;
|
background-color: #f5f5f5;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 0rpx 40rpx;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</style>
|
.search-container {
|
||||||
|
padding: 20rpx 30rpx;
|
||||||
|
background-color: #ffffff;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
z-index: 10;
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input-wrapper {
|
||||||
|
flex: 1;
|
||||||
|
background-color: #f3f3f3;
|
||||||
|
border-radius: 10rpx;
|
||||||
|
padding: 8rpx 20rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 80rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-icon {
|
||||||
|
margin-right: 15rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input {
|
||||||
|
flex: 1;
|
||||||
|
height: 100%;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.placeholder {
|
||||||
|
color: #999;
|
||||||
|
font-size: 28rpx;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clear-icon {
|
||||||
|
padding: 10rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.community-list {
|
||||||
|
flex: 1;
|
||||||
|
margin-top: 20rpx;
|
||||||
|
margin-bottom: 180rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.community-item {
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 30rpx;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.community-item.active {
|
||||||
|
background-color: #F5FAFF;
|
||||||
|
border: 1px solid #2F77FD;
|
||||||
|
transform: translateY(2rpx);
|
||||||
|
}
|
||||||
|
|
||||||
|
.community-item-left {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.community-info {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.community-name {
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #222;
|
||||||
|
font-weight: 500;
|
||||||
|
margin-bottom: 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selected-icon {
|
||||||
|
margin-left: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 100rpx 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-text {
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #999;
|
||||||
|
margin-top: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.confirm-area {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
padding: 20rpx 30rpx 40rpx;
|
||||||
|
background-color: #fff;
|
||||||
|
box-shadow: 0 -2rpx 20rpx rgba(0, 0, 0, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.confirm-btn {
|
||||||
|
background-color: #4D5DFA;
|
||||||
|
color: #fff;
|
||||||
|
height: 80rpx;
|
||||||
|
line-height: 80rpx;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
width: 100%;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.disabled-btn {
|
||||||
|
background-color: #ccc;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.container {
|
||||||
|
max-width: 500px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<uni-nav-bar left-icon="left" title="远程开门" backgroundColor ="none" :border="false" @clickLeft="narBack" />
|
<uni-nav-bar left-icon="left" title="远程开门" backgroundColor ="none" :border="false" @clickLeft="narBack" />
|
||||||
</view>
|
</view>
|
||||||
<view class="top-img">
|
<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>
|
</view>
|
||||||
|
|
||||||
<!-- 提示文案 -->
|
<!-- 提示文案 -->
|
||||||
@@ -49,6 +49,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
|
||||||
// 响应式数据:选中的门索引、开门成功提示
|
// 响应式数据:选中的门索引、开门成功提示
|
||||||
const selectedDoor = ref(-1) // -1表示未选中
|
const selectedDoor = ref(-1) // -1表示未选中
|
||||||
const showSuccess = ref(false)
|
const showSuccess = ref(false)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<swiper-item>
|
<swiper-item>
|
||||||
<view class="guide-item">
|
<view class="guide-item">
|
||||||
<view class="guide-img">
|
<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>
|
||||||
<view style="height: 200rpx;width: 100%;"></view>
|
<view style="height: 200rpx;width: 100%;"></view>
|
||||||
<view class="guide-title">精准服务</view>
|
<view class="guide-title">精准服务</view>
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
<swiper-item>
|
<swiper-item>
|
||||||
<view class="guide-item">
|
<view class="guide-item">
|
||||||
<view class="guide-img">
|
<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>
|
||||||
<view style="height: 200rpx;width: 100%;"></view>
|
<view style="height: 200rpx;width: 100%;"></view>
|
||||||
<view class="guide-title">高效沟通</view>
|
<view class="guide-title">高效沟通</view>
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
<swiper-item>
|
<swiper-item>
|
||||||
<view class="guide-item">
|
<view class="guide-item">
|
||||||
<view class="guide-img">
|
<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>
|
||||||
<view style="height: 200rpx;width: 100%;"></view>
|
<view style="height: 200rpx;width: 100%;"></view>
|
||||||
<view class="guide-title">智能管理</view>
|
<view class="guide-title">智能管理</view>
|
||||||
|
|||||||
@@ -13,13 +13,13 @@
|
|||||||
<view class="location-area">
|
<view class="location-area">
|
||||||
<!-- 定位图标 -->
|
<!-- 定位图标 -->
|
||||||
<view class="location-icon">
|
<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>
|
||||||
<!-- 小区名称和下拉箭头 -->
|
<!-- 小区名称和下拉箭头 -->
|
||||||
<view class="community-selector">
|
<view class="community-selector">
|
||||||
<text class="community-name">{{ currentCommunity }}</text>
|
<text class="community-name">{{ currentCommunity }}</text>
|
||||||
<view class="community-icon">
|
<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>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
<view class="noticeClass">
|
<view class="noticeClass">
|
||||||
<!-- 左侧消息通知文字 -->
|
<!-- 左侧消息通知文字 -->
|
||||||
<view class="notice-left">
|
<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>
|
||||||
<!-- 右侧滚动公告 -->
|
<!-- 右侧滚动公告 -->
|
||||||
<view class="notice-right" @click="getNoticeMore">
|
<view class="notice-right" @click="getNoticeMore">
|
||||||
@@ -93,26 +93,26 @@
|
|||||||
<!-- 第一行功能:故障上报、一键开门、工单大厅、我的工单 -->
|
<!-- 第一行功能:故障上报、一键开门、工单大厅、我的工单 -->
|
||||||
<view class="function-row">
|
<view class="function-row">
|
||||||
<view class="function-item" @click="goToReport">
|
<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>
|
<text class="item-text">故障上报</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="function-item" @click="goToOneOpenDoor">
|
<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>
|
<text class="item-text">一键开门</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="function-item" @tap="goToTicketHall">
|
<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>
|
<text class="item-text">工单大厅</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="function-item" @tap="goToMyTicket">
|
<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>
|
<text class="item-text">我的工单</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 第二行 -->
|
<!-- 第二行 -->
|
||||||
<view class="function-row" style="margin-top: 2px">
|
<view class="function-row" style="margin-top: 2px">
|
||||||
<view class="function-item" @tap="goToComplaint">
|
<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>
|
<text class="item-text">投诉处理</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -126,15 +126,22 @@ import { onLoad, onUnload } from '@dcloudio/uni-app'
|
|||||||
|
|
||||||
// 列表数据状态
|
// 列表数据状态
|
||||||
const current = ref(0)
|
const current = ref(0)
|
||||||
const currentCommunity = ref('碧桂园小区')
|
const currentCommunity = ref('')
|
||||||
const bannerList = ref([{ img: '/static/imgs/banner1.png' }])
|
const bannerList = ref([{ img: 'http://47.104.199.163:9090/images/imgs/banner1.png' }])
|
||||||
const noticeText = ref('公告公告本小区今天安装了摄像头')
|
const noticeText = ref('公告公告本小区今天安装了摄像头')
|
||||||
|
|
||||||
// =======方法=======
|
// =======方法=======
|
||||||
// 跳转小区
|
// 跳转小区
|
||||||
const navigateToPage = () => {
|
const navigateToPage = () => {
|
||||||
|
const curVillageId = uni.getStorageSync('currentVillage')
|
||||||
|
let villageId = ''
|
||||||
|
if(curVillageId){
|
||||||
|
try{
|
||||||
|
villageId = JSON.parse(curVillageId).id
|
||||||
|
}catch(e){}
|
||||||
|
}
|
||||||
uni.navigateTo({
|
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 => {
|
const slelctHomeData = data => {
|
||||||
currentCommunity.value = data.name
|
currentCommunity.value = data.villageName
|
||||||
|
uni.setStorageSync('currentVillage', JSON.stringify(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
uni.$on('confirm', slelctHomeData)
|
uni.$on('confirm', slelctHomeData)
|
||||||
|
// 读取本地缓存的小区
|
||||||
|
const cache = uni.getStorageSync('currentVillage')
|
||||||
|
if (cache) {
|
||||||
|
try {
|
||||||
|
const village = JSON.parse(cache)
|
||||||
|
currentCommunity.value = village.villageName
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnload(() => {
|
onUnload(() => {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<scroll-view class="page" scroll-y>
|
<scroll-view class="page" scroll-y>
|
||||||
<view class="topBox">
|
<view class="topBox">
|
||||||
<view class="name">
|
<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
|
<span
|
||||||
style="padding: 5rpx 5rpx; display: flex; flex-direction: column; line-height: 60rpx"
|
style="padding: 5rpx 5rpx; display: flex; flex-direction: column; line-height: 60rpx"
|
||||||
>
|
>
|
||||||
@@ -50,16 +50,16 @@ import { ref } from 'vue'
|
|||||||
|
|
||||||
const list = ref([
|
const list = ref([
|
||||||
{
|
{
|
||||||
icon: '/static/imgs/shangbao.png',
|
icon: 'http://47.104.199.163:9090/images/imgs/shangbao.png',
|
||||||
title: '上报记录'
|
title: '上报记录'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: '/static/imgs/xunjian.png',
|
icon: 'http://47.104.199.163:9090/images/imgs/xunjian.png',
|
||||||
title: '巡检记录'
|
title: '巡检记录'
|
||||||
// desc: "您可以在这里添加家人、朋友、租客~"
|
// desc: "您可以在这里添加家人、朋友、租客~"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: '/static/imgs/xunjian.png',
|
icon: 'http://47.104.199.163:9090/images/imgs/xunjian.png',
|
||||||
title: '仪表换新'
|
title: '仪表换新'
|
||||||
// desc: "您可以在这里添加家人、朋友、租客~"
|
// 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 |