This commit is contained in:
wangyilin 2024-11-12 17:12:07 +08:00
parent a2385c5632
commit 57bf502664
3 changed files with 135 additions and 48 deletions

View File

@ -1,57 +1,94 @@
<template> <template>
<view> <view class="search" id="search">
<view class="swiperDemo"> <nut-input v-model="valueInput" @input="searchInput" placeholder="请进行搜索"></nut-input>
<nut-swiper ref="swiperRef" pagination-visible pagination-color="#e53e31" :auto-play="3000" :init-page="0"> <view v-if="valueInput">
<nut-swiper-item v-for="(item, index) in list" :key="index" style="height: 200px"> <ul>
<image :src="item" alt="" style="height: 100%; width: 100%" draggable="false"/> <li v-for="item in searchResults" :key="item.id">{{item}}</li>
</nut-swiper-item> </ul>
</nut-swiper>
</view> </view>
<view class="swiperDemoItem"> <view v-else >
<view class="swiperDemoIndex"></view> 没有找到相关结果
<view>请选择</view>
</view>
<!--九宫格-->
<view>
<view class="subModule">
<view class="subModuleItem" v-for="item in subModuleList" :key="item.id" @click="subNavigation(item.url)">
<view class="subModuleIndex">
<image :src="item.icon"></image>
</view>
<view style=" font-size: 12px;color: #414141;margin-top: 9px">{{ item.name }}</view>
</view>
</view>
</view> </view>
</view> </view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import {ref} from 'vue'
import Taro from "@tarojs/taro";
import icon from '@/assets/images/project.png'
import './index.scss' import './index.scss'
const list = ref([process.env.TARO_APP_MINIO_URL + '/police-security/2024/11/5/dunpai.jpg',process.env.TARO_APP_MINIO_URL + '/police-security/2024/11/5/xingqiu.jpg']) import { ref} from "vue";
const swiperRef = ref() // const valueInput = ref('')
const subModuleList = ref([ // '','','','','','','','','',''
const list = ref([])
const dataList = ref([
{ {
id: 0, id:0,
icon: icon, value:'齐家园'
name: '企事业单位',
url: '/subPages/police/myEnterprisesUnit/myEnterprisesUnit'
}, },
{ {
id: 1, id:1,
icon: icon, value:'刘德华'
name: '警保风采',
url: ''
}, },
{ {
id: 2, id:2,
icon: icon, value:'张学友'
name: '待定', },{
url: '' id:3,
value:'黎明'
},
{
id:4,
value:'家具城'
},
{
id:5,
value:'左岸春天'
},
{
id:6,
value:'麦德龙商城'
},
{
id:7,
value:'世纪酒店'
},
{
id:8,
value:'四方小学'
},
{
id:9,
value:'海洋半岛'
},
{
id:10,
value:'育英小学'
},
{
id:11,
value:'明德小学'
},{
id:12,
value:'希望小学'
} }
]) ])
const searchResults = ref([])
const subNavigation = async (url: string) => Taro.navigateTo({url}) const searchInput = (e:any)=>{
valueInput.value = e.target.value
if (!valueInput.value) {
searchResults.value = []
return [];
}else{
dataList.value.map((item)=>{
return list.value.push(item.value)
})
searchResults.value = list.value.filter(item =>
item.toLowerCase().includes(valueInput.value.toLowerCase())
);
}
// console.log(searchResults.value)
}
</script> </script>
<style scoped lang="scss">
</style>

View File

@ -15,7 +15,7 @@
</view> </view>
<!-- 用户信息 --> <!-- 用户信息 -->
<view class="userIndex"> <view class="userIndex">
<view class="exit" v-for="item in datalist" :key="item.value"> <view class="exit" v-for="item in datalist" :key="item.value" @click="addExit(item.value)">
<view class="exitItem"> <view class="exitItem">
<!-- <view class="exitItemIndex">--> <!-- <view class="exitItemIndex">-->
<!-- <image :src="item.url" mode="scaleToFill" class="image" />--> <!-- <image :src="item.url" mode="scaleToFill" class="image" />-->
@ -28,20 +28,30 @@
</view> </view>
</view> </view>
<!-- 退出弹框--> <!-- 退出弹框-->
<nut-dialog
content="是否退出登录?"
v-model:visible="visible" @cancel="visible = false" @ok="onOk"
/>
</view> </view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import './index.scss' import './index.scss'
import {ref} from "vue"; import {ref} from "vue";
import {useUserStore} from "@/store/userStore";
import {useTabBarStore} from "@/store/tabBarStore"
import Taro from "@tarojs/taro";
const {setSelected} = useTabBarStore()
const {resetUserInfo} = useUserStore()
const visible = ref<boolean>(false)
const datalist = ref([ const datalist = ref([
{ {
value: 1, value: 0,
name: '简介', name: '简介',
}, },
{ {
value: 0, value: 1,
name: '退出登录', name: '退出登录',
}, },
{ {
@ -53,4 +63,18 @@ const datalist = ref([
name: '意见收集', name: '意见收集',
}, },
]) ])
const addExit = (index:number)=>{
switch (index) {
case 1:
visible.value = true
break;
}
}
const onOk = ()=>{
resetUserInfo()
setSelected(0)
Taro.navigateTo({
url: "/pages/login/login",
});
}
</script> </script>

View File

@ -14,7 +14,7 @@
</view> </view>
<!-- 用户信息 --> <!-- 用户信息 -->
<view class="userIndex"> <view class="userIndex">
<view class="exit" v-for="item in datalist" :key="item.value"> <view class="exit" v-for="item in datalist" :key="item.value" @click="addExit(item.value)">
<view class="exitItem"> <view class="exitItem">
<!-- <view class="exitItemIndex">--> <!-- <view class="exitItemIndex">-->
<!-- <image :src="item.url" mode="scaleToFill" class="image" />--> <!-- <image :src="item.url" mode="scaleToFill" class="image" />-->
@ -27,20 +27,30 @@
</view> </view>
</view> </view>
<!-- 退出弹框--> <!-- 退出弹框-->
<nut-dialog
content="是否退出登录?"
v-model:visible="visible" @cancel="visible = false" @ok="onOk"
/>
</view> </view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import './index.scss' import './index.scss'
import {ref} from "vue"; import {ref} from "vue";
import {useUserStore} from "@/store/userStore";
import {useTabBarStore} from "@/store/tabBarStore"
import Taro from "@tarojs/taro";
const {setSelected} = useTabBarStore()
const {resetUserInfo} = useUserStore()
const visible = ref<boolean>(false)
const datalist = ref([ const datalist = ref([
{ {
value: 1, value: 0,
name: '小程序简介', name: '小程序简介',
}, },
{ {
value: 0, value: 1,
name: '退出登录', name: '退出登录',
}, },
{ {
@ -52,4 +62,20 @@ const datalist = ref([
name: '意见收集', name: '意见收集',
}, },
]) ])
const addExit = (index:number)=>{
switch (index) {
case 1:
visible.value = true
break;
}
}
const onOk = ()=>{
resetUserInfo()
setSelected(0)
Taro.navigateTo({
url: "/pages/login/login",
});
}
</script> </script>