|
@@ -1,5 +1,5 @@
|
|
|
// pages/home/home.js
|
|
|
-const { getCategoryAPI,getClassifyGoods} = require('../../API/appraise')
|
|
|
+const { getCategoryAPI, getAllGoods} = require('../../API/appraise')
|
|
|
|
|
|
|
|
|
Page({
|
|
@@ -12,6 +12,12 @@ Page({
|
|
|
classifyList: [],
|
|
|
//用于存放页面上划高度
|
|
|
scrollTop: 0,
|
|
|
+ //存放所有商品
|
|
|
+ allGoods: [],
|
|
|
+ page: 1,
|
|
|
+ pageSize: 6,
|
|
|
+ flag: true,
|
|
|
+ isLoading: false
|
|
|
},
|
|
|
|
|
|
userTo() {
|
|
@@ -24,6 +30,11 @@ Page({
|
|
|
url: '/pages/classify/classify',
|
|
|
})
|
|
|
},
|
|
|
+ messageTo() {
|
|
|
+ wx.switchTab({
|
|
|
+ url: '/pages/message/message',
|
|
|
+ })
|
|
|
+ },
|
|
|
searchTo() {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/search/search',
|
|
@@ -37,11 +48,17 @@ Page({
|
|
|
url: '/pages/classify_detail/classify_detail?classify_id=' + id + '&title=' + title,
|
|
|
})
|
|
|
},
|
|
|
+ flagChange() {
|
|
|
+ this.setData({
|
|
|
+ flag: false
|
|
|
+ })
|
|
|
+ },
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad(options) {
|
|
|
this.getClassifyList();
|
|
|
+ this.getGoodsList();
|
|
|
this.setData({
|
|
|
avatarUrl:wx.getStorageSync('avatarUrl'),
|
|
|
nickName: wx.getStorageSync('nickName')
|
|
@@ -57,11 +74,35 @@ Page({
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
- // getGoodsList() {
|
|
|
- // getClassifyGoods(this.data).then((data) => {
|
|
|
- // console.log(data);
|
|
|
- // })
|
|
|
- // },
|
|
|
+ //获取推荐商品
|
|
|
+ getGoodsList() {
|
|
|
+ //加载的loading效果
|
|
|
+ wx.showLoading({
|
|
|
+ title: '数据获取中',
|
|
|
+ })
|
|
|
+ getAllGoods(this.data).then((res) => {
|
|
|
+ const { code, data, message } = res.data;
|
|
|
+ const d = data.data;
|
|
|
+ this.setData({
|
|
|
+ allGoods: [...this.data.allGoods, ...d],
|
|
|
+ isLoading: true
|
|
|
+ })
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ isLoading: false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //推荐商品传递数据
|
|
|
+ detailTo(e) {
|
|
|
+ console.log(e.currentTarget.dataset);
|
|
|
+ const id = e.currentTarget.dataset.id;
|
|
|
+ const title = e.currentTarget.dataset.title;
|
|
|
+ const price = e.currentTarget.dataset.price;
|
|
|
+ const comImg = e.currentTarget.dataset.pic;
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pages/details/details?id=' + id + '&title=' + title + '&price=' + price + '&img=' + comImg,
|
|
|
+ })
|
|
|
+ },
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
@@ -101,7 +142,12 @@ Page({
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom() {
|
|
|
-
|
|
|
+ if(this.data.isLoading) {
|
|
|
+ this.setData({
|
|
|
+ page: this.data.page + 1,
|
|
|
+ })
|
|
|
+ this.getGoodsList()
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
/**
|