217 lines
3.9 KiB
JavaScript
217 lines
3.9 KiB
JavaScript
const app = getApp()
|
|
//a
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据00
|
|
*/
|
|
data: {
|
|
news: [],
|
|
pageNum: 1,
|
|
bannerdata: [
|
|
"home-banner"
|
|
]
|
|
},
|
|
|
|
onShow() {
|
|
// 重置页码并重新获取数据
|
|
this.setData({
|
|
pageNum: 1,
|
|
news: []
|
|
}, () => {
|
|
this.getOrderList()
|
|
})
|
|
},
|
|
|
|
// =============== 页面跳转相关 ===============
|
|
|
|
// 检查登录状态并跳转
|
|
checkLoginAndNavigate(path) {
|
|
if (!wx.getStorageSync('phone')) {
|
|
wx.setStorageSync('uidFlag', false)
|
|
this.showLoginModal()
|
|
return false
|
|
}
|
|
return true
|
|
},
|
|
|
|
// 显示登录提示
|
|
showLoginModal() {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '请先登录',
|
|
success(res) {
|
|
if (res.confirm) {
|
|
wx.switchTab({
|
|
url: '/pages/my/my'
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
// 生长曲线图
|
|
go_grow() {
|
|
if (this.checkLoginAndNavigate()) {
|
|
wx.navigateTo({
|
|
url: '/pages/grocur/grocur'
|
|
})
|
|
}
|
|
},
|
|
|
|
// 性发育图表
|
|
go_peizhen() {
|
|
// if (this.checkLoginAndNavigate()) {
|
|
// wx.showToast({
|
|
// title: '功能正在开发中',
|
|
// icon: 'none'
|
|
// })
|
|
// }
|
|
if (this.checkLoginAndNavigate()) {
|
|
wx.navigateTo({
|
|
url: '/pages/ghdCalculator/ghdCalculator'
|
|
})
|
|
}
|
|
},
|
|
|
|
// 性发育图表页面
|
|
go_chart() {
|
|
if (this.checkLoginAndNavigate()) {
|
|
wx.navigateTo({
|
|
url: '/pages/sexChart/sexChart'
|
|
})
|
|
}
|
|
},
|
|
|
|
// 身高SDS计算页面
|
|
redirectToHeightSDS() {
|
|
wx.navigateTo({
|
|
url: '/pages/heightSdsCalculator/heightSdsCalculator?category=1'
|
|
})
|
|
},
|
|
|
|
// 遗传靶身高计算页面
|
|
redirectToGeneticTargetHeight() {
|
|
wx.navigateTo({
|
|
url: '/pages/tarhei/tarhei'
|
|
})
|
|
},
|
|
|
|
// CPP预测计算
|
|
go_cpp() {
|
|
if (this.checkLoginAndNavigate()) {
|
|
wx.navigateTo({
|
|
url: '/pages/ghdCalculator/ghdCalculator'
|
|
})
|
|
}
|
|
},
|
|
|
|
// IGF-1参考值
|
|
go_peihu() {
|
|
if (this.checkLoginAndNavigate()) {
|
|
wx.navigateTo({
|
|
url: '/pages/igfrefer/igfrefer'
|
|
})
|
|
}
|
|
},
|
|
|
|
// =============== 资讯列表相关 ===============
|
|
|
|
// 获取资讯列表数据
|
|
getOrderList() {
|
|
wx.request({
|
|
url: app.globalData.url + 'app/Ruilaiwechat/selectRealtimeInfoList',
|
|
method: 'POST',
|
|
header: {
|
|
'content-type': 'application/x-www-form-urlencoded'
|
|
},
|
|
data: {
|
|
page: this.data.pageNum
|
|
},
|
|
success: this.handleOrderListResponse.bind(this)
|
|
})
|
|
},
|
|
|
|
// 处理资讯列表响应
|
|
handleOrderListResponse(res) {
|
|
if (res.data.erro !== 0) {
|
|
wx.showToast({
|
|
title: '获取数据失败',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
|
|
const { lists, currentPage } = res.data
|
|
|
|
if (lists && lists.length > 0) {
|
|
this.setData({
|
|
news: currentPage === 1 ? lists : this.data.news.concat(lists),
|
|
pageNum: currentPage + 1
|
|
})
|
|
}
|
|
},
|
|
|
|
// 资讯项点击
|
|
itemclick(e) {
|
|
const { url } = e.currentTarget.dataset
|
|
wx.navigateTo({
|
|
url: `/pages/webpage/webpage?url=${url}`
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
// 下拉刷新时重置页码并重新获取数据
|
|
this.setData({
|
|
pageNum: 1,
|
|
news: []
|
|
}, () => {
|
|
this.getOrderList()
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
// 上拉加载更多数据
|
|
this.getOrderList()
|
|
},
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
|
|
}) |