src\libs\http.js
封装 get、post 请求
import axios from 'axios'
import qs from 'qs'import { JUHE_APPKEY } from '@/configs/keys'function axiosPost(options) {axios({url: options.url,method: 'post',header: {'Content-Type': 'application/x-www-form-urlencoded',},data: qs.stringify({...options.data,key: JUHE_APPKEY,}),}).then((res) => options.success(res.data)).catch((err) => options.error(err))
}function axiosGet(options) {axios(options.url + '&key=' + JUHE_APPKEY).then((res) => options.success(res.data)).catch((err) => options.error(err))
}export {axiosGet,axiosPost
}
src\services\request.js
封装聚合支付api请求
import { axiosPost } from '@/libs/http'
function getDayData(date) {return new Promise((resolve, reject) => {axiosPost({url: '/api/calendar/day',data: { date },success(data) {resolve(data)},error(err) {reject(err)},})})
}
function getMonthData(yearMonth) {return new Promise((resolve, reject) => {axiosPost({url: '/api/calendar/month',data: { yearMonth },success(data) {resolve(data)},error(err) {reject(err)},})})
}
function getYearData(year) {return new Promise((resolve, reject) => {axiosPost({url: '/api/calendar/year',data: { year },success(data) {resolve(data)},error(err) {reject(err)},})})
}
export { getDayData, getMonthData, getYearData }