作者 xuyangjie

通知接口对接

// pages/18/18.js
const app = getApp()
Page({
/**
... ... @@ -37,7 +38,12 @@ Page({
vewi:'2021-05-21'
},
]
],
noticeData:[],//通知列表
noticePage:{
page:1,//商城列表页数
last_page:1,//最大页数
},
},
gotoday(){
wx.redirectTo({
... ... @@ -48,9 +54,38 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.MessageList()
},
//获取通知列表
MessageList(){
var that = this;
if(this.data.noticePage.page > this.data.noticePage.last_page){
console.log('没有更多数据')
return
}
app.post("my/MessageList", {page:this.data.noticePage.page}).then(res => {
if(res.code == 1){
var data = this.data.noticeData;
console.log(res)
res.data.data.forEach((val) => {
data.push(val)
})
var page = this.data.noticePage.page*1+1
that.setData({
noticeData:data,
noticePage:{
page:page,
last_page:res.data.last_page
}
})
}
}).catch(err => {
wx.showToast({
title: err.msg,
icon: 'none'
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
... ...
<view class="mine" wx:for="{{list}}">
<view class="mine" wx:for="{{noticeData}}" wx:key='index'>
<image src="{{item.img}}" bindtap="gotoday"></image>
<view class="rights">
<text>{{item.text}}</text>
<view>2021-05-21</view>
<text>{{item.teacher_name}}批注了作业</text>
<view>{{item.createtime}}</view>
</view>
<view class="red_spot">
<view class="red_spot" wx:if="{{item.status == 0}}">
<text>1</text>
</view>
</view>
<view class="no" wx:if="{{noticeData.length == 0}}">
<view>
<image src="../../img/img_blank.png" mode="widthFix"></image>
</view>
<view>
<text>
暂无通知
</text>
</view>
</view>
\ No newline at end of file
... ...
... ... @@ -40,4 +40,26 @@
.red_spot text{
color: #fff;
font-size: 20rpx;
}
.no>view{
display: flex;
justify-content: center;
}
.no{
position: fixed;
top: 50%;
left: 50%;
margin-left: -160rpx;
margin-top: -40%;
}
.no>view>image{
width: 320rpx;
height: 320rpx;
}
.no>view>text{
color: rgba(0,0,0,1);
font-size: 26rpx;
font-family: "PingFang SC";
letter-spacing: 0.3px;
}
\ No newline at end of file
... ...