web
2025-07-08 a1aca8be99e62ea683fd8d7db82d7a480f5d0305
feat:增加取水能力
已修改5个文件
70 ■■■■ 文件已修改
api/index.js 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
manifest.json 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/device/index.vue 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/index/index.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/user/index.vue 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/index.js
@@ -38,4 +38,9 @@
// 充值记录
export function getrechargeRecord(data) {
    return request('/api/user/searchRechargeRecords', data, 'POST')
}
// 取水
export function getWater(data) {
    return request('/api/user/userWaterInTaking', data, 'POST')
}
manifest.json
@@ -59,11 +59,11 @@
            "enable" : false
        },
        "lazyCodeLoading" : "requiredComponents",
        "permission" : {
            "scope.userLocation" : {
                "desc" : "你的位置信息将用于计算设备与您的距离"
            }
        }
        "permission" : {
            "scope.userLocation" : {
                "desc" : "你的位置信息将用于计算设备与您的距离"
            }
        }
    },
    "vueVersion" : "3"
}
pages/device/index.vue
@@ -28,11 +28,12 @@
        </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>
@@ -42,13 +43,13 @@
<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 = () => {
@@ -67,19 +68,49 @@
    
    // 取水
    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'
            })
        })
    }
    
    //打开地图导航
@@ -102,6 +133,7 @@
                    lon: res.longitude
                }
                uni.setStorageSync('userLocation',JSON.stringify(userLocation.value))
                getFacitilyList()
            },
            fail:(err) =>{
                locationToast()
@@ -112,7 +144,7 @@
    const locationToast = () => {
        uni.showModal({
            title: "请求授权当前位置",
            content: "请求获取您的位置,加载附近饮水设备信息!",
            content: "请求获取您的位置,加载附近取水设备信息!",
            confirmText: "前往设置",
            success: (res) => {
                if (res.confirm) {
pages/index/index.vue
@@ -109,7 +109,7 @@
    const locationToast = () => {
        uni.showModal({
            title: "请求授权当前位置",
            content: "请求获取您的位置,加载附近饮水设备信息!",
            content: "请求获取您的位置,加载附近取水设备信息!",
            confirmText: "前往设置",
            success: (res) => {
                if (res.confirm) {
pages/user/index.vue
@@ -32,6 +32,7 @@
<script setup>
    import { onMounted, ref } from "vue";
    import { onShow } from "@dcloudio/uni-app"
    
    const topHeight = ref(0)
    const userInfo = ref()
@@ -66,9 +67,12 @@
        })
    }
    
    onShow(() => {
        userInfo.value = JSON.parse(uni.getStorageSync('userInfo'))
    })
    onMounted(() => {
        getTopHeight()
        userInfo.value = JSON.parse(uni.getStorageSync('userInfo'))
    })
</script>
@@ -84,6 +88,7 @@
                height: 80rpx;
                image{
                    width: 100%;
                    height: 100%;
                    border-radius: 50%;
                }
            }