1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- const baseUrl="http://api.admin.app.cliu.cc/api";
- const request=function(url,dataPraams,method="POST"){
-
- url=baseUrl+url;
-
- // 显示loading
- uni.showLoading({
- title: '加载中'
- });
-
- return new Promise((resolve,reject)=>{
- uni.request({
- url,
- method,
- data:dataPraams,
- success:function(res){
- uni.hideLoading();
- const {data}=res
- const { code, msg}=data
- if(code===200){
- resolve(data)
- } else {
- resolve(data)
- }
- },
- fail:function(err){
- console.log(11,err)
- uni.hideLoading();
- uni.showToast({
- title:"网络加载失败",
- icon:"none",
- duration: 3500
- })
- reject(err)
- }
- })
- })
-
- }
- export default request;
|