diff --git a/pages/contact/index.js b/pages/contact/index.js
index 90c9476..391d0e1 100644
--- a/pages/contact/index.js
+++ b/pages/contact/index.js
@@ -56,7 +56,7 @@ Page({
getMessages() {
const userInfo = wx.getStorageSync('user_info');
const that = this;
- request('app/messages', 'get', {
+ return request('app/messages', 'get', {
app_id: that.data.appid,
user_id: userInfo.openid,
page: that.data.page,
@@ -74,7 +74,9 @@ Page({
// only auto-scroll if user is at bottom
scrollToId: that.data.isAtBottom ? (sortedList[sortedList.length - 1] ? sortedList[sortedList.length - 1].id : '') : that.data.scrollToId
});
- })
+
+ return res; // 返回结果以支持链式调用
+ });
},
// Load older messages (previous pages) and prepend them to the top
@@ -476,8 +478,11 @@ Page({
},
onShow() {
- // resume polling when page becomes visible
+ // resume polling when page becomes visible and get latest messages
if (wx.getStorageSync('user_info')) {
+ // 立即请求最新消息
+ this.getMessages();
+ // 然后开始轮询
this.startPolling();
}
},
@@ -489,7 +494,19 @@ Page({
// cleanup
this.stopPolling();
},
- onPullDownRefresh() { },
+ onPullDownRefresh() {
+ // 下拉刷新时获取最新消息
+ if (wx.getStorageSync('user_info')) {
+ this.getMessages().then(() => {
+ // 停止下拉刷新动画
+ wx.stopPullDownRefresh();
+ }).catch(() => {
+ wx.stopPullDownRefresh();
+ });
+ } else {
+ wx.stopPullDownRefresh();
+ }
+ },
onReachBottom() { },
onShareAppMessage() { }
});
\ No newline at end of file
diff --git a/pages/contact/index.json b/pages/contact/index.json
index fd86421..fb13c82 100644
--- a/pages/contact/index.json
+++ b/pages/contact/index.json
@@ -1,5 +1,6 @@
{
"usingComponents": {},
- "navigationBarTitleText": "联系客服"
-
+ "navigationBarTitleText": "联系客服",
+ "enablePullDownRefresh": true,
+ "backgroundColor": "#fafbfc"
}
\ No newline at end of file
diff --git a/pages/contact/index.wxml b/pages/contact/index.wxml
index 8a4d1d1..75caa3c 100644
--- a/pages/contact/index.wxml
+++ b/pages/contact/index.wxml
@@ -6,7 +6,7 @@
-->
-
+