Browse Source

详情

test
Enzo 4 years ago
parent
commit
ee8c1da24e
  1. 39
      common/shared.js
  2. 13
      pages/message/detail.vue
  3. 13
      pages/notice/article.vue

39
common/shared.js

@ -24,4 +24,41 @@ export function isRight(obj) {
export function isValueType(value) {
let str = Object.prototype.toString.call(value);
return str.match(/\[object (.*?)\]/)[1].toLowerCase();
}
}
export const timer = (value, fmt) => {
if(!value) return;
let newTime = new Date(value)
if(!fmt){
fmt = 'yyyy-MM-dd hh:mm';
}
if(/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (newTime.getFullYear() + '').substr(4 - RegExp.$1.length));
}
let o = {
'M+': newTime.getMonth() + 1,
'd+': newTime.getDate(),
'h+': newTime.getHours(),
'm+': newTime.getMinutes(),
's+': newTime.getSeconds()
};
function padLeftZero(str) {
return ('00'+str).substr(str.length);
}
// 遍历这个对象
for (let k in o) {
if (new RegExp(`(${k})`).test(fmt)) {
// console.log(`${k}`)
let str = o[k] + '';
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : padLeftZero(str));
}
}
return fmt;
}
// 位数不足2,前面补0
var cover = function(par) {
par = par.toString()[1] ? par : "0" + par;
return par;
};

13
pages/message/detail.vue

@ -11,16 +11,21 @@
export default {
data(){
return {
content: ''
content: '',
news_id: 0
}
},
onLoad(){
// this.getData();
onLoad(e){
this.news_id = e.news_id
if(this.news_id) {
this.getData();
}
},
methods: {
getData(){
this.$http(this.API.API_ARTICLE_QA).then(res => {
this.$http(this.API.API_MESSAGEDETAILS,{id: this.news_id}).then(res => {
this.content = res.data?.content;
console.log(this.content)
})
}
}

13
pages/notice/article.vue

@ -11,16 +11,21 @@
export default {
data(){
return {
content: ''
content: '',
article_id: 0
}
},
onLoad(){
// this.getData();
onLoad(e){
this.article_id = e.article_id
if(this.article_id) {
this.getData();
}
},
methods: {
getData(){
this.$http(this.API.API_ARTICLE_QA).then(res => {
this.$http(this.API.API_FINDARTICLEDETAILS,{id: this.article_id}).then(res => {
this.content = res.data?.content;
console.log(this.content)
})
}
}

Loading…
Cancel
Save