| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- import request from '@/utils/request/index.js'
- import config from '@/config/config.js'
- import cache from '@/utils/cache'
- import {
- LOGIN_TOKEN
- } from '@/config/cache'
- /**
- * 病害监测模块
- */
- // 识别基类 (uni.request 对formData数据不支持,暂时先写成独立的基类,后期遇到好的方案可改进)
- export const baseDiscern = (url, img_file) => {
- uni.r
- return new Promise((resolve, reject) => {
- uni.uploadFile({
- url: config.baseUrl +
- 'api/api_gateway?method=pest.pests.' + url, //仅为示例,非真实的接口地址
- formData: {
- 'img_file': img_file,
- token: cache.get(LOGIN_TOKEN)
- },
- success: (uploadFileRes) => {
- resolve(uploadFileRes.data);
- }
- });
- })
- }
- // 病虫害库
- export const loadPestList = (data) => async (data) => {
- const res = await request.post(`api/api_gateway?method=pest.pests.pests_info`, data);
- return res?.data;
- }
- // 虫害识别
- export const handleInsectDiscern = (img_file) => baseDiscern('insect_discern', img_file);
- // 病害识别
- export const handlePlantDiscern = (img_file) => baseDiscern('plant_discern', img_file);
|