export var dd = "asdfsadfasdf";
export class request{
static request(url, data, method = 'GET') {
url = "http://hr.jifen.com" + url
let header = {
'content-type': 'application/json', // 默认值
'Cookie': wx.getStorageSync('sessionkey')
};
let token = wx.getStorageSync('token') || '';
if (token) {
header['X-ECAPI-Authorization'] = token
}
return new Promise(function (resolve, reject) {
wx.request({
url: url,
method: method,
data: data,
header: header,
success: function (res) {
if (res.data.code === 1) {
if (!wx.getStorageSync('sessionkey')) {
wx.setStorageSync('sessionkey', res.header['Set-Cookie']);//保存Cookie到Storage
}
// if (res.header &&
uni-app 小程序 vue 服务器请求封装
最新推荐文章于 2024-10-16 10:40:00 发布
本文介绍如何在uni-app中,结合vue,进行全局服务器请求的封装。通过在main.js中引入并配置,实现uni-app小程序的便捷网络请求。
摘要由CSDN通过智能技术生成