|
@@ -8,7 +8,7 @@ Page({
|
|
* 页面的初始数据
|
|
* 页面的初始数据
|
|
*/
|
|
*/
|
|
data: {
|
|
data: {
|
|
- newNoticeTitle:''
|
|
|
|
|
|
+ newNoticeTitle:'' //滚动显示的公告标题
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -16,34 +16,42 @@ Page({
|
|
*/
|
|
*/
|
|
onLoad:async function(options) {
|
|
onLoad:async function(options) {
|
|
let result = await request('/front/notificationFront') //获取公告列表
|
|
let result = await request('/front/notificationFront') //获取公告列表
|
|
- console.log(result);
|
|
|
|
- let newNoticeTitle = this.data.newNoticeTitle
|
|
|
|
- var newId = ''
|
|
|
|
- // 获取最新的公告标题(未完成)
|
|
|
|
|
|
+ // console.log(result);
|
|
|
|
+ // 对公告列表按id降序排序(即按发布时间由近到远排序)
|
|
if(result.length == 0){
|
|
if(result.length == 0){
|
|
this.setData({
|
|
this.setData({
|
|
- newNoticeTitle:'暂无公告发布'
|
|
|
|
|
|
+ newNoticeTitle:'暂无公告内容'
|
|
})
|
|
})
|
|
- }else if(result.length == 1){
|
|
|
|
|
|
+ }else if(result.length == 1 && result[0].status == 1){
|
|
this.setData({
|
|
this.setData({
|
|
newNoticeTitle:result[0].title
|
|
newNoticeTitle:result[0].title
|
|
})
|
|
})
|
|
- }else{
|
|
|
|
- for(let i = 0;i < result.length - 1;i++){
|
|
|
|
- for(let j = i+1;j < result.length - 1 - i;j++){
|
|
|
|
|
|
+ }else if(result.length == 1 && result[0].status == 0){
|
|
|
|
+ this.setData({
|
|
|
|
+ newNoticeTitle:'暂无公告内容'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ for(let i = 0;i < result.length-1;i++){
|
|
|
|
+ for(let j = 0;j < result.length-1-i;j++){
|
|
if(result[j].id < result[j+1].id){
|
|
if(result[j].id < result[j+1].id){
|
|
- let temp = result[j].id
|
|
|
|
|
|
+ let temp = result[j]
|
|
result[j] = result[j+1]
|
|
result[j] = result[j+1]
|
|
result[j+1] = temp
|
|
result[j+1] = temp
|
|
}
|
|
}
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- console.log(result);
|
|
|
|
- this.setData({
|
|
|
|
- newNoticeTitle:result[0].title
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+ // console.log(result);
|
|
|
|
+ // 遍历重新排序后的列表,取出第一个状态为1的标题
|
|
|
|
+ for(let i = 0;i < result.length;i++){
|
|
|
|
+ if(result[i].status == 1){
|
|
|
|
+ this.setData({
|
|
|
|
+ newNoticeTitle:result[0].title
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
},
|
|
},
|
|
|
|
|
|
// 跳转到纳溪介绍页面
|
|
// 跳转到纳溪介绍页面
|