123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- import { commonConfig } from '../common/config'
- export default {
- async post(url, param,yanci=true) {
-
-
-
-
-
-
-
-
- const res = await this.uni_request(url,param,'post')
-
-
-
-
-
- return res;
- },
- async get(url, param,yanci=true) {
-
-
-
-
-
-
-
-
- const res = await this.uni_request(url,param,'get')
-
-
-
-
-
- return res;
- },
- async put(url, param) {
- const res = await this.uni_request(url,param,'put')
- return res;
- },
- async delete(url, param) {
- const res = await this.uni_request(url,param,'delete')
- return res;
- },
- uni_request(url,param,method,again_quest=true) {
- const that = this
- return new Promise((cback, reject) => {
- uni.request({
- url: commonConfig.baseUrl + url,
- data: param,
- method:method,
- header: {
- accessToken:uni.getStorageSync("token")
- },
- }).then(data => {
- var [error, res] = data;
- cback(res.data);
- var res_code = res.statusCode.toString();
- let errCode = res.data?.retHead?.errCode;
- if (res_code.charAt(0) == 2) {
- if(res_code==200){
-
- cback(res.data);
- }else{
- console.log('201',url)
- uni.showToast({
- title:res.data.retHead.errMsg,
- icon:'none'
- })
- }
- };
- if(errCode==401||errCode==405){
- uni.showToast({
- title:res.data.retHead.errMsg,
- icon:'none',
- duration: 12000,
- complete:function(){
- window.location.replace(config.loginUrl)
- }
- })
-
- };
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if(data[1].data.retHead.errCode&&data[1].data.retHead.errCode!='0'&&data[1].data.retHead.errMsg){
- uni.showToast({
- title:data[1].data.retHead.errMsg,
- icon:'none'
- });
- };
- }).catch(err => {
- console.log('catch:',err);
- })
- })
- },
- }
|