前端
config包下
// 本地环境
const Url= 'http://本机地址:端口号/**********';
//暴露接口
export default Url;
common交互逻辑
// 引入本地环境
import Url from '../config/config.js';
//清除登录用户信息
export default {
//获取openid方法
getOpenIdSessionKey() {
var that = this;
uni.login({
provider: 'weixin',
success: (res) => {
//这里获取的是用户的code,用来换取 openid、unionid、session_key 等信息,再将信息丢给后台自己的登录业务就行了
uni.request({
url: Url + '/*****/*******',
method: 'post',
dataType: 'json',
responseType: 'text',
header: {
'content-type': 'application/json',
},
data: {
code: res.code
},
}).then((res) => {
console.log(res);
console.log(res[1].data.code);
// if (res.data.code == 200) {
// console.log("测试");
// }
})
}
})
},
/**
* 判断当前参数是否为空(空返回true,不空返回flase)
* @param {*} options 需要判空的参数
*/
fieldIsNull(options) {
if (typeof options === "undefined" || options === null