You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
185 lines
4.4 KiB
185 lines
4.4 KiB
// pages/home/home.js
|
|
var app = getApp()
|
|
var WxParse = require('../../wxParse/wxParse.js');
|
|
import { getDetailProduct } from "../../api/home"
|
|
import { getAbout } from "../../api/home"
|
|
|
|
let that
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
|
|
fileList: [
|
|
{
|
|
url: '',
|
|
deletable: false,
|
|
},
|
|
],
|
|
id:10,
|
|
detailsList:[],
|
|
userPhone:'',
|
|
article:'',
|
|
title:'',
|
|
source:'',
|
|
|
|
},
|
|
|
|
// // 跳转发布
|
|
// openPub() {
|
|
// wx.switchTab({
|
|
// url: '/pages/publish/publish',
|
|
// })
|
|
// },
|
|
|
|
getAboutDetails() {
|
|
getAbout({}).then(res => {
|
|
that.setData({
|
|
userPhone: res.data.contact_phone ,
|
|
})
|
|
|
|
})
|
|
},
|
|
// 获取产品详情
|
|
getProductDetails() {
|
|
getDetailProduct({
|
|
id:that.data.id,
|
|
}).then(res => {
|
|
|
|
that.setData({
|
|
detailsList: res.data.postion,
|
|
title:res.data.detail.title,
|
|
source:res.data.detail.source,
|
|
fileList:[{
|
|
url:res.data.detail.image
|
|
}],
|
|
|
|
|
|
article: WxParse.wxParse('article', 'html', res.data.detail.content, that, 5)
|
|
})
|
|
console.log(that.data.detailsList)
|
|
})
|
|
|
|
},
|
|
|
|
callPhone (e) {
|
|
console.log(e.currentTarget.dataset.phone)
|
|
let mobile = e.currentTarget.dataset.phone; //获取data-phone的手机号
|
|
wx.makePhoneCall({
|
|
phoneNumber: mobile
|
|
})
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
that = this
|
|
wx.setNavigationBarTitle({
|
|
title: '首页',
|
|
})
|
|
// console.log(options.id) //options.参数名就可以取到
|
|
that.setData({
|
|
id: options.id
|
|
})
|
|
// var article = `< !DOCTYPE HTML >`+that.data.content;
|
|
// WxParse.wxParse('article', 'html', that.data.content, that, 5);
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
// that.getTabBar().init();
|
|
|
|
that.getProductDetails()
|
|
that.getAboutDetails()
|
|
/* that.getList({
|
|
page: that.data.page,
|
|
limit: that.data.limit
|
|
})
|
|
|
|
that.getTypeList()
|
|
that.setData({
|
|
minDate: new Date(new Date().getFullYear(), new Date().getMonth(), 1).getTime(),
|
|
maxDate: new Date(new Date().getFullYear(), new Date().getMonth() + 1, 0).getTime(),
|
|
today: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()).getTime()
|
|
}) */
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
// console.log("下拉刷新")
|
|
// that.setData({
|
|
// page: 1, // 每次触发下拉事件page=1
|
|
// })
|
|
// that.getList({
|
|
// page: 1,
|
|
// limit: that.data.limit,
|
|
// adCode: that.data.address ? that.data.address[1].code : '',
|
|
// labelId: that.data.curCate
|
|
// })
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
// console.log("上拉加载")
|
|
// if(that.data.list.length < that.data.total) {
|
|
// that.setData({
|
|
// page: that.data.page + 1
|
|
// })
|
|
// that.getList({
|
|
// page: that.data.page,
|
|
// limit: that.data.limit,
|
|
// adCode: that.data.address ? that.data.address[1].code : '',
|
|
// labelId: value.detail ? value.detail : ''
|
|
// })
|
|
// }else {
|
|
// Toast('没有更多数据了')
|
|
// }
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
},
|
|
// 下拉
|
|
onPageScroll: function(e) {
|
|
if (e.scrollTop < 0) {
|
|
wx.pageScrollTo({
|
|
scrollTop: 0
|
|
})
|
|
}
|
|
}
|
|
})
|