1、獲取日期並格式化(已解決)
dateFormat: function (date) { //author: theyn
var year = date.getFullYear()
var month = date.getMonth() + 1
var day = date.getDate()
var hour = date.getHours()
var minutes = date.getMinutes()
var seconds = date.getSeconds()
var realseconds = seconds > 9 ? seconds : "0" + seconds
var realminutes = minutes > 9 ? minutes : "0" + minutes
var realhour = hour > 9 ? hour : "0" + hour
var realday = day > 9 ? day : "0" + day
var realMonth = month > 9 ? month : "0" + month
return year + "-" + realMonth + "-" + realday + " "+ realhour+ ":" + realminutes + ":" + realseconds
},
2、查看個人發佈歷史
踩坑a 發佈的數據庫保存到了兩張表,topic和history,主頁和發佈歷史共用的詳情頁,結果發佈歷史進去詳情頁爲空,原因是詳情頁查詢的是topic的ID,從history傳過來的ID就查找不到內容。解決:發佈歷史也使用topic數據庫
踩坑b 發佈歷史包含別人發佈的,原因是需要用的openID模塊已經加載出來了,openID還沒獲取到,導致openID爲空
獲取openid的坑
解決:獲取成功後再調用函數
success: res => {
app.globalData.openid = res.result.openid
that.getData(that.data.page);