提交 a978aa7d 作者: 方治民

Merge branch 'dev' of https://gitlab.yiring.com/digital-agri/agri-app into dev

import { otherHttp } from '/@/utils/http/axios' import { otherHttp } from '/@/utils/http/axios'
import { postFormData } from '/@/utils/http/formDataRequest'
enum Api { enum Api {
zoneList = '/online/cgform/api/getData/01fd687ecb164aea914e92047e144d66', // 功能菜单数据 zoneList = '/online/cgform/api/getData/01fd687ecb164aea914e92047e144d66', // 功能菜单数据
...@@ -9,6 +10,9 @@ enum Api { ...@@ -9,6 +10,9 @@ enum Api {
commonToolsList = '/online/cgform/api/getData/3a7fbb877f304b7d83935caa454859c4', // 常用工具数据 commonToolsList = '/online/cgform/api/getData/3a7fbb877f304b7d83935caa454859c4', // 常用工具数据
getFarmBaseList = '/farmbase/getFarmBaseList', getFarmBaseList = '/farmbase/getFarmBaseList',
} }
export function queryByType(data = {}) {
return postFormData('/device/queryByType', data).then((res) => res.data)
}
/** /**
* 删除设备 * 删除设备
* @param id * @param id
......
...@@ -546,24 +546,11 @@ ...@@ -546,24 +546,11 @@
{ {
"path": "pages/device/device", "path": "pages/device/device",
"style": { "style": {
"navigationBarTitleText": "物联设备", "navigationBarTitleText": "基地设备",
"enablePullDownRefresh": false, "enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#5DB66F", "navigationBarBackgroundColor": "#5DB66F",
"navigationBarTextStyle": "white", "navigationBarTextStyle": "white",
"backgroundColorBottom": "#F2F2F2", "backgroundColorBottom": "#F2F2F2"
"app-plus": {
"titleNView": {
"buttons": [
{
"text": "+ 添加设备",
"fontSrc": "/static/uni.ttf",
"color": "#fff",
"fontSize": "26rpx",
"width": "auto"
}
]
}
}
} }
}, },
{ {
......
...@@ -286,6 +286,7 @@ ...@@ -286,6 +286,7 @@
:required="false" :required="false"
clearable clearable
trim trim
type="number"
placeholder="请输入手机号" placeholder="请输入手机号"
v-model="model.form.data.username" v-model="model.form.data.username"
name="mobile" name="mobile"
......
...@@ -15,6 +15,7 @@ import type { ToolBoxButtonHandleEvent } from '@/components/Map/Widgets/ToolBox' ...@@ -15,6 +15,7 @@ import type { ToolBoxButtonHandleEvent } from '@/components/Map/Widgets/ToolBox'
import { ToolBoxWidget, useToolBoxWidget } from '@/components/Map/Widgets/ToolBox' import { ToolBoxWidget, useToolBoxWidget } from '@/components/Map/Widgets/ToolBox'
import * as NongchangAPI from '@/api/model/nongchang' import * as NongchangAPI from '@/api/model/nongchang'
import * as farmbaseApi from '@/api/model/farmbase' import * as farmbaseApi from '@/api/model/farmbase'
import navigate from '@/utils/page/navigate'
// 页面参数 // 页面参数
const page = reactive<Page>({ const page = reactive<Page>({
...@@ -343,6 +344,9 @@ onNavigationBarButtonTap((e) => { ...@@ -343,6 +344,9 @@ onNavigationBarButtonTap((e) => {
Navigate.to(`/pages/jidiguanli/add?farmId=${model.id}`) Navigate.to(`/pages/jidiguanli/add?farmId=${model.id}`)
} }
}) })
const toDevice = (device)=>{
Navigate.to(`/pages/device/device?deviceType=${device.deviceType}&farmBaseId=`+model.farmbaseInfo?.id)
}
</script> </script>
<template> <template>
...@@ -485,16 +489,20 @@ onNavigationBarButtonTap((e) => { ...@@ -485,16 +489,20 @@ onNavigationBarButtonTap((e) => {
<view class="box-4"> <view class="box-4">
<view class="box-4-title"> <view class="box-4-title">
<view class="box-4-title-text1"><text>基地设备</text></view> <view class="box-4-title-text1"><text>基地设备</text></view>
<view class="box-4-title-text2" @click="showDialog=true"><text>+ 添加设备</text></view> <view class="box-4-title-text2" @click="showDialog = true"><text>+ 添加设备</text></view>
</view> </view>
<view class="box-4-device"> <view class="box-4-device">
<view <view
class="box-4-device-item" class="box-4-device-item"
v-for="(device, index) in model.deviceTypeCount" v-for="(device, index) in model.deviceTypeCount"
:key="index" :key="index"
@click="toDevice(device)"
> >
<view class="box-4-item-icon"> <view class="box-4-item-icon">
<image class="box-4-item-icon-image" :src="`/static/images/nongchang/device${device.deviceType}.png`" /> <image
class="box-4-item-icon-image"
:src="`/static/images/nongchang/device${device.deviceType}.png`"
/>
</view> </view>
<view class="box-4-item-content"> <view class="box-4-item-content">
<text class="box-4-item-text1">{{ device.deviceName }}</text> <text class="box-4-item-text1">{{ device.deviceName }}</text>
...@@ -506,7 +514,13 @@ onNavigationBarButtonTap((e) => { ...@@ -506,7 +514,13 @@ onNavigationBarButtonTap((e) => {
</view> </view>
</view> </view>
</view> </view>
<SaveDialog :show="showDialog" :farmId="model.id" :farmBaseId="model.farmbaseInfo?.id" @submitSuccess="getDeviceTypeCount" @close="showDialog=false"/> <SaveDialog
:show="showDialog"
:farmId="model.id"
:farmBaseId="model.farmbaseInfo?.id"
@submitSuccess="getDeviceTypeCount"
@close="showDialog = false"
/>
</view> </view>
</template> </template>
...@@ -887,8 +901,8 @@ page { ...@@ -887,8 +901,8 @@ page {
.box-4-device-item { .box-4-device-item {
width: 49%; width: 49%;
// height: 48%; // height: 48%;
height: 136rpx; height: 136rpx;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
border-radius: 24rpx; border-radius: 24rpx;
......
/**
* uni-app formdata 请求封装
* 使用 uni.request 模拟 formdata 提交
*/
import { useGlobSetting } from '/@/hooks/setting'
import { useUserStoreWithOut } from '@/store/modules/user'
interface FormDataRequestOptions {
url: string
data?: Record<string, any>
method?: 'GET' | 'POST' | 'PUT' | 'DELETE'
header?: Record<string, any>
timeout?: number
}
interface FormDataResponse<T = any> {
data: T
statusCode: number
header: Record<string, any>
errMsg: string
}
/**
* formdata 格式请求
* @param options 请求配置
* @returns Promise
*/
export function formDataRequest<T = any>(options: FormDataRequestOptions): Promise<FormDataResponse<T>> {
return new Promise((resolve, reject) => {
const { url, data = {}, method = 'POST', header = {}, timeout = 60000 } = options
// 获取全局配置
const globSetting = useGlobSetting()
const urlPrefix = globSetting.urlPrefix
const apiUrl = globSetting.apiUrl
// 获取 token
const userStore = useUserStoreWithOut()
const token = userStore.getToken
// 拼接完整 URL
const fullUrl = `${apiUrl}${urlPrefix}${url}`
// 将数据转换为 formdata 格式字符串
const formDataStr = Object.keys(data)
.map((key) => {
const value = data[key]
if (value === null || value === undefined) {
return ''
}
if (Array.isArray(value)) {
// 处理数组
return value.map((item) => `${encodeURIComponent(key)}=${encodeURIComponent(item)}`).join('&')
}
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`
})
.filter((item) => item !== '')
.join('&')
uni.request({
url: fullUrl,
method,
data: formDataStr,
header: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Access-Token': token,
...header,
},
timeout,
success: (res: any) => {
resolve({
data: res.data,
statusCode: res.statusCode,
header: res.header,
errMsg: res.errMsg,
})
},
fail: (err: any) => {
reject({
data: null,
statusCode: err.statusCode || 0,
header: err.header || {},
errMsg: err.errMsg || '请求失败',
})
},
})
})
}
/**
* POST formdata 请求
* @param url 请求地址
* @param data 请求数据
* @param header 请求头
* @returns Promise
*/
export function postFormData<T = any>(
url: string,
data?: Record<string, any>,
header?: Record<string, any>,
): Promise<FormDataResponse<T>> {
return formDataRequest<T>({
url,
data,
method: 'POST',
header,
})
}
/**
* PUT formdata 请求
* @param url 请求地址
* @param data 请求数据
* @param header 请求头
* @returns Promise
*/
export function putFormData<T = any>(
url: string,
data?: Record<string, any>,
header?: Record<string, any>,
): Promise<FormDataResponse<T>> {
return formDataRequest<T>({
url,
data,
method: 'PUT',
header,
})
}
...@@ -11,8 +11,8 @@ const PROXY_LIST: [[string, string]?] = [ ...@@ -11,8 +11,8 @@ const PROXY_LIST: [[string, string]?] = [
// [`http://192.168.0.100:18100`, `https://oss.beta.app.yiring.com`], // [`http://192.168.0.100:18100`, `https://oss.beta.app.yiring.com`],
// 开发环境(预览) // 开发环境(预览)
// [`http://192.168.0.156:18100`, `http://111.22.182.169:49091`], [`http://192.168.0.156:18100`, `http://111.22.182.169:49091`],
[`http://192.168.0.156:18100`, `http://36.133.16.81:42111`], // [`http://192.168.0.156:18100`, `http://36.133.16.81:42111`],
] ]
/** /**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论