2019-12-13 15:39:55 +08:00
|
|
|
// pages/classify/classify.js
|
2019-12-19 11:10:21 +08:00
|
|
|
import { request } from "../../utils/bin"
|
2019-12-13 15:39:55 +08:00
|
|
|
Page({
|
|
|
|
|
2019-12-19 11:10:21 +08:00
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
2019-12-19 17:22:23 +08:00
|
|
|
type: [],
|
|
|
|
list:[]
|
2019-12-19 11:10:21 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad: function(options) {
|
|
|
|
request({
|
|
|
|
url: "Goods/goodsCategoryList",
|
|
|
|
data: {
|
|
|
|
parent_id: 2
|
|
|
|
}
|
|
|
|
}).then((res) => {
|
|
|
|
// console.log(res)
|
|
|
|
this.setData({
|
|
|
|
type: res.data.result
|
|
|
|
})
|
2019-12-19 17:22:23 +08:00
|
|
|
this.select({detail:{id:res.data.result[0].id}})
|
2019-12-19 11:10:21 +08:00
|
|
|
console.log(this.data.type, 150)
|
|
|
|
})
|
|
|
|
|
|
|
|
},
|
2019-12-19 17:22:23 +08:00
|
|
|
select(a){
|
|
|
|
// console.log(a)
|
|
|
|
// a.detail.id
|
|
|
|
request({
|
|
|
|
url:'Goods/goodsList',
|
|
|
|
urldata:{
|
|
|
|
id:a.detail.id,
|
|
|
|
sort:'shop_price',
|
|
|
|
sort_asc:'desc',
|
|
|
|
p:0
|
|
|
|
}
|
|
|
|
}).then((res)=>{
|
|
|
|
console.log(res)
|
|
|
|
this.setData({
|
|
|
|
list:res.data.result.goods_list
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
2019-12-19 11:10:21 +08:00
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady: function() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: function() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide: function() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload: function() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
onPullDownRefresh: function() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
onReachBottom: function() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage: function() {
|
|
|
|
|
|
|
|
}
|
2019-12-13 15:39:55 +08:00
|
|
|
})
|