Commit f5d28e71 authored by 俞嘉婷's avatar 俞嘉婷

feat: 接口失败toast处理

parent eab38489
...@@ -96,9 +96,15 @@ ComponentWithStore({ ...@@ -96,9 +96,15 @@ ComponentWithStore({
clickSubscribe: _asyncThrottle(async function () { clickSubscribe: _asyncThrottle(async function () {
console.log('clickSubscribe', this) console.log('clickSubscribe', this)
store.doLog(508, 3) store.doLog(508, 3)
await request({ const { success, message } = await request({
url: API_PATH.subscribe, url: API_PATH.subscribe,
}); });
if (!success) {
wx.showToast({
title: message,
icon: 'none',
});
}
await this.updateHomeInfo(); await this.updateHomeInfo();
}), }),
......
...@@ -32,12 +32,18 @@ class Store { ...@@ -32,12 +32,18 @@ class Store {
// title: '加载中', // title: '加载中',
// mask: true, // mask: true,
// }); // });
const { success, data } = await request({ const { success, data, message } = await request({
url: API_PATH.index, url: API_PATH.index,
data: params, data: params,
}); });
if (!success) return; if (!success) {
wx.showToast({
title: message,
icon: 'none',
});
return;
}
this.homeInfo = data; this.homeInfo = data;
} }
...@@ -53,7 +59,7 @@ class Store { ...@@ -53,7 +59,7 @@ class Store {
// title: '加载中', // title: '加载中',
// mask: true, // mask: true,
// }); // });
const { success, data } = await request({ const { success, data, message } = await request({
url: API_PATH.activity, url: API_PATH.activity,
data: { data: {
channel: this.paramsObj.channel, channel: this.paramsObj.channel,
...@@ -61,7 +67,13 @@ class Store { ...@@ -61,7 +67,13 @@ class Store {
}, },
}); });
if (!success) return; if (!success) {
wx.showToast({
title: message,
icon: 'none',
});
return;
}
this.activityInfo = data; this.activityInfo = data;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment