付延余
2023-03-21 d36eb757af8867278125c6999fcaa5bdb902151c
api/publicInterface.js
@@ -4,76 +4,46 @@
// const BaseUrl = "http://192.168.3.159:9999/";
import {BaseUrl as wrBaseUrl} from '@/api/request.js'
// const BaseUrl = "http://192.168.0.120:9999"
const BaseUrl = "http://192.168.0.120:9999"
const BaseUrl = "http://192.168.3.130:9999"
// 登录
function apiLogin({
   code
}) {
   uni.showLoading({
      title: '登录中...',
   })
   return new Promise((resolve, reject) => {
      uni.request({
         url: BaseUrl + "/wrzs/wx/login",
         method: "POST",
         data: {
            code
         },
         header: {
            // "TENANT-ID": "5",
            // "Authorization": "Basic cGlnOnBpZw==",
            'Content-Type': 'application/x-www-form-urlencoded'
         },
         success: (res) => {
            uni.hideLoading();
            // console.log(res)
            resolve(res.data);
         },
         fail: (err) => {
            console.log('错误', err);
            uni.hideLoading();
            uni.showToast({
               icon: 'none',
               title: '服务器错误'
            })
         }
      })
   })
}
// function apiLogin({
//    code
// }) {
//    uni.showLoading({
//       title: '登录中...',
//    })
//    return new Promise((resolve, reject) => {
//       uni.request({
//          url: BaseUrl + "/wrzs/wx/login",
//          method: "POST",
//          data: {
//             code
//          },
//          header: {
//             // "TENANT-ID": "5",
//             // "Authorization": "Basic cGlnOnBpZw==",
//             'Content-Type': 'application/x-www-form-urlencoded'
//          },
//          success: (res) => {
//             uni.hideLoading();
//             // console.log(res)
//             resolve(res.data);
//          },
//          fail: (err) => {
//             console.log('错误', err);
//             uni.hideLoading();
//             uni.showToast({
//                icon: 'none',
//                title: '服务器错误'
//             })
//          }
//       })
//    })
// }
function apiLogin2({
   code
}) {
   uni.showLoading({
      title: '加载中...'
   })
   return new Promise((resolve, reject) => {
      uni.request({
         url: BaseUrl + "/wrzs/wx/login2",
         method: "POST",
         data: {
            code
         },
         header: {
            'Content-Type': 'application/x-www-form-urlencoded'
         },
         success: (res) => {
            uni.hideLoading();
            resolve(res.data)
         },
         fail: (err) => {
            console.log('错误', err);
            uni.hideLoading();
            uni.showToast({
               icon: 'none',
               title: '服务器错误'
            })
         }
      })
   })
}
// 注册
@@ -130,6 +100,7 @@
   })
}
// 获取token
function apiLoginPassword({
   username,
@@ -170,6 +141,45 @@
}
// 微信小程序一键登录
function apiLoginWx({
   code
}) {
   uni.showLoading({
      title: '加载中...'
   })
   return new Promise((resolve, reject) => {
      uni.request({
         url: BaseUrl + '/admin/oauth2/token',
         method: "POST",
         data: {
            grant_type:'mobile',
            mobile:`MINI@${code}`,
            code
         },
         header: {
            "Authorization": 'Basic c29jaWFsOnNvY2lhbA==', //app:app
            'content-type': 'application/x-www-form-urlencoded',
            "CLIENT_TOC": "Y",
            "isToken": "false"
         },
         success: (res) => {
            uni.hideLoading();
            resolve(res.data)
         },
         fail: (err) => {
            console.log('错误', err);
            uni.hideLoading();
            uni.showToast({
               icon: 'none',
               title: '服务器错误'
            })
         }
      })
   })
}
// 获取流程数据
// export const getProcessDataList = (params) => {
@@ -178,8 +188,8 @@
export {
   apiLogin,
   apiLogin2,
   apiLoginWx,
   apiRegister,
   apiLoginPassword
   apiLoginPassword,
   BaseUrl
}