|
@@ -10,51 +10,20 @@ Component({
|
|
|
position:{
|
|
position:{
|
|
|
type:String,
|
|
type:String,
|
|
|
value:''
|
|
value:''
|
|
|
|
|
+ },
|
|
|
|
|
+ filterObj:{
|
|
|
|
|
+ type:Object,
|
|
|
|
|
+ value:{}
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ observers:{
|
|
|
|
|
+ "filterObj": function(newVal){
|
|
|
|
|
+ this.getClassifyCommodity();
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
data: {
|
|
data: {
|
|
|
- goodsList: [
|
|
|
|
|
- {
|
|
|
|
|
- name: "哪吒魔童闹海周边哪吒魔童闹海周边哪吒魔童闹海周边",
|
|
|
|
|
- price: 49.5,
|
|
|
|
|
- image:'/images/index/hot-item.png'
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- name: "若来十二生肖盲盒 桌面手办若来十二生肖盲盒 桌面手办若来十二生肖盲盒 桌面手办",
|
|
|
|
|
- price: 49.5,
|
|
|
|
|
- image:'/images/index/hot-item.png'
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- name: "官方正版姜子牙电影四不像",
|
|
|
|
|
- price: 49.5,
|
|
|
|
|
- image:'/images/index/hot-item.png'
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- name: "若来十二生肖盲盒 十二节气祖国版",
|
|
|
|
|
- price: 49.5,
|
|
|
|
|
- image:'/images/index/hot-item.png'
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- name: "哪吒魔童闹海周边哪吒魔童闹海周边哪吒魔童闹海周边",
|
|
|
|
|
- price: 49.5,
|
|
|
|
|
- image:'/images/index/hot-item.png'
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- name: "若来十二生肖盲盒 桌面手办若来十二生肖盲盒 桌面手办若来十二生肖盲盒 桌面手办",
|
|
|
|
|
- price: 49.5,
|
|
|
|
|
- image:'/images/index/hot-item.png'
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- name: "官方正版姜子牙电影四不像",
|
|
|
|
|
- price: 49.5,
|
|
|
|
|
- image:'/images/index/hot-item.png'
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- name: "若来十二生肖盲盒 十二节气祖国版",
|
|
|
|
|
- price: 49.5,
|
|
|
|
|
- image:'/images/index/hot-item.png'
|
|
|
|
|
- },
|
|
|
|
|
- ],
|
|
|
|
|
|
|
+ goodsList: [],
|
|
|
|
|
+ pageNum:1,
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
// 获取今日热门商品列表
|
|
// 获取今日热门商品列表
|
|
@@ -86,11 +55,37 @@ Component({
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ // 获取分类商品
|
|
|
|
|
+ getClassifyCommodity(){
|
|
|
|
|
+ let data = {
|
|
|
|
|
+ ...this.data.filterObj,
|
|
|
|
|
+ pageNum:this.data.pageNum,
|
|
|
|
|
+ pageSize:5
|
|
|
|
|
+ }
|
|
|
|
|
+ API.getProdsList(data).then(res=>{
|
|
|
|
|
+ if(res){
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ goodsList:this.data.pageNum === 1?res.mercProdList:[...this.data.goodsList,...res.mercProdList]
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ // 观察滚动触底事件
|
|
|
|
|
+ onReachBottom(e){
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ pageNum:this.data.pageNum+1
|
|
|
|
|
+ });
|
|
|
|
|
+ this.observerFunction();
|
|
|
|
|
+ },
|
|
|
|
|
+ observerFunction(){
|
|
|
|
|
+ if(this.data.position === 'hot') this.getHotCommodity();
|
|
|
|
|
+ if(this.data.position === 'new') this.getNewCommodity();
|
|
|
|
|
+ if(this.data.position === 'presale') this.getPresaleCommodity();
|
|
|
|
|
+ if(this.data.position === 'sort') this.getClassifyCommodity();
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
ready: function(){
|
|
ready: function(){
|
|
|
- if(this.data.position === 'hot') this.getHotCommodity();
|
|
|
|
|
- if(this.data.position === 'new') this.getNewCommodity();
|
|
|
|
|
- if(this.data.position === 'presale') this.getPresaleCommodity();
|
|
|
|
|
|
|
+ this.observerFunction();
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|