| | |
| | | confirmBtn: { |
| | | content: '确认' |
| | | }, |
| | | errorDialogTitle: "关阀错误", |
| | | showForceConfirm: false, //是否强制开阀 |
| | | lastIntakeName: "" |
| | | }, |
| | | |
| | | openValve: function (e) { |
| | |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | //判断本地是否保存sessionId |
| | | |
| | | |
| | | // 使用 wx.nextTick 等待页面渲染完成 |
| | | wx.nextTick(() => { |
| | | this.calculateScrollViewHeight(); |
| | |
| | | }) |
| | | this.getOpenList(); |
| | | } |
| | | this.getUserDataBySession(); |
| | | this.initData(); |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | //判断本地是否保存sessionId |
| | | if (storage.isHasKeySync("sessionId")) { |
| | | storage.getItem('sessionId').then((data) => { |
| | | this.setData({ |
| | | sessionId: data |
| | | }); |
| | | if (sessionId !== "") {} |
| | | }).catch((err) => { |
| | | console.error('Failed to load parameter:', err); |
| | | }); |
| | | } else { |
| | | console.log('Failed to load parameter:false'); |
| | | } |
| | | this.getOpenList(); |
| | | |
| | | }, |
| | | |
| | | /** |
| | |
| | | }); |
| | | }, |
| | | closeDialog() { |
| | | console.log("closeDialog"); |
| | | this.setData({ |
| | | showConfirm: false, |
| | | showErrorDialog: false, |
| | | showForceConfirm: false |
| | | }); |
| | | }, |
| | | cancelDialog() { |
| | | this.setData({ |
| | | showForceConfirm: false, |
| | | showConfirm: false |
| | | }); |
| | | }, |
| | |
| | | wx.hideLoading(); |
| | | this.setData({ |
| | | showErrorDialog: true, |
| | | errorData: error.msg |
| | | errorData: error.msg, |
| | | errorDialogTitle: "关阀错误" |
| | | }) |
| | | // 处理错误响应 |
| | | console.error('请求失败:', error); |
| | |
| | | showErrorDialog: false |
| | | }) |
| | | }, |
| | | /** |
| | | * 扫码开阀 |
| | | */ |
| | | scenCode() { |
| | | const that = this; |
| | | wx.scanCode({ |
| | | success(res) { |
| | | console.log(res.result); // 当且仅当扫码为非微信二维码时,会返回result |
| | | // 如果扫码结果为URL,会自动尝试打开 |
| | | // 如果扫码结果为微信小程序的码,会直接跳转到对应的小程序页面 |
| | | // 如果扫码结果为公众号二维码,则会在手机上打开微信并跳转到对应的公众号 |
| | | if (res.result.startsWith("content://")) { |
| | | let jsonStr = res.result.replace("content://", "") |
| | | try { |
| | | |
| | | that.saveData(jsonStr) |
| | | } catch (error) { |
| | | console.error('Error parsing JSON:', error); |
| | | } |
| | | |
| | | } else { |
| | | that.postOppenValva(res.result) |
| | | } |
| | | |
| | | }, |
| | | fail(err) { |
| | | console.error(err); |
| | | } |
| | | |
| | | }) |
| | | }, |
| | | confirmForceDialog() { |
| | | console.log("confirmForceDialog"); |
| | | this.setData({ |
| | | showForceConfirm: false |
| | | }) |
| | | this.postOppenValva(this.data.lastIntakeName, true) |
| | | }, |
| | | /** |
| | | * |
| | | * @param {*} intakeName |
| | | */ |
| | | postOppenValva(intakeName, isforce) { |
| | | const that = this; |
| | | wx.showLoading({ |
| | | title: '正在开阀请稍候...', // 加载提示文字 |
| | | mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false |
| | | }); |
| | | const app = getApp(); |
| | | that.setData({ |
| | | lastIntakeName: intakeName |
| | | }) |
| | | const data = { |
| | | intakeName: intakeName, //取水口ID |
| | | // vcId: vcId, //虚拟卡ID |
| | | operator: app.globalData.sessionId, //操作员 |
| | | forceOpen: !!isforce // 使用逻辑非操作符 !! 来确保 isForce 是布尔值 |
| | | }; |
| | | post({ |
| | | url: "wx/valve/open_wx", |
| | | data: data, |
| | | timeout: 180000 |
| | | }).then(response => { |
| | | |
| | | // 处理成功响应 |
| | | console.log('请求成功:', response); |
| | | // 加载完成后隐藏加载动画 |
| | | wx.hideLoading(); |
| | | //完成后回到首页 |
| | | wx.reLaunch({ |
| | | url: '/pages/home/home?param=true' // 首页的路径,根据实际情况填写 |
| | | }); |
| | | }).catch(error => { |
| | | // 加载完成后隐藏加载动画 |
| | | wx.hideLoading(); |
| | | // 处理错误响应 |
| | | console.error('请求失败:', error); |
| | | if (error.code === "10005") { |
| | | that.setData({ |
| | | showForceConfirm: true |
| | | }) |
| | | } else { |
| | | that.setData({ |
| | | showErrorDialog: true, |
| | | errorData: error.msg, |
| | | errorDialogTitle: "开阀错误" |
| | | }) |
| | | } |
| | | }); |
| | | }, |
| | | /** |
| | | * 扫描后保存用户id和tag |
| | | */ |
| | | saveData(userData) { |
| | | storage.setItem("userData", userData).then(() => { |
| | | this.initData(); |
| | | }).catch((error) => {}); |
| | | |
| | | }, |
| | | //进入界面获取界面数据 |
| | | initData() { |
| | | const app = getApp(); |
| | | console.log("tag>>>>:" +app.globalData.tag) |
| | | |
| | | if (storage.isHasKeySync("userData")) { |
| | | storage.getItem('userData').then((data) => { |
| | | let jsonObj = JSON.parse(data); |
| | | app.globalData.sessionId = jsonObj.sessionId; |
| | | app.globalData.tag = jsonObj.tag; |
| | | this.getUserDataBySession(); |
| | | this.getOpenList(); |
| | | console.log("userData>>>>>>>" + data) |
| | | }).catch((err) => { |
| | | console.error('Failed to load parameter:', err); |
| | | }); |
| | | } else { |
| | | this.getUserDataBySession(); |
| | | this.getOpenList(); |
| | | console.log('Failed to load parameter:false'); |
| | | } |
| | | |
| | | } |
| | | }) |
| | |
| | | <text class="unbind" bind:tap="feedBack">解绑</text> |
| | | <text class="head-bottom" bind:tap="feedBack">联系客服</text> |
| | | </view> |
| | | <image class="scen-code" src="/images/scen_code.svg" bind:tap="scenCode"/> |
| | | <view class="scen-view" bind:tap="scenCode"> |
| | | <image class="scen-code" src="/images/scen_code.svg" /> |
| | | <text>扫码开阀</text> |
| | | </view> |
| | | |
| | | </view> |
| | | </view> |
| | | |
| | |
| | | </view> |
| | | </scroll-view> |
| | | |
| | | <t-dialog class="dialog" visible="{{showConfirm}}" content="确认关闭{{waterIntakeName}}吗?" confirm-btn="{{ { content: '确认', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="取消" bind:confirm="confirmDialog" bind:cancel="closeDialog" /> |
| | | <t-dialog class="error-dialog" title="关阀错误" visible="{{showErrorDialog}}" content="{{errorData}}" confirm-btn="{{ confirmBtn }}" bind:confirm="closeDialog" /> |
| | | <t-dialog class="dialog" visible="{{showConfirm}}" content="确认关闭{{waterIntakeName}}吗?" confirm-btn="{{ { content: '确认', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="取消" bind:confirm="confirmDialog" bind:cancel="cancelDialog" /> |
| | | <t-dialog class="error-dialog" title="{{errorDialogTitle}}" visible="{{showErrorDialog}}" content="{{errorData}}" confirm-btn="{{ confirmBtn }}" bind:confirm="closeDialog" /> |
| | | <t-dialog visible="{{showForceConfirm}}" content="当前虚拟卡被占用,是否强制开阀?" confirm-btn="{{ { content: '强制开阀', variant: 'base', theme: 'danger' } }}" cancel-btn="取消" bind:confirm="confirmForceDialog" bind:cancel="cancelDialog" /> |
| | | |
| | | </view> |
| | |
| | | padding-left: 25rpx; |
| | | padding-right: 25rpx; |
| | | padding-top: 15rpx; |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: center; |
| | | padding-bottom: 15rpx; |
| | | } |
| | | |
| | | .refresh-button:active{ |
| | | background-color: #7c7c7c; /* Change to a darker color when pressed */ |
| | | } |
| | | .refresh-view { |
| | | text-align: center; |
| | | padding: 30rpx; |
| | |
| | | justify-content: center; |
| | | } |
| | | |
| | | .item-button:active { |
| | | background-color: #7c7c7c; /* Change to a darker color when pressed */ |
| | | } |
| | | |
| | | .divider { |
| | | width: 100%; |
| | | margin-top: 2rpx; |
| | |
| | | } |
| | | |
| | | |
| | | .error-dialog{ |
| | | --td-dialog-title-color:red; |
| | | --td-dialog-title-font-size:40rpx; |
| | | .error-dialog { |
| | | --td-dialog-title-color: red; |
| | | --td-dialog-title-font-size: 40rpx; |
| | | } |
| | | |
| | | .scen-code{ |
| | | .scen-view { |
| | | position: absolute; |
| | | /* 添加这行 */ |
| | | top: 15rpx; |
| | | /* 根据需要调整距离顶部的距离 */ |
| | | right: 30rpx; |
| | | /* 根据需要调整距离右侧的距离 */ |
| | | display: flex; |
| | | align-items: center; |
| | | /* 垂直方向居中 */ |
| | | justify-content: space-between; |
| | | } |
| | | |
| | | .scen-code { |
| | | width: 40rpx; |
| | | height: 40rpx; |
| | | position: absolute; /* 添加这行 */ |
| | | top: 15rpx; /* 根据需要调整距离顶部的距离 */ |
| | | right: 30rpx; /* 根据需要调整距离右侧的距离 */ |
| | | } |
| | | |
| | | .scen-view text { |
| | | font-size: 30rpx; |
| | | color: #ffffff; |
| | | } |
| | |
| | | searchQuery: "", |
| | | commonWaterPoints: [], // 常用取水口数据 |
| | | allWaterPoints: [], // 所有取水口数据 |
| | | searchData: [{ |
| | | intakeNum: "1111111" |
| | | }, { |
| | | intakeNum: "2222222" |
| | | }], |
| | | isRefreshing_all: false, |
| | | isRefreshing_common: false, |
| | | showConfirm: false, |
| | |
| | | confirmBtn: { |
| | | content: '确认' |
| | | }, |
| | | showForceConfirm: false, |
| | | forceIntakeId: "", //强制开阀的取水口id |
| | | inputValue:"" |
| | | }, |
| | | |
| | | // 切换 Tabs |
| | |
| | | this.getallWaterPoints(query) |
| | | // 在这里进行搜索操作,更新 allWaterPoints 数据 |
| | | } else { |
| | | this.getallWaterPoints(query) |
| | | this.setData({ |
| | | allWaterPoints: [] |
| | | }) |
| | | } |
| | | }, |
| | | |
| | |
| | | * @param {} event |
| | | */ |
| | | choseCard(event) { |
| | | //显示二次确认弹窗 |
| | | this.setData({ |
| | | showConfirm: true, |
| | | choseItem: event.currentTarget.dataset.item |
| | | choseItem: event.currentTarget.dataset.item, |
| | | allWaterPoints: [] |
| | | }) |
| | | // console.log(intakeId); |
| | | // wx.navigateTo({ |
| | |
| | | |
| | | }, |
| | | //开泵通信 |
| | | postOpenValva(intakeId) { |
| | | /** |
| | | * |
| | | * @param {*} intakeId 取水口id |
| | | * @param {*} isforce 是否强制开阀 |
| | | */ |
| | | postOpenValva(intakeId, isforce) { |
| | | this.setData({ |
| | | inputValue:"" |
| | | }) |
| | | console.log("intakeId:" + intakeId + " isforce:" + isforce) |
| | | wx.showLoading({ |
| | | title: '正在开阀请稍候...', // 加载提示文字 |
| | | mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false |
| | |
| | | const data = { |
| | | intakeId: intakeId, //取水口ID |
| | | // vcId: vcId, //虚拟卡ID |
| | | operator: app.globalData.sessionId //操作员 |
| | | operator: app.globalData.sessionId, //操作员 |
| | | forceOpen: !!isforce // 使用逻辑非操作符 !! 来确保 isForce 是布尔值 |
| | | }; |
| | | post({ |
| | | url: "wx/valve/open_wx", |
| | |
| | | wx.hideLoading(); |
| | | // 处理错误响应 |
| | | console.error('请求失败:', error); |
| | | |
| | | this.setData({ |
| | | showErrorDialog: true, |
| | | errorData: error.msg |
| | | }) |
| | | |
| | | if (error.code === "10005") { |
| | | this.setData({ |
| | | forceIntakeId: intakeId, |
| | | showForceConfirm: true |
| | | }) |
| | | } else { |
| | | this.setData({ |
| | | showErrorDialog: true, |
| | | errorData: error.msg |
| | | }) |
| | | } |
| | | }); |
| | | }, |
| | | |
| | |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | this.getallWaterPoints(); |
| | | this.getcommonWaterPoints(); |
| | | }, |
| | | |
| | |
| | | |
| | | }, |
| | | /** |
| | | * 获取所有取水口 |
| | | *在所有取水口搜索 |
| | | */ |
| | | getallWaterPoints: function (intakeNum) { |
| | | let params = { |
| | |
| | | isRefreshing_all: false |
| | | }); |
| | | if (data.success && data.code === "0001") { |
| | | this.setData({ |
| | | allWaterPoints: data.content.obj |
| | | }); |
| | | if (!data.content) { |
| | | wx.showToast({ |
| | | title: '没有搜索到取水口', |
| | | icon: 'error', |
| | | }) |
| | | }else{ |
| | | this.setData({ |
| | | allWaterPoints:[data.content] |
| | | }); |
| | | } |
| | | |
| | | } else { |
| | | wx.showToast({ |
| | | title: data.msg, |
| | |
| | | this.setData({ |
| | | showErrorDialog: false |
| | | }) |
| | | }, |
| | | cancelDialog() { |
| | | this.setData({ |
| | | showForceConfirm: false |
| | | }); |
| | | }, |
| | | //强制开阀 |
| | | confirmForceDialog() { |
| | | this.postOpenValva(this.data.forceIntakeId, true); |
| | | }, |
| | | closeSearch(){ |
| | | this.setData({ |
| | | allWaterPoints:[], |
| | | inputValue:"" |
| | | }) |
| | | } |
| | | }) |
| | |
| | | "t-button": "tdesign-miniprogram/button/button", |
| | | "t-dialog": "tdesign-miniprogram/dialog/dialog" |
| | | }, |
| | | "navigationBarTitleText": "取水口", |
| | | "navigationBarTitleText": "常用取水口", |
| | | "navigationBarTextStyle": "white" |
| | | |
| | | } |
| | |
| | | <view class="container"> |
| | | <!-- 顶部 Tabs --> |
| | | <view class="tabs"> |
| | | <view class="tab" bindtap="switchTab" data-tab="0" id="tab0"> |
| | | 常用取水口 |
| | | <view class="indicator" wx:if="{{currentTab === 0}}"></view> |
| | | </view> |
| | | <view class="tab" bindtap="switchTab" data-tab="1" id="tab1"> |
| | | 所有取水口 |
| | | <view class="indicator" wx:if="{{currentTab === 1}}"></view> |
| | | </view> |
| | | </view> |
| | | |
| | | <!-- 常用取水口 --> |
| | | <scroll-view class="list-container" wx:if="{{currentTab === 0}}" scroll-y="true" refresher-enabled="true" refresher-threshold="50" bindrefresherrefresh="onPullDownRefresh_common" refresher-triggered="{{isRefreshing_common}}"> |
| | | <block wx:for="{{commonWaterPoints}}" wx:key="index"> |
| | | <view class="item"> |
| | | <view class="item-left"> |
| | | <text>{{item.intakeNum}}</text> |
| | | <image class="item-img" src="{{item.isOnLine ? '/images/wifi_no.svg' : '/images/wifi_off.svg'}}" /> |
| | | </view> |
| | | <text class="item-button" bindtap="choseCard" data-item="{{item}}">开阀</text> |
| | | </view> |
| | | </block> |
| | | <view wx:if="{{commonWaterPoints.length === 0}}" class="noMore-View"> |
| | | <image class="noMore-img" src="/images/no_more.svg" /> |
| | | <text class="noMore-text">没有数据</text> |
| | | </view> |
| | | </scroll-view> |
| | | |
| | | <!-- 所有取水口 --> |
| | | <view class="all-waterIntake" wx:if="{{currentTab === 1}}"> |
| | | |
| | | |
| | | |
| | | <view class="all-waterIntake" wx:if="{{currentTab === 0}}"> |
| | | <view class="search-container"> |
| | | <input class="search-input" placeholder="请输入取水口编码后点击搜索" bindinput="onInput" /> |
| | | <input class="search-input" value="{{inputValue}}" placeholder="请输入取水口编码后点击搜索" bindinput="onInput" /> |
| | | <t-button class="search-button" theme="primary" size="large" icon="search" shape="square" aria-label="搜索" bindtap="onSearch" style="background-color: #1890FF; border: none; height: 80rpx;"></t-button> |
| | | </view> |
| | | <scroll-view class="list-container" scroll-y="true" refresher-enabled="true" refresher-threshold="50" bindrefresherrefresh="onPullDownRefresh_all" refresher-triggered="{{isRefreshing_all}}"> |
| | | <view class="search-results" wx:if="{{allWaterPoints.length > 0}}" bindtap="closeSearch"> |
| | | <block wx:for="{{allWaterPoints}}" wx:key="index"> |
| | | <view class="result-item" bindtap="choseCard" data-item="{{item}}"> |
| | | <text>{{item.intakeNum}}</text> |
| | | </view> |
| | | </block> |
| | | </view> |
| | | <scroll-view class="list-container" scroll-y="true" refresher-enabled="true" refresher-threshold="50" bindrefresherrefresh="onPullDownRefresh_common" refresher-triggered="{{isRefreshing_common}}"> |
| | | <block wx:for="{{commonWaterPoints}}" wx:key="index"> |
| | | <view class="item"> |
| | | <view class="item-left"> |
| | | <text>{{item.intakeNum}}</text> |
| | |
| | | <text class="item-button" bindtap="choseCard" data-item="{{item}}">开阀</text> |
| | | </view> |
| | | </block> |
| | | <view wx:if="{{allWaterPoints.length === 0}}" class="noMore-View"> |
| | | <view wx:if="{{commonWaterPoints.length === 0}}" class="noMore-View"> |
| | | <image class="noMore-img" src="/images/no_more.svg" /> |
| | | <text class="noMore-text">没有数据</text> |
| | | </view> |
| | |
| | | <t-dialog class="dialog" visible="{{showConfirm}}" content="确认打开{{choseItem.intakeNum}}吗?" confirm-btn="{{ { content: '确认', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="取消" bind:confirm="confirmDialog" bind:cancel="closeDialog" /> |
| | | |
| | | <t-dialog class="error-dialog" title="开阀错误" visible="{{showErrorDialog}}" content="{{errorData}}" confirm-btn="{{ confirmBtn }}" bind:confirm="closeErrorDialog" /> |
| | | |
| | | <t-dialog visible="{{showForceConfirm}}" content="当前虚拟卡被占用,是否强制开阀?" confirm-btn="{{ { content: '强制开阀', variant: 'base', theme: 'danger' } }}" cancel-btn="取消" bind:confirm="confirmForceDialog" bind:cancel="cancelDialog" /> |
| | | |
| | | |
| | | </view> |
| | |
| | | align-items: center; |
| | | justify-content: center; |
| | | } |
| | | |
| | | .item-button:active { |
| | | background-color: #7c7c7c; /* Change to a darker color when pressed */ |
| | | } |
| | | .indicator { |
| | | width: 100%; |
| | | height: 3px; |
| | |
| | | .error-dialog{ |
| | | --td-dialog-title-color:red; |
| | | --td-dialog-title-font-size:45rpx; |
| | | } |
| | | |
| | | .search-results { |
| | | position: absolute; |
| | | top: 100rpx; /* 根据搜索框的高度调整 */ |
| | | left: 30rpx; |
| | | right: 30rpx; |
| | | bottom: 0; |
| | | background-color: rgba(255, 255, 255, 0.90); /* 设置白色背景 */ |
| | | z-index: 1; |
| | | overflow-y: auto; |
| | | } |
| | | |
| | | .result-item { |
| | | padding: 20rpx; |
| | | border-bottom: 1px solid #eaeaea; |
| | | } |