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.
 

167 lines
3.5 KiB

// pages/activity/year2020/index.js
import commonApi from "../../../utils/https/common"
import util from "../../../utils/util"
let device = wx.getSystemInfoSync();
const ratio = device.windowWidth / 750;
Page({
/**
* 页面的初始数据
*/
data: {
zhouzhuang:[],
haofengguang:[],
dongshan:[],
huqiu:[],
jiangnan:[],
list:[],
total:1,
top:0
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let rect = wx.getMenuButtonBoundingClientRect();
let height = (rect.top - device.statusBarHeight) * 2 + rect.height + device.statusBarHeight;
this.setData({
top:height
})
// 周庄年货专区
commonApi._post("adv/getAdvByKey",{
key:"zhouzhuangnianhuo"
}).then(res=>{
this.setData({
zhouzhuang:res.data.content || []
})
})
// 苏州好风光
commonApi._post("adv/getAdvByKey",{
key:"haofengguangnianhuo"
}).then(res=>{
this.setData({
haofengguang:res.data.content || []
})
})
// 东山爆款好物
commonApi._post("adv/getAdvByKey",{
key:"dongshannianhuo"
}).then(res=>{
this.setData({
dongshan:res.data.content || []
})
})
// 虎丘茶礼
commonApi._post("adv/getAdvByKey",{
key:"huqiunianhuo"
}).then(res=>{
this.setData({
huqiu:res.data.content || []
})
})
// 江南米造局
commonApi._post("adv/getAdvByKey",{
key:"jiangniannianhuo"
}).then(res=>{
this.setData({
jiangnan:res.data.content || []
})
})
this.getList()
},
getList:function(){
let list = this.data.list;
if(list.length>=this.data.total) return;
commonApi._post('product/get_product_by_tag',{
tag_id:22,
offset:list.length,
limit:10
}).then(res=>{
list = list.concat(res.data.list);
this.setData({
list:list,
total:res.data.total
})
})
},
gotoDetail:function(e){
let item = e.currentTarget.dataset.item;
let [type,id] = item.href.split(",");
util.gotoDetail({
type:type,
id:id
})
},
gotoDetail2:function(e){
let item = e.currentTarget.dataset.item;
util.gotoDetail(item)
},
home:function(){
wx.switchTab({
url: '/pages/index/index',
})
},
gotoScroll:function(e){
let that = this,index = e.currentTarget.dataset.index;
const query=wx.createSelectorQuery(); //创建节点查询器
query.select("#box"+index).boundingClientRect() //选择toViewid获取位置信息
query.selectViewport().scrollOffset() //获取页面查询位置的
query.exec(function(res) {
let scrollTop = res[0].top + res[1].scrollTop - that.data.top;
wx.pageScrollTo({
scrollTop: scrollTop + 4,
duration: 500
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.getList()
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})