feedbacklist.js 4.97 KB
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
// pages/messageNotification/message.js

// 网络请求工具类
var networkUtil = require('../../../utils/network_util.js')
var api = require('../../../utils/apiFile.js')
Page({

/**
* 页面的初始数据
*/
data: {
notificationList:[], // 消息通知列表
currentPage: 1, // 当前页码
limit: 10, // 每页显示的数据条数
hasMoreData: true, // 是否有更多数据可加载
babyId:null,
formattedDate:null
},

//获取消息通知
getNotificationList:function(){
},
formatDate(milliseconds) {
// 创建 Date 对象
const date = new Date(milliseconds);
// 格式化日期和时间
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份是从0开始的
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
// 拼接成 YYYY-MM-DD HH:MM:SS 格式
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
} ,
// 下拉加载
loadMore:function(){
const self = this;
if (!self.data.hasMoreData) {
return; // 如果没有更多数据,不执行任何操作
}
// 使用 setData 更新页面状态为正在加载
self.setData({
isLoading: true
});
networkUtil._get(api.getfeedback, {
page: self.data.currentPage,
limit: self.data.limit,
babyId:self.data.babyId,
}, function(res) {
if (res.data && res.data.data.length > 0) {
let newData = self.data.notificationList.concat(res.data.data);
newData.forEach((item,index)=>{
if(item.created){
newData[index].createdstr=self.formatDate(item.created)
}
})
self.setData({
notificationList: newData,
currentPage: self.data.currentPage + 1,
isLoading: false
});
// 判断是否还有更多数据
const hasMoreData = res.data.pageInfo.page < res.data.pageInfo.lastPage
// 更新页面数据(假设你在微信小程序或其他使用setData方法的框架中)
self.setData({
hasMoreData: hasMoreData
});

wx.hideToast();
} else {
// 如果没有返回数据,表示没有更多数据了
self.setData({
hasMoreData: false,
isLoading: false
});
}
}, function(res) {
networkUtil.showErrorToast(res.errormsg);
wx.hideToast();
});
},

// 跳转
messageBtn:function(e){
const id = e.currentTarget.dataset.index
const str=e.currentTarget.dataset.item
if(id){
wx.setStorageSync('feedxq', JSON.stringify(str))
setTimeout(() =>{
wx.navigateTo({
url: `/packageA/pages/feedbackxq/feedbackxq?id=${id}`,
})
},100)
} else {
return
}
},
// 快速预约课程
goAddQuestion: function(e) {
networkUtil.showLoading();
var self = this;
wx.showModal({
title: '提示',
confirmText: '线上',
content:`您目前是要线上预约还是现场预约?`,
cancelText: '现场',
success(res) {
if (res.confirm) {
var param = { courseId: e.target.dataset.id, type: 1 };
networkUtil._get(api.orderCourse, param, function(res) {
if (res.data.errorcode == 0) {
networkUtil.showToast('预约成功');
self.loadMore();
}
},
function(res) {
networkUtil.showErrorToast(res.errormsg);
wx.hideToast();
});
} else if (res.cancel) {
var param = { courseId: e.target.dataset.id, type: 2 };
networkUtil._get(api.orderCourse, param, function(res) {
// console.log(ress,'res');
if (res.data.errorcode == 0) {
networkUtil.showToast('预约成功');
self.loadMore();
}
}
, function(res) {
networkUtil.showErrorToast(res.errormsg);
wx.hideToast();
}
);
}
}
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
networkUtil.showLoading()
console.log('options',options);
this.setData({
babyId:options.id
})
},

/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {

},

/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.loadMore()
},

/**
* 生命周期函数--监听页面隐藏
*/
onHide() {

},

/**
* 生命周期函数--监听页面卸载
*/
onUnload() {

},

/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {

},

/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {

},

/**
* 用户点击右上角分享
*/
onShareAppMessage() {

}
})