Skip to content

Commit 239a374

Browse files
committed
域名到期了,现在请求接口换成ip了
1 parent 611e758 commit 239a374

File tree

1 file changed

+28
-38
lines changed

1 file changed

+28
-38
lines changed

src/utils/index.js

+28-38
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,67 @@
11
function formatNumber(n) {
2-
const str = n.toString()
3-
return str[1] ? str : `0${str}`
2+
const str = n.toString();
3+
return str[1] ? str : `0${str}`;
44
}
55

66
export function formatTime(date) {
7-
const year = date.getFullYear()
8-
const month = date.getMonth() + 1
9-
const day = date.getDate()
7+
const year = date.getFullYear();
8+
const month = date.getMonth() + 1;
9+
const day = date.getDate();
1010

11-
const hour = date.getHours()
12-
const minute = date.getMinutes()
13-
const second = date.getSeconds()
11+
const hour = date.getHours();
12+
const minute = date.getMinutes();
13+
const second = date.getSeconds();
1414

15-
const t1 = [year, month, day].map(formatNumber).join('/')
16-
const t2 = [hour, minute, second].map(formatNumber).join(':')
15+
const t1 = [year, month, day].map(formatNumber).join("/");
16+
const t2 = [hour, minute, second].map(formatNumber).join(":");
1717

18-
return `${t1} ${t2}`
18+
return `${t1} ${t2}`;
1919
}
2020

21-
2221
//-------------------------------------------------------------------------请求的封装
2322

24-
const host = 'https://www.heyuhsuo.xyz/heyushuo';
25-
export {
26-
host
27-
}
23+
const host = "http://118.25.222.68:5757/heyushuo";
24+
export { host };
2825
//请求封装
2926
function request(url, method, data, header = {}) {
3027
wx.showLoading({
31-
title: '加载中' //数据请求前loading
32-
})
28+
title: "加载中" //数据请求前loading
29+
});
3330
return new Promise((resolve, reject) => {
3431
wx.request({
3532
url: host + url, //仅为示例,并非真实的接口地址
3633
method: method,
3734
data: data,
3835
header: {
39-
'content-type': 'application/json' // 默认值
36+
"content-type": "application/json" // 默认值
4037
},
41-
success: function (res) {
38+
success: function(res) {
4239
wx.hideLoading();
43-
resolve(res.data)
40+
resolve(res.data);
4441
},
45-
fail: function (error) {
42+
fail: function(error) {
4643
wx.hideLoading();
47-
reject(false)
44+
reject(false);
4845
},
49-
complete: function () {
46+
complete: function() {
5047
wx.hideLoading();
5148
}
52-
})
53-
})
49+
});
50+
});
5451
}
5552
export function get(url, data) {
56-
return request(url, 'GET', data)
53+
return request(url, "GET", data);
5754
}
5855
export function post(url, data) {
59-
return request(url, 'POST', data)
56+
return request(url, "POST", data);
6057
}
6158

6259
//-------------------------------------------------------------------------请求的封装
6360

64-
6561
//----------------------------------------------用户是否登录 未登录跳转到登录页面 -------------------------
6662

67-
6863
export function toLogin() {
69-
const userInfo = wx.getStorageSync('userInfo');
64+
const userInfo = wx.getStorageSync("userInfo");
7065
if (!userInfo) {
7166
wx.navigateTo({
7267
url: "/pages/login/main"
@@ -77,27 +72,23 @@ export function toLogin() {
7772
}
7873

7974
export function login() {
80-
const userInfo = wx.getStorageSync('userInfo');
75+
const userInfo = wx.getStorageSync("userInfo");
8176
if (userInfo) {
8277
return userInfo;
8378
}
8479
}
8580

8681
//----------------------------------------------用户是否登录 未登录跳转到登录页面 -------------------------
8782

88-
8983
export function getStorageOpenid() {
9084
const openId = wx.getStorageSync("openId");
9185
if (openId) {
9286
return openId;
9387
} else {
94-
return ''
88+
return "";
9589
}
9690
}
9791

98-
99-
100-
10192
export function getOpenid() {
10293
// wx.login({
10394
// success: res => {
@@ -119,7 +110,6 @@ export function getOpenid() {
119110
// } else {
120111
// console.log('登录失败!' + res.errMsg)
121112
// }
122-
123113
// },
124114
// fail: () => {},
125115
// complete: () => {}

0 commit comments

Comments
 (0)