赞
踩
- // 封装ajax
- import config from './config'; //基础配置,服务器配置
- export default (url, data={}, method='GET') => {
- console.log(wx.getStorageSync('cookies'))
- return new Promise((resolve, reject) => {
- wx.request({
- url: config.host + url,
- data,
- method,
- header: {
- cookie: wx.getStorageSync('cookies')? wx.getStorageSync('cookies').find(item => item.indexOf('MUSIC_U') !== '-1'): ''
- },
- success: (res) => {
- // console.log(res)
- if(data.isLogin){ //登录接口
- //cookies存储到本地
- wx.setStorageSync('cookies', res.cookies);
- }
- resolve(res.data);
- },
- fail: (err) => {
- reject(err);
- }
- })
- })
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。