...
|
...
|
@@ -3,6 +3,8 @@ let method = require("../../utils/reuqest.js"); |
|
|
const util = require("../../utils/util.js");
|
|
|
Page({
|
|
|
data: {
|
|
|
page: 1,
|
|
|
classifyId: "",
|
|
|
idx: 0, //商品规格索引
|
|
|
check: false, //商品规格选择
|
|
|
goodsData: '', //获取商品库存
|
...
|
...
|
@@ -20,8 +22,25 @@ Page({ |
|
|
location: '',
|
|
|
latitude: '', //维度
|
|
|
longitude: '', //经度
|
|
|
bottomHint: false //触底提示
|
|
|
},
|
|
|
|
|
|
// tabbar
|
|
|
toHome() {
|
|
|
wx.reLaunch({
|
|
|
url: '/pages/home/home',
|
|
|
})
|
|
|
},
|
|
|
toShopCart() {
|
|
|
wx.reLaunch({
|
|
|
url: '/pages/shopping-cart/shopping-cart',
|
|
|
})
|
|
|
},
|
|
|
toUser() {
|
|
|
wx.reLaunch({
|
|
|
url: '/pages/user/user',
|
|
|
})
|
|
|
},
|
|
|
//获取定位
|
|
|
getLocation() {
|
|
|
let that = this;
|
|
|
wx.getLocation({
|
...
|
...
|
@@ -69,7 +88,7 @@ Page({ |
|
|
url: '/pages/searchRequest/searchRequest?keyword=' + this.data.keyword,
|
|
|
})
|
|
|
},
|
|
|
// 导航切换
|
|
|
// 导航菜单
|
|
|
catalog() {
|
|
|
method.getRequest('/category/getCategoryList', data => {
|
|
|
if (data.statusCode == 0) {
|
...
|
...
|
@@ -84,34 +103,43 @@ Page({ |
|
|
let that = this;
|
|
|
let list = that.data.lableArray;
|
|
|
let id = e.currentTarget.dataset.id;
|
|
|
this.setData({
|
|
|
classifyId: id
|
|
|
})
|
|
|
that.dataRequest(id)
|
|
|
},
|
|
|
//第一次数据请求
|
|
|
onData() {
|
|
|
onData(id) {
|
|
|
let postData = {
|
|
|
categoryId: this.data.lableArray[0].categoryId,
|
|
|
page: 1,
|
|
|
categoryId:this.data.classifyId,
|
|
|
page: this.data.page,
|
|
|
size: 10
|
|
|
}
|
|
|
method.postRequest('/goods/list', postData, data => {
|
|
|
let lists = this.data.page == 1 ? data.data : this.data.list.concat(data.data)
|
|
|
if (data.statusCode == 0) {
|
|
|
this.setData({
|
|
|
list: data.data
|
|
|
list: lists
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
//分类数据请求
|
|
|
dataRequest: function (id) {
|
|
|
this.setData({
|
|
|
page:1
|
|
|
})
|
|
|
let postData = {
|
|
|
categoryId: id,
|
|
|
page: 1,
|
|
|
page: this.data.page,
|
|
|
size: 10
|
|
|
}
|
|
|
method.postRequest('/goods/list', postData, data => {
|
|
|
wx.stopPullDownRefresh()
|
|
|
let lists = this.data.page == 1 ? data.data : this.data.list.concat(data.data)
|
|
|
if (data.statusCode == 0) {
|
|
|
this.setData({
|
|
|
list: data.data
|
|
|
list: lists
|
|
|
})
|
|
|
}
|
|
|
})
|
...
|
...
|
@@ -246,11 +274,24 @@ Page({ |
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
// this.dataRequest();
|
|
|
|
|
|
this.catalog();
|
|
|
if (wx.getStorageSync('categoryId')) {
|
|
|
let id=wx.getStorageSync('categoryId')
|
|
|
this.setData({
|
|
|
classifyId: id
|
|
|
})
|
|
|
this.dataRequest(this.data.classifyId);
|
|
|
} else {
|
|
|
setTimeout(() => {
|
|
|
this.setData({
|
|
|
classifyId: this.data.lableArray[0].categoryId
|
|
|
})
|
|
|
}, 500)
|
|
|
this.dataRequest(this.data.classifyId);
|
|
|
}
|
|
|
wx.removeStorageSync('categoryId')
|
|
|
wx.removeStorageSync('index')
|
|
|
this.catalog();
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -266,11 +307,16 @@ Page({ |
|
|
onShow: function () {
|
|
|
let categoryId = wx.getStorageSync('categoryId')
|
|
|
let index = wx.getStorageSync('classifyIndex')
|
|
|
this.setData({
|
|
|
activeKey: index
|
|
|
});
|
|
|
// this.location()
|
|
|
//this.getLocation();
|
|
|
if(index){
|
|
|
this.setData({
|
|
|
activeKey: index
|
|
|
});
|
|
|
}else{
|
|
|
this.setData({
|
|
|
activeKey:0
|
|
|
})
|
|
|
}
|
|
|
wx.removeStorageSync("classifyIndex")
|
|
|
let that = this;
|
|
|
wx.getLocation({
|
|
|
type: 'gcj02',
|
...
|
...
|
@@ -306,15 +352,33 @@ Page({ |
|
|
/**
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
*/
|
|
|
onRefresh() {
|
|
|
this.setData({
|
|
|
page: 1,
|
|
|
list: []
|
|
|
})
|
|
|
this.dataRequest(this.data.classifyId);
|
|
|
},
|
|
|
onPullDownRefresh: function () {
|
|
|
|
|
|
this.onRefresh()
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom: function () {
|
|
|
|
|
|
this.setData({
|
|
|
page: Number(this.data.page) + 1
|
|
|
})
|
|
|
this.dataRequest(this.data.classifyId);
|
|
|
this.setData({
|
|
|
bottomHint: true
|
|
|
})
|
|
|
setTimeout(() => {
|
|
|
this.setData({
|
|
|
bottomHint: false
|
|
|
})
|
|
|
}, 2000)
|
|
|
},
|
|
|
|
|
|
/**
|
...
|
...
|
|