12345678910111213141516171819202122232425262728 |
- import settings from '@/settings.js'
- export const myRequest = (options)=>{
- return new Promise((resolve, reject)=>{
- uni.request({
- url:settings.base_url + "/" + settings.prefix + options.url,
- method: options.method || 'GET',
- data: options.data || {},
- success: (res)=>{
- if(res.statusCode !== 200) {
- uni.showToast({
- icon:"error",
- title: '拉取数据失败'
- })
- reject()
- }
- resolve(res.data)
- },
- fail: (err)=>{
- uni.showToast({
- icon:"error",
- title: err.errMsg
- })
- reject(err)
- }
- })
- })
- }
|