From 4ecf443f896f45e52646a44fd3f5df1cdf66b29d Mon Sep 17 00:00:00 2001 From: qiaomu <3520484422@qq.com> Date: Tue, 24 Dec 2024 17:33:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=89=8B=E5=8A=A8=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/searchSelect/index.js | 18 +++++++++++-- pages/handleLogin/index.js | 44 ++++++++++++++++++++++++++++++++ pages/handleLogin/index.json | 1 + pages/handleLogin/index.wxml | 40 +++++++++++++++++++++++++++-- project.private.config.json | 7 +++++ utils/index.js | 13 ++-------- 6 files changed, 108 insertions(+), 15 deletions(-) diff --git a/components/searchSelect/index.js b/components/searchSelect/index.js index aef7a6e..0aed2d8 100644 --- a/components/searchSelect/index.js +++ b/components/searchSelect/index.js @@ -3,7 +3,7 @@ import { getParkSimpleMeterList } from "../../service/meter" import { alertInfo } from "../../utils/index"; import request from "../../utils/request" import { payWays } from "../../utils/data"; - +import { getTenementList } from "../../service/tenement"; const { OK } = request; // components/searchSelect/index.js @@ -86,6 +86,8 @@ Component({ return; case "meter": this.onSearchMeter(); + case "tenement": + this.onSearchTenement(); return; } }, @@ -112,6 +114,18 @@ Component({ columns: parks?.map(item => `${item.meterNo}-${item.address}${item.shortName ? '-' + item.shortName : ''}`), list: parks, }) - } + }, + async onSearchTenement() { + const { searchText = "", park } = this.data; + const { code, message, data = [] } = await getTenementList({keyword: searchText, park}); + if (code !== OK) { + alertInfo(message) + return + } + this.setData({ + columns: data?.map(item => item?.name), + list: data, + }) + }, } }) \ No newline at end of file diff --git a/pages/handleLogin/index.js b/pages/handleLogin/index.js index 42d0a09..0005692 100644 --- a/pages/handleLogin/index.js +++ b/pages/handleLogin/index.js @@ -93,6 +93,25 @@ Page({ }) }) }, + onParkFocus(e) { + this.setData({ + show: true, + title: "园区", + type: 'park' + }) + }, + onTenementFocus(e) { + const { park } = this.data; + if (!park) { + alertInfo("请先选择园区") + return; + } + this.setData({ + show: true, + title: "公司", + type: 'tenement' + }) + }, scan() { wx.scanCode({ scanType: "qrCode", @@ -108,4 +127,29 @@ Page({ } }) }, + onConfirm(e) { + console.log('e', e.detail) + const { type, data = {} } = e.detail; + switch(type) { + case "park": + this.setData({ + park: data.id, + parkName: data.name, + }) + break; + case "tenement": + this.setData({ + tenement: data.id, + tenementName: data.name, + }) + } + this.onConcal(); + }, + onConcal() { + this.setData({ + show: false, + title: "", + type: "", + }) + }, }) \ No newline at end of file diff --git a/pages/handleLogin/index.json b/pages/handleLogin/index.json index 6d40fc3..c29853f 100644 --- a/pages/handleLogin/index.json +++ b/pages/handleLogin/index.json @@ -2,6 +2,7 @@ "usingComponents": { "topbar": "/components/topbar/index", "select": "/components/select/index", + "search-select": "/components/searchSelect/index", "van-button": "@vant/weapp/button/index", "van-field": "@vant/weapp/field/index", "van-icon": "@vant/weapp/icon/index", diff --git a/pages/handleLogin/index.wxml b/pages/handleLogin/index.wxml index d23c8a9..01adc43 100644 --- a/pages/handleLogin/index.wxml +++ b/pages/handleLogin/index.wxml @@ -17,8 +17,34 @@ - + + + + 选择 + + + + + 选择 + + + + + diff --git a/project.private.config.json b/project.private.config.json index fadfe0b..5d56456 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -10,6 +10,13 @@ "condition": { "miniprogram": { "list": [ + { + "name": "pages/handleLogin/index", + "pathName": "pages/handleLogin/index", + "query": "", + "launchMode": "default", + "scene": null + }, { "name": "pages/ticket/index", "pathName": "pages/ticket/index", diff --git a/utils/index.js b/utils/index.js index 5faab9f..26de1e0 100644 --- a/utils/index.js +++ b/utils/index.js @@ -225,17 +225,8 @@ export const wxModal = (data) => { } -export const getPixelRatio = () => { - let pixelRatio = 0 - wx.getSystemInfo({ - success: function (res) { - pixelRatio = res.pixelRatio - }, - fail: function () { - pixelRatio = 0 - } - }) - return pixelRatio +export const getPixelRatio = () => { + return wx.getSystemInfoSync()?. pixelRatio }