|
@ -2,7 +2,9 @@ |
|
|
import dayjs from '../../utils/dayjs/index.js' |
|
|
import dayjs from '../../utils/dayjs/index.js' |
|
|
import relativeTime from '../../utils/dayjs/relativeTime.js' |
|
|
import relativeTime from '../../utils/dayjs/relativeTime.js' |
|
|
dayjs.extend(relativeTime); |
|
|
dayjs.extend(relativeTime); |
|
|
import { HomeModel } from '../../models/home.js' |
|
|
import { |
|
|
|
|
|
HomeModel |
|
|
|
|
|
} from '../../models/home.js' |
|
|
let homeModel = new HomeModel() |
|
|
let homeModel = new HomeModel() |
|
|
Page({ |
|
|
Page({ |
|
|
data: { |
|
|
data: { |
|
@ -11,9 +13,9 @@ Page({ |
|
|
banners: [], |
|
|
banners: [], |
|
|
hots: [], |
|
|
hots: [], |
|
|
list: [], |
|
|
list: [], |
|
|
show:false, |
|
|
show: false, |
|
|
// url:"../../images/ad.jpg",
|
|
|
// url:"../../images/ad.jpg",
|
|
|
web:'https://wx.vzan.com/live/TpForm?zbid=860533452&oId=213742&type=0&v=1623841891714' |
|
|
web: 'https://wx.vzan.com/live/TpForm?zbid=860533452&oId=213742&type=0&v=1623841891714' |
|
|
// web:'http://www.rencaibeichu.cn'
|
|
|
// web:'http://www.rencaibeichu.cn'
|
|
|
}, |
|
|
}, |
|
|
onLoad: function () { |
|
|
onLoad: function () { |
|
@ -35,8 +37,8 @@ Page({ |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
/** |
|
|
/** |
|
|
* 页面相关事件处理函数--监听用户下拉动作 |
|
|
* 页面相关事件处理函数--监听用户下拉动作 |
|
|
*/ |
|
|
*/ |
|
|
onPullDownRefresh: function () { |
|
|
onPullDownRefresh: function () { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
currPage: 1, |
|
|
currPage: 1, |
|
@ -46,7 +48,7 @@ Page({ |
|
|
this.fetchHomeBanner() |
|
|
this.fetchHomeBanner() |
|
|
this.fetchHomeHot() |
|
|
this.fetchHomeHot() |
|
|
wx.vibrateShort({ |
|
|
wx.vibrateShort({ |
|
|
success () { |
|
|
success() { |
|
|
//console.log('震动')
|
|
|
//console.log('震动')
|
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
@ -66,7 +68,7 @@ Page({ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取首页列表
|
|
|
// 获取首页列表
|
|
|
fetchHomeList () { |
|
|
fetchHomeList() { |
|
|
let page = this.data.currPage |
|
|
let page = this.data.currPage |
|
|
homeModel.getHomeList(page, res => { |
|
|
homeModel.getHomeList(page, res => { |
|
|
this.setData({ |
|
|
this.setData({ |
|
@ -82,7 +84,7 @@ Page({ |
|
|
image: item.titlePic, |
|
|
image: item.titlePic, |
|
|
showTop: item.isTop == 1 ? true : false, |
|
|
showTop: item.isTop == 1 ? true : false, |
|
|
time: dayjs(item.createTime).toNow(), |
|
|
time: dayjs(item.createTime).toNow(), |
|
|
type:item.type, |
|
|
type: item.type, |
|
|
readed: item.isRead == 0 ? false : true |
|
|
readed: item.isRead == 0 ? false : true |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
@ -113,7 +115,7 @@ Page({ |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fetchHomeBanner () { |
|
|
fetchHomeBanner() { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
banners: [] |
|
|
banners: [] |
|
|
}) |
|
|
}) |
|
@ -126,7 +128,8 @@ Page({ |
|
|
tempBanners.push({ |
|
|
tempBanners.push({ |
|
|
id: item.id, |
|
|
id: item.id, |
|
|
image: item.titlePic, |
|
|
image: item.titlePic, |
|
|
title: item.title |
|
|
title: item.title, |
|
|
|
|
|
type: item.type |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
this.setData({ |
|
|
this.setData({ |
|
@ -134,7 +137,7 @@ Page({ |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
fetchHomeHot () { |
|
|
fetchHomeHot() { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
hots: [] |
|
|
hots: [] |
|
|
}) |
|
|
}) |
|
@ -146,7 +149,8 @@ Page({ |
|
|
datas.forEach(item => { |
|
|
datas.forEach(item => { |
|
|
tempHots.push({ |
|
|
tempHots.push({ |
|
|
id: item.id, |
|
|
id: item.id, |
|
|
title: item.title |
|
|
title: item.title, |
|
|
|
|
|
type: item.type |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
this.setData({ |
|
|
this.setData({ |
|
@ -155,57 +159,81 @@ Page({ |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
// Banner/Hot/List事件
|
|
|
// Banner/Hot/List事件
|
|
|
tapSwiperItem (e) { |
|
|
tapSwiperItem(e) { |
|
|
//console.log(e.detail)
|
|
|
console.log(e) |
|
|
if(e.detail.id == '987a8433d925f36d3690fab91fe9e137'){ |
|
|
const { |
|
|
|
|
|
id, |
|
|
|
|
|
type |
|
|
|
|
|
} = e.detail |
|
|
|
|
|
if (e.detail.id == '987a8433d925f36d3690fab91fe9e137') { |
|
|
this.jump() |
|
|
this.jump() |
|
|
}else{ |
|
|
} else { |
|
|
this.gotoArticePage(e.detail.id) |
|
|
// this.gotoArticePage(e.detail.id)
|
|
|
|
|
|
if (type == 0) { |
|
|
|
|
|
this.gotoArticePage(id) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.gotoActivityPage(id) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
tapFocusItem (e) { |
|
|
tapFocusItem(e) { |
|
|
|
|
|
// console.log(e)
|
|
|
|
|
|
const { |
|
|
|
|
|
id, |
|
|
|
|
|
title, |
|
|
|
|
|
type |
|
|
|
|
|
} = e.detail |
|
|
//console.log(e.detail)
|
|
|
//console.log(e.detail)
|
|
|
this.gotoArticePage(e.detail.id) |
|
|
// this.gotoArticePage(e.detail.id)
|
|
|
|
|
|
//type 文章/活动标识0-文章,1-活动
|
|
|
|
|
|
if (type == 0) { |
|
|
|
|
|
this.gotoArticePage(id) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.gotoActivityPage(id) |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//点击列表cell获取id,进入页面
|
|
|
//点击列表cell获取id,进入页面
|
|
|
clickListItem (e) { |
|
|
clickListItem(e) { |
|
|
//console.log(e.detail)
|
|
|
//console.log(e.detail)
|
|
|
console.log('点击---',e) |
|
|
console.log('点击---', e) |
|
|
const {id, index,type} = e.detail |
|
|
const { |
|
|
|
|
|
id, |
|
|
|
|
|
index, |
|
|
|
|
|
type |
|
|
|
|
|
} = e.detail |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
[`list[${index}].readed`]: true |
|
|
[`list[${index}].readed`]: true |
|
|
}) |
|
|
}) |
|
|
//type 文章/活动标识0-文章,1-活动
|
|
|
//type 文章/活动标识0-文章,1-活动
|
|
|
if(type==0){ |
|
|
if (type == 0) { |
|
|
this.gotoArticePage(id) |
|
|
this.gotoArticePage(id) |
|
|
} |
|
|
} else { |
|
|
else{ |
|
|
this.gotoActivityPage(id) |
|
|
this.gotoActivityPage(id) |
|
|
} |
|
|
} |
|
|
|
|
|
}, |
|
|
}, |
|
|
//文章 0
|
|
|
//文章 0
|
|
|
gotoArticePage (id) { |
|
|
gotoArticePage(id) { |
|
|
wx.navigateTo({ |
|
|
wx.navigateTo({ |
|
|
url: `/pages/article/index?id=${id}`, |
|
|
url: `/pages/article/index?id=${id}`, |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
//活动 1
|
|
|
//活动 1
|
|
|
gotoActivityPage (id) { |
|
|
gotoActivityPage(id) { |
|
|
wx.navigateTo({ |
|
|
wx.navigateTo({ |
|
|
url: `/pages/topics/activity/activityDetail/index?activityId=${id}`, |
|
|
url: `/pages/topics/activity/activityDetail/index?activityId=${id}`, |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
onClose(){ |
|
|
onClose() { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
show:false |
|
|
show: false |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
jump:function(){ |
|
|
jump: function () { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
show:false |
|
|
show: false |
|
|
}) |
|
|
}) |
|
|
wx.navigateTo({ |
|
|
wx.navigateTo({ |
|
|
url: '/pages/resource/navigate/index?url=' + encodeURIComponent(this.data.web) |
|
|
url: '/pages/resource/navigate/index?url=' + encodeURIComponent(this.data.web) |
|
|