暂存工作台修改

This commit is contained in:
2024-11-12 11:10:46 +08:00
parent b9d1ee34a7
commit c8649288ff
10 changed files with 342 additions and 23 deletions

View File

@@ -1,3 +1,11 @@
import { getParkList } from "../../service/park"
import { getParkMeterList } from "../../service/meter"
import { alertInfo } from "../../utils/index";
import request from "../../utils/request"
import { payWays } from "../../utils/data";
const { OK } = request;
// components/searchSelect/index.js
Component({
@@ -5,20 +13,108 @@ Component({
* 组件的属性列表
*/
properties: {
title: String,
type: String,
show: Boolean,
park: String,
},
observers: {
"show,type": function(newShow, newType) {
if (newShow && newType) {
this.onSearch()
}
}
},
/**
* 组件的初始数据
*/
data: {
columns: ['杭州', '宁波', '温州', '嘉兴', '湖州'],
columns: [],
searchText: "",
payWays,
},
lifetimes: {
attached() {
}
},
/**
* 组件的方法列表
*/
methods: {
onChangeSearch(e) {
this.setData({
searchText: e.detail,
})
},
onCancel() {
this.setData({
columns: [],
list: [],
searchText: ""
})
this.triggerEvent("cancel")
},
onConfirm(event) {
const { index } = event.detail;
const { list = [], type } = this.data;
const item = list[index];
this.setData({
columns: [],
list: [],
searchText: ""
})
this.triggerEvent("confirm", { data: item, type } );
},
onPayConfirm(event) {
const { index } = event.detail;
const { payWays = [], type } = this.data;
const item = payWays[index];
this.setData({
columns: [],
list: [],
searchText: ""
})
this.triggerEvent("confirm", { data: item, way: index, type } );
},
onSearch() {
const { type } = this.data;
console.log('type', type)
switch(type) {
case "park":
this.onSearchPark();
return;
case "meter":
console.log("meter")
this.onSearchMeter();
return;
}
},
async onSearchPark() {
const { searchText = "" } = this.data;
const { code, message, data: parks = [] } = await getParkList({keyword: searchText});
if (code !== OK) {
alertInfo(message)
return
}
this.setData({
columns: parks?.map(item => item?.name),
list: parks,
})
},
async onSearchMeter() {
const { searchText = "", park } = this.data;
console.log('this.data', this.data)
const { code, message, data: parks = [] } = await getParkMeterList({keyword: searchText, park});
if (code !== OK) {
alertInfo(message)
return
}
this.setData({
columns: parks?.map(item => `${item.meterNo}-${item.address}${item.tenement?.name ? '-' + item.tenement?.name : ''}`),
list: parks,
})
}
}
})

View File

@@ -1,8 +1,8 @@
{
"component": true,
"usingComponents": {
"van-overlay": "@vant/weapp/overlay/index",
"van-picker": "@vant/weapp/picker/index"
"van-popup": "@vant/weapp/popup/index",
"van-picker": "@vant/weapp/picker/index",
"van-search": "@vant/weapp/search/index"
}
}

View File

@@ -1,14 +1,39 @@
<!--components/searchSelect/index.wxml-->
<van-popup
show="{{ true }}"
show="{{ show }}"
bind:click="onClickHide"
position="bottom"
>
<!-- <view style="height: 100%; width: 100%; display: flex;align-items: center; justify-content: center;">
<van-picker
<view wx:if="{{type !== 'pay'}}">
<van-search
value="{{ value }}"
placeholder="请输入搜索关键词"
use-action-slot
bind:change="onChangeSearch"
>
<view
style="margin-left: 20rpx; margin-right: 20rpx"
slot="action"
bind:tap="onSearch"
>搜索</view>
</van-search>
<van-picker
custom-style="width: 100%;"
columns="{{ columns }}"
bind:change="onChange"
title="{{title}}"
show-toolbar="{{true}}"
bind:cancel="onCancel"
bind:confirm="onConfirm"
/>
</view> -->
111
</view>
<view wx:else>
<van-picker
custom-style="width: 100%;"
columns="{{ payWays }}"
title="{{title}}"
show-toolbar="{{true}}"
bind:cancel="onCancel"
bind:confirm="onPayConfirm"
/>
</view>
</van-popup>