You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
xzjl-ui/pages/home/xx/hy/hx/hx.js

152 lines
3.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// pages/home/xx/hy/index.js
const app = getApp();//新建页面时 默认引入
const req = app.xzjlReq();//初始化一个的request() 实例
Page({
/**
* 页面的初始数据
*/
data: {
visible:false,
image: []
},
go2Reback(){
wx.navigateTo({
url: '/pages/home/xx/hy/yx/yx'
})
},
go2Xz(){
wx.navigateTo({
url: '/pages/home/xx/hy/index'
})
},
go2Yx(){
wx.navigateTo({
url: '/pages/home/xx/hy/yx/yx'
})
},
go2Hx(){
wx.navigateTo({
url: '/pages/home/xx/hy/hx/hx'
})
},
go2Zt(){
wx.navigateTo({
url: '/pages/home/xx/hy/zt/zt'
})
},
blockClick(e){
console.log(e.target.dataset.url);
this.setData({
visible: true,
image: [e.target.dataset.url]
})
},
onClose(){
this.setData({visible: false})
},
delBtn(e){
console.log(this.data.image);
const regex = /\d+/;
const matchResult = this.data.image.match(regex);
const number = matchResult[0];
console.log(number); // 输出254
req.deleteRequest(`/api/user/curt/message/${number}`,{}).then(res => {
console.log(res,'删除成功');
})
},
closeViewer(){this.setData({visible: false})},
getList(){
req.getRequest('/api/user/curt/message/lover',{
limit:-1,
type: 'graphic'
}).then(res => {
const list = res.data.data.records
list.forEach(item => {
// 将时间字符串转为Date对象
const date = new Date(item.createdAt);
// 获取年月日时分秒
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
// 格式化时间
const formattedDate = `${year}${month}${day}`;
item.createdAt = formattedDate
})
console.log(list);
const treeData = list.reduce((result, item) => {
const group = result.find(group => group.createdAt === item.createdAt);
if (group) {
// group.list.push(item.resourceId);
group.list.push(`https://xzjl-api.windymuse.cn/api/resource/${item.resourceId}?k=${item.fromUserid}`);
} else {
result.push({
createdAt: item.createdAt,
list: [`https://xzjl-api.windymuse.cn/api/resource/${item.resourceId}?k=${item.fromUserid}`]
});
}
return result;
}, []);
console.log(treeData);
this.setData({list: treeData})
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getList()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})