1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
| import ajax from './ajax' import jsonp from 'jsonp' import {message} from 'antd'
const BASE = ''
export const reqLogin=(username,password)=>ajax(BASE+'login',{username,password},'POST')
export const reqCategorys=(parentId)=>ajax(BASE+'/manage/category/list',{parentId})
export const reqAddCategory=(parentId,categoryName)=>ajax(BASE+'/manage/category/add',{parentId,categoryName},'POST')
export const reqUpdateCategory=({categoryId,categoryName})=>ajax(BASE+'/manage/category/update',{categoryId,categoryName},'POST')
export const reqCategory = (categoryId) => ajax(BASE + '/manage/category/info', {categoryId})
export const reqProducts=(pageNum,pageSize)=>ajax(BASE+'/manage/product/list',{pageNum,pageSize})
export const reqUpdateStatus=(productId,status)=>ajax(BASE+'/manage/product/updateStatus',{productId,status},'POST')
export const reqSearchProducts = ({pageNum, pageSize, searchName, searchType}) => ajax(BASE + '/manage/product/search', { pageNum, pageSize, [searchType]: searchName, })
export const reqAddUpdatePro=(product)=>ajax(BASE+'/manage/product/'+(product._id?'update':'add'),product,'POST')
export const reqDeletPic=(name)=>ajax(BASE+'/manage/img/delete',{name},'POST')
export const reqRoles=()=>ajax(BASE+'/manage/role/list')
export const reqAddRole=(roleName)=>ajax(BASE+'/manage/role/add',{roleName},'POST')
export const reqUpdateRole=(role)=>ajax(BASE+'/manage/role/update',role,'POST')
export const reqWeather=(city) => { const url = `http://api.map.baidu.com/telematics/v3/weather?location=${city}&output=json&ak=3p49MVra6urFRGOT9s8UBWr2` return new Promise((resolve,reject) => { jsonp(url,{},(err,data) => { console.log('jsonp()', err, data) if(!err && data.status==='success'){ const {dayPictureUrl,weather}=data.results[0].weather_data[0] resolve({dayPictureUrl,weather}) }else{ message.error('天气信息获取失败') } }) }) }
|