1.封装方法 并且注册给微信
import {base_url} from '../config/conster'
export let $request=function(url,data={},method='GET'){
return new Promise(resolve=>{
wx.request({
url:base_url+url,
data,
method,
success:({data})=>{
resolve(data)
}
})
})
}
export let $get= function(url, data={}, ){
return $request(url, data ,'GET')
}
export let $post= function(url, data={}){
return $request(url, data ,'POST')
}
wx.$request=$request
wx.$get=$get
wx.$post=$post