|
@@ -5,13 +5,28 @@ Page({
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
+ newList: []
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
- onLoad: function (options) {
|
|
|
-
|
|
|
+ onLoad: async function (options) {
|
|
|
+
|
|
|
+ const db = wx.cloud.database();
|
|
|
+ const _ = db.command;
|
|
|
+ const _this = this;
|
|
|
+ let list = await db.collection('data_news').where({
|
|
|
+ hot: 1,
|
|
|
+ type: 1
|
|
|
+ }).get();
|
|
|
+ for (let i = 0; i < list.data.length; i++) {
|
|
|
+ const v = list.data[i];
|
|
|
+ v.creat_time = this.format(v.creat_time || 0)
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ newList: list.data || []
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -63,21 +78,34 @@ Page({
|
|
|
|
|
|
},
|
|
|
|
|
|
- toDetail:function(e){
|
|
|
+ format: function (res) {
|
|
|
+ if (!res) return ""
|
|
|
+ let T = new Date(res || 0);
|
|
|
+ let year = T.getFullYear();
|
|
|
+ let month = T.getMonth() + 1;
|
|
|
+ let day = T.getDate();
|
|
|
+ let hour = T.getHours();
|
|
|
+ let min = T.getMinutes() + 1;
|
|
|
+ let sec = T.getSeconds();
|
|
|
+
|
|
|
+ return year + "-" + (month > 9 ? month : "0" + month) + "-" + day + " " + (hour > 9 ? hour : '0' + hour) + ":" + (min > 9 ? min : '0' + min) + ":" + (sec > 9 ? sec : '0' + sec);
|
|
|
+ },
|
|
|
+ toDetail: function (e) {
|
|
|
let title = e.currentTarget.dataset.title, id = e.currentTarget.dataset.id;
|
|
|
wx.navigateTo({
|
|
|
- url: '/pages/detail/detail?title=' +title + "&id=" + id,
|
|
|
+ url: '/pages/detail/detail?title=' + title + "&id=" + id,
|
|
|
})
|
|
|
},
|
|
|
- toRuins:function(e){
|
|
|
+ toRuins: function (e) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/ruins/index',
|
|
|
})
|
|
|
},
|
|
|
- toMarvellous:function(e){
|
|
|
+ toMarvellous: function (e) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/marvellous/index?title=' + e.currentTarget.dataset.title + "&type=" + e.currentTarget.dataset.type,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-})
|
|
|
+})
|
|
|
+
|