| | |
| | | </view> |
| | | <uni-popup ref="qushuiDialog" type="dialog"> |
| | | <uni-popup-dialog type="info" cancelText="取消" confirmText="确认" title="请输入取水量" |
| | | before-close="true" |
| | | @confirm="dialogConfirm" |
| | | @close="dialogClose" |
| | | > |
| | | <view> |
| | | <input v-model="qushuiNum" placeholder="请输入取水量(L)" /> |
| | | <input v-model="qushuiNum" type="number" placeholder="请输入取水量(L)" /> |
| | | </view> |
| | | </uni-popup-dialog> |
| | | </uni-popup> |
| | |
| | | <script setup> |
| | | import{ ref, onMounted } from 'vue' |
| | | import Navbar from '../../components/navbar/navbar.vue' |
| | | import { getFacitily } from '@/api/index.js' |
| | | import { getFacitily, getWater } from '@/api/index.js' |
| | | import { BASE_URL } from '../../config/index.js' |
| | | |
| | | const userLocation = ref() |
| | | const facitilyList = ref([]) |
| | | const qushuiDialog = ref() |
| | | const facitilyId = ref() |
| | | const facilityId = ref() |
| | | const qushuiNum = ref() |
| | | |
| | | const getFacitilyList = () => { |
| | |
| | | |
| | | // 取水 |
| | | const handleQushui = (id) => { |
| | | facitilyId.value = id |
| | | facilityId.value = id |
| | | qushuiDialog.value.open() |
| | | } |
| | | |
| | | // 取消 |
| | | const dialogClose = () => { |
| | | facitilyId.value = '' |
| | | facilityId.value = '' |
| | | qushuiNum.value = '' |
| | | qushuiDialog.value.close() |
| | | } |
| | | |
| | | // 确认 |
| | | const dialogConfirm = () => { |
| | | |
| | | if(!qushuiNum.value) { |
| | | uni.showToast({ |
| | | title:'请输入取水量', |
| | | icon:'none' |
| | | }) |
| | | return |
| | | } |
| | | const data = { |
| | | facilityId: facilityId.value, |
| | | amount: Number(qushuiNum.value) |
| | | } |
| | | getWater(data).then(res => { |
| | | if(res.code === 200) { |
| | | uni.showToast({ |
| | | title:res.data, |
| | | icon:'success' |
| | | }) |
| | | dialogClose() |
| | | }else{ |
| | | uni.showToast({ |
| | | title:res.msg, |
| | | icon:'error' |
| | | }) |
| | | } |
| | | }).catch(err => { |
| | | uni.showToast({ |
| | | title:'指令发送失败,请稍后重试', |
| | | icon:'error' |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | //打开地图导航 |
| | |
| | | lon: res.longitude |
| | | } |
| | | uni.setStorageSync('userLocation',JSON.stringify(userLocation.value)) |
| | | getFacitilyList() |
| | | }, |
| | | fail:(err) =>{ |
| | | locationToast() |
| | |
| | | const locationToast = () => { |
| | | uni.showModal({ |
| | | title: "请求授权当前位置", |
| | | content: "请求获取您的位置,加载附近饮水设备信息!", |
| | | content: "请求获取您的位置,加载附近取水设备信息!", |
| | | confirmText: "前往设置", |
| | | success: (res) => { |
| | | if (res.confirm) { |