123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <template>
- <view class="dealer">
- <view class="top">
- <input class="uni-input" v-model="keyword" placeholder="请输入" @input="input"/>
- <view class="btn" @click="searchHistory(keyword)">搜索</view>
- </view>
- <view class="bom">
- <view class="grouping" v-for="(v,i) in aList" :key="i">
- <view class="th">
- {{v._id}}
- </view>
- <view class="td" v-for="(v1,i1) in v.data" :key="i1" @click="$goBack(2,'/pages/dealer/dealerDetails?id=' + v1.id + '&name=' +v1.name)">
- {{v1.name}}
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {search} from '../../api/dealer.js'
- export default {
- data() {
- return {
- keyword: '',
- aList: [], //展示的数据
- //所有的数据
- bList: []
- };
- },
- onLoad() {
-
- },
- created() {
- this.getData()
- },
- methods: {
- input(){
- if(this.keyword.length <= 0){
- this.getList()
- }
- },
- async getData(){
- uni.showLoading({
- title: '加载中'
- });
- const res = await search({
- agencyList: [],
- name: '',
- accessToken: uni.getStorageSync('tokenInfo'),
- account: uni.getStorageSync('account')
- })
- uni.hideLoading();
- this.bList = res.data.list
- this.getList()
- },
- getList(){
- this.aList = this.bList
- },
- // 搜索
- searchHistory(value) {
- // value自动接收输入框中的内容
- if (value == '') {
- //如果输入的值为空则加载所有的列表
- this.getList();
- } else {
- //先清空展示的数据
- this.aList = []
- //然后开始循环全部数据
- this.bList.forEach(v => {
- v.data.forEach(v1 => {
- if(v1.name.indexOf(value) >= 0){
- let list = {
- _id: v._id,
- data: [{
- name: v1.name,
- id: v1.id
- }]
- }
- this.aList.push(list)
- }
- })
- })
- }
- },
- }
- }
- </script>
- <style lang="scss">
- .dealer {
- height: 100%;
- .top {
- height: 100rpx;
- display: flex;
- padding: 10rpx;
- border-bottom: 1rpx solid #dfdfdf;
- .uni-input{
- flex: 1;
- height: 100%;
- padding-left: 20rpx;
- }
- .btn{
- width: 20%;
- height: 100%;
- line-height: 100rpx;
- text-align: center;
- font-size: 30rpx;
- background-color: #f4f4f4;
- }
- }
- .bom {
- height: calc(100% - 130rpx);
- padding-top: 10rpx;
- overflow-y: scroll;
- .grouping {
- .th {
- height: 60rpx;
- line-height: 60rpx;
- text-align: center;
- background-color: #f1f1f1;
- color: #834e9a;
- }
- .td {
- padding: 30rpx;
- border-bottom: 1rpx solid #b0b0b0;
- &:last-child{
- border-bottom: 0;
- }
- }
- }
- }
- }
- </style>
|